Convert( this VisualCCommon.ICommonCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.NoLogo.GetValueOrDefault(false)) { vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo.Value, condition); } if (settings.RuntimeLibrary.HasValue) { vsSettingsGroup.AddSetting("RuntimeLibrary", settings.RuntimeLibrary.Value.ToString(), condition); } if (settings.WarningLevel.HasValue) { if (EWarningLevel.Level0 == settings.WarningLevel.Value) { vsSettingsGroup.AddSetting("WarningLevel", "TurnOffAllWarnings", condition); } else { vsSettingsGroup.AddSetting("WarningLevel", System.String.Format("Level{0}", settings.WarningLevel.Value.ToString("D")), condition); } } if (settings.EnableLanguageExtensions.HasValue) { vsSettingsGroup.AddSetting("DisableLanguageExtensions", !settings.EnableLanguageExtensions.Value, condition); } }
Convert( this C.ICommonWinResourceCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.Verbose.HasValue) { vsSettingsGroup.AddSetting("ShowProgress", settings.Verbose.Value, condition); } vsSettingsGroup.AddSetting("ResourceOutputFileName", module.GeneratedPaths[C.ObjectFile.Key].Parse(), condition); }
Convert( this VisualCCommon.ICommonAssemblerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { vsSettingsGroup.AddSetting("NoLogo", settings.NoLogo, condition); vsSettingsGroup.AddSetting("WarningLevel", settings.WarningLevel.ToString("D"), condition); // safe exception handlers only required in 32-bit mode if (((settings as Bam.Core.Settings).Module as C.CModule).BitDepth == C.EBit.ThirtyTwo) { vsSettingsGroup.AddSetting("UseSafeExceptionHandlers", settings.SafeExceptionHandlers, condition); } }
Convert( this C.ICxxOnlyCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.ExceptionHandler.HasValue) { System.Func <string> exceptionHandler = () => { switch (settings.ExceptionHandler.Value) { case C.Cxx.EExceptionHandler.Disabled: return("false"); case C.Cxx.EExceptionHandler.Asynchronous: return("Async"); case C.Cxx.EExceptionHandler.Synchronous: return("Sync"); case C.Cxx.EExceptionHandler.SyncWithCExternFunctions: return("SyncCThrow"); default: throw new Bam.Core.Exception("Unknown exception handler, {0}", settings.ExceptionHandler.Value.ToString()); } }; vsSettingsGroup.AddSetting("ExceptionHandling", exceptionHandler(), condition); } }
Convert( this C.ICommonLinkerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { switch (settings.Bits) { case C.EBit.ThirtyTwo: vsSettingsGroup.AddSetting("TargetMachine", "MachineX86", condition); break; case C.EBit.SixtyFour: vsSettingsGroup.AddSetting("TargetMachine", "MachineX64", condition); break; default: throw new Bam.Core.Exception("Unknown machine bit depth, {0}", settings.Bits.ToString()); } switch (settings.OutputType) { case C.ELinkerOutput.Executable: { var outPath = module.GeneratedPaths[C.ConsoleApplication.Key].Parse(); vsSettingsGroup.AddSetting("OutputFile", System.String.Format("$(OutDir)\\{0}", System.IO.Path.GetFileName(outPath)), condition); } break; case C.ELinkerOutput.DynamicLibrary: { var outPath = module.GeneratedPaths[C.DynamicLibrary.Key].Parse(); vsSettingsGroup.AddSetting("OutputFile", System.String.Format("$(OutDir)\\{0}", System.IO.Path.GetFileName(outPath)), condition); var importPath = module.GeneratedPaths[C.DynamicLibrary.ImportLibraryKey].ToString(); vsSettingsGroup.AddSetting("ImportLibrary", System.String.Format("$(OutDir)\\{0}", System.IO.Path.GetFileName(importPath)), condition); } break; } vsSettingsGroup.AddSetting("AdditionalLibraryDirectories", settings.LibraryPaths, condition); vsSettingsGroup.AddSetting("AdditionalDependencies", settings.Libraries, condition); if (settings.DebugSymbols) { vsSettingsGroup.AddSetting("GenerateDebugInformation", true, condition); if (null != module.GeneratedPaths[C.ConsoleApplication.PDBKey]) { vsSettingsGroup.AddSetting("ProgramDatabaseFile", module.GeneratedPaths[C.ConsoleApplication.PDBKey], condition, isPath: true); } } }
Convert( this ICommonLinkerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo, condition); }
Convert( this C.ICommonWinResourceCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.Verbose.HasValue) { vsSettingsGroup.AddSetting("ShowProgress", settings.Verbose.Value, condition); } if (settings.IncludePaths.Count > 0) { vsSettingsGroup.AddSetting("AdditionalIncludeDirectories", settings.IncludePaths, condition, inheritExisting: true, arePaths: true); } vsSettingsGroup.AddSetting("ResourceOutputFileName", module.GeneratedPaths[C.ObjectFile.Key], condition, isPath: true); }
Convert( this C.IAdditionalSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.AdditionalSettings.Count > 0) { vsSettingsGroup.AddSetting("AdditionalOptions", settings.AdditionalSettings, condition); } }
Convert( this ICommonLinkerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo, condition); var solution = Bam.Core.Graph.Instance.MetaData as VSSolutionBuilder.VSSolution; var project = solution.EnsureProjectExists(module); var config = project.GetConfiguration(module); config.EnableManifest = settings.GenerateManifest; // safe exception handlers only required in 32-bit mode if (((settings as Bam.Core.Settings).Module as C.CModule).BitDepth == C.EBit.ThirtyTwo) { vsSettingsGroup.AddSetting("ImageHasSafeExceptionHandlers", settings.SafeExceptionHandlers, condition); } }
Convert( this ICommonWinResourceCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.NoLogo.HasValue) { vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo.Value, condition); } }
Convert( this C.ICommonLinkerSettingsWin settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { switch (settings.SubSystem.Value) { case C.ESubsystem.Console: case C.ESubsystem.Windows: vsSettingsGroup.AddSetting("SubSystem", settings.SubSystem.Value.ToString(), condition); break; default: throw new Bam.Core.Exception("Unrecognized subsystem: {0}", settings.SubSystem.Value.ToString()); } if (null != settings.ExportDefinitionFile) { vsSettingsGroup.AddSetting("ModuleDefinitionFile", settings.ExportDefinitionFile, condition); } }
Convert( this C.ICommonAssemblerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { vsSettingsGroup.AddSetting("GenerateDebugInformation", settings.DebugSymbols, condition); switch (settings.OutputType) { case C.ECompilerOutput.CompileOnly: vsSettingsGroup.AddSetting("GeneratePreprocessedSourceListing", false, condition); break; case C.ECompilerOutput.Preprocess: vsSettingsGroup.AddSetting("GeneratePreprocessedSourceListing", true, condition); break; } vsSettingsGroup.AddSetting("TreatWarningsAsErrors", settings.WarningsAsErrors, condition); if (settings.IncludePaths.Any()) { vsSettingsGroup.AddSetting("IncludePaths", settings.IncludePaths, condition, inheritExisting: true, arePaths: true); } if (settings.PreprocessorDefines.Any()) { vsSettingsGroup.AddSetting("PreprocessorDefinitions", settings.PreprocessorDefines, condition, inheritExisting: true); } }
Convert( this ICommonLinkerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo, condition); var solution = Bam.Core.Graph.Instance.MetaData as VSSolutionBuilder.VSSolution; var project = solution.EnsureProjectExists(module); var config = project.GetConfiguration(module); config.EnableManifest = settings.GenerateManifest; }
Convert( this C.ICxxOnlyCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.ExceptionHandler.HasValue) { System.Func <string> exceptionHandler = () => { switch (settings.ExceptionHandler.Value) { case C.Cxx.EExceptionHandler.Disabled: return("false"); case C.Cxx.EExceptionHandler.Asynchronous: return("Async"); case C.Cxx.EExceptionHandler.Synchronous: return("Sync"); case C.Cxx.EExceptionHandler.SyncWithCExternFunctions: return("SyncCThrow"); default: throw new Bam.Core.Exception("Unknown exception handler, {0}", settings.ExceptionHandler.Value.ToString()); } }; vsSettingsGroup.AddSetting("ExceptionHandling", exceptionHandler(), condition); } if (settings.EnableRunTimeTypeInfo.HasValue) { vsSettingsGroup.AddSetting("RuntimeTypeInfo", settings.EnableRunTimeTypeInfo.Value, condition); } // CL automatically supports language standards // No different standard library }
Convert( this C.ICommonArchiverSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { switch (settings.OutputType) { case C.EArchiverOutput.StaticLibrary: { var outPath = module.GeneratedPaths[C.StaticLibrary.Key].ToString(); vsSettingsGroup.AddSetting("OutputFile", System.String.Format("$(OutDir)\\{0}", System.IO.Path.GetFileName(outPath)), condition); } break; default: throw new Bam.Core.Exception("Unknown output type, {0}", settings.OutputType.ToString()); } }
Convert( this C.ICommonLinkerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { switch (settings.OutputType) { case C.ELinkerOutput.Executable: { var outPath = module.GeneratedPaths[C.ConsoleApplication.Key].Parse(); vsSettingsGroup.AddSetting("OutputFile", System.String.Format("$(OutDir)\\{0}", System.IO.Path.GetFileName(outPath)), condition); } break; case C.ELinkerOutput.DynamicLibrary: { var outPath = module.GeneratedPaths[C.DynamicLibrary.Key].Parse(); vsSettingsGroup.AddSetting("OutputFile", System.String.Format("$(OutDir)\\{0}", System.IO.Path.GetFileName(outPath)), condition); var importPath = module.GeneratedPaths[C.DynamicLibrary.ImportLibraryKey].ToString(); vsSettingsGroup.AddSetting("ImportLibrary", System.String.Format("$(OutDir)\\{0}", System.IO.Path.GetFileName(importPath)), condition); } break; } vsSettingsGroup.AddSetting("AdditionalLibraryDirectories", settings.LibraryPaths, condition); vsSettingsGroup.AddSetting("AdditionalDependencies", settings.Libraries, condition); if (settings.DebugSymbols) { vsSettingsGroup.AddSetting("GenerateDebugInformation", true, condition); if (null != module.GeneratedPaths[C.ConsoleApplication.PDBKey]) { vsSettingsGroup.AddSetting("ProgramDatabaseFile", module.GeneratedPaths[C.ConsoleApplication.PDBKey], condition); } } }
Convert( this VisualCCommon.ICommonCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { if (settings.NoLogo.GetValueOrDefault(false)) { vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo.Value, condition); } if (settings.RuntimeLibrary.HasValue) { vsSettingsGroup.AddSetting("RuntimeLibrary", settings.RuntimeLibrary.Value.ToString(), condition); } if (settings.WarningLevel.HasValue) { if (EWarningLevel.Level0 == settings.WarningLevel.Value) { vsSettingsGroup.AddSetting("WarningLevel", "TurnOffAllWarnings", condition); } else { vsSettingsGroup.AddSetting("WarningLevel", System.String.Format("Level{0}", settings.WarningLevel.Value.ToString("D")), condition); } } if (settings.EnableLanguageExtensions.HasValue) { vsSettingsGroup.AddSetting("DisableLanguageExtensions", !settings.EnableLanguageExtensions.Value, condition); } if (settings.Optimization.HasValue) { var common_optimization = (settings as C.ICommonCompilerSettings).Optimization; if (common_optimization.HasValue && common_optimization.Value != C.EOptimization.Custom) { throw new Bam.Core.Exception("Compiler specific optimizations can only be set when the common optimization is C.EOptimization.Custom"); } System.Func <string> optimization = () => { switch (settings.Optimization.Value) { case EOptimization.Full: return("Full"); default: throw new Bam.Core.Exception("Unknown compiler optimization type, {0}", settings.Optimization.Value.ToString()); } }; vsSettingsGroup.AddSetting("Optimization", optimization(), condition); } if (settings.IncreaseObjectFileSectionCount.HasValue) { if (settings.IncreaseObjectFileSectionCount.Value) { vsSettingsGroup.AddSetting("AdditionalOptions", "-bigobj", condition); } } }
Convert( this C.ICommonCompilerSettings settings, Bam.Core.Module module, VSSolutionBuilder.VSSettingsGroup vsSettingsGroup, string condition) { // write nothing for disabled debug symbols, otherwise the source files rebuild continually // and reports a warning that the pdb file does not exist // the IDE can write None into the .vcxproj, but this has the same behaviour // https://connect.microsoft.com/VisualStudio/feedback/details/833494/project-with-debug-information-disabled-always-rebuilds if (settings.DebugSymbols.HasValue) { if (settings.DebugSymbols.Value) { vsSettingsGroup.AddSetting("DebugInformationFormat", "OldStyle", condition); } } if (settings.DisableWarnings.Count > 0) { vsSettingsGroup.AddSetting("DisableSpecificWarnings", settings.DisableWarnings, condition, inheritExisting: true); } if (settings.IncludePaths.Count > 0) { vsSettingsGroup.AddSetting("AdditionalIncludeDirectories", settings.IncludePaths, condition, inheritExisting: true); } if (settings.OmitFramePointer.HasValue) { vsSettingsGroup.AddSetting("OmitFramePointers", settings.OmitFramePointer.Value, condition); } if (settings.Optimization.HasValue) { System.Func <string> optimization = () => { switch (settings.Optimization.Value) { case C.EOptimization.Off: return("Disabled"); case C.EOptimization.Size: return("MinSpace"); case C.EOptimization.Speed: return("MaxSpeed"); case C.EOptimization.Full: return("Full"); default: throw new Bam.Core.Exception("Unknown optimization type, {0}", settings.Optimization.Value.ToString()); } }; vsSettingsGroup.AddSetting("Optimization", optimization(), condition); } if (settings.PreprocessorDefines.Count > 0) { vsSettingsGroup.AddSetting("PreprocessorDefinitions", settings.PreprocessorDefines, condition, inheritExisting: true); } if (settings.PreprocessorUndefines.Count > 0) { vsSettingsGroup.AddSetting("UndefinePreprocessorDefinitions", settings.PreprocessorUndefines, condition, inheritExisting: true); } if (settings.TargetLanguage.HasValue) { System.Func <string> targetLanguage = () => { switch (settings.TargetLanguage.Value) { case C.ETargetLanguage.C: return("CompileAsC"); case C.ETargetLanguage.Cxx: return("CompileAsCpp"); case C.ETargetLanguage.Default: return("Default"); default: throw new Bam.Core.Exception("Unknown target language, {0}", settings.TargetLanguage.Value.ToString()); } }; vsSettingsGroup.AddSetting("CompileAs", targetLanguage(), condition); } if (settings.WarningsAsErrors.HasValue) { vsSettingsGroup.AddSetting("TreatWarningAsError", settings.WarningsAsErrors.Value, condition); } if (settings.OutputType.HasValue) { vsSettingsGroup.AddSetting("PreprocessToFile", settings.OutputType.Value == C.ECompilerOutput.Preprocess, condition); if (module is C.ObjectFile) // rather than ObjectFileCollection { vsSettingsGroup.AddSetting("ObjectFileName", module.GeneratedPaths[C.ObjectFile.Key], condition); } } }