VisualStudioProcessor.IConvertToProject.Convert(
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
     VisualStudioProcessor.Conversion.Convert(typeof(VisualCCommon.VSSolutionImplementation), this, module, vsSettingsGroup, 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);
            }
        }
Example #3
0
 public static void Convert(
     System.Type conversionClass,
     Bam.Core.Settings settings,
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
     var moduleType = typeof(Bam.Core.Module);
     var vsSettingsGroupType = typeof(VSSolutionBuilder.VSSettingsGroup);
     var stringType = typeof(string);
     foreach (var i in settings.Interfaces())
     {
         var method = conversionClass.GetMethod("Convert", new[] { i, moduleType, vsSettingsGroupType, stringType });
         if (null == method)
         {
             throw new Bam.Core.Exception("Unable to locate method {0}.Convert({1}, {2}, {3})",
                 conversionClass.ToString(),
                 i.ToString(),
                 moduleType,
                 vsSettingsGroupType,
                 stringType);
         }
         try
         {
             method.Invoke(null, new object[] { settings, module, vsSettingsGroup, condition });
         }
         catch (System.Reflection.TargetInvocationException exception)
         {
             throw new Bam.Core.Exception(exception.InnerException, "VisualStudio conversion error:");
         }
     }
 }
 Convert(
     this C.ICOnlyCompilerSettings settings,
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string 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);
                }
            }
        }
 public static void Convert(
     this ICommonLinkerSettings settings,
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
     vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo, condition);
 }
 public static void 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);
     }
 }
 public static void Convert(
     this ICommonWinResourceCompilerSettings settings,
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
     if (settings.NoLogo.HasValue)
     {
         vsSettingsGroup.AddSetting("SuppressStartupBanner", settings.NoLogo.Value, condition);
     }
 }
 public static void 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);
 }
Example #10
0
        public static void 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());
            }
        }
        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.ICommonCompilerSettingsWin settings,
     Bam.Core.Module module,
     VSSolutionBuilder.VSSettingsGroup vsSettingsGroup,
     string condition)
 {
     if (settings.CharacterSet.HasValue)
     {
         // this setting is project wide
         var encapsulating = module.GetEncapsulatingReferencedModule();
         if (encapsulating != module)
         {
             // if it is not being applied project wide, then this cannot be represented properly in VisualStudio projects
             // as the character set is applied at the project level
             throw new Bam.Core.Exception("Unable to apply character set change to a subset of source files in the VisualStudio project for module '{0}'", encapsulating.ToString());
         }
         var project = module.MetaData as VSSolutionBuilder.VSProject;
         var config = project.GetConfiguration(module);
         config.SetCharacterSet(settings.CharacterSet.Value);
     }
 }
        public static void 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 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);
                }
            }
        }