Ejemplo n.º 1
0
        static public string GetDefinesForProject(VCConfiguration vcConfiguration)
        {
            StringBuilder    defines = new StringBuilder();
            VCCLCompilerTool vcCTool = GetVCCLCompilerToolForProject(vcConfiguration);

            if (String.IsNullOrEmpty(vcCTool.PreprocessorDefinitions) == false)
            {
                ts.TraceInformation("GetDefinesForProject: PreprocessorDefinitions\n" + vcCTool.PreprocessorDefinitions);
                defines.Append(BuildDefines(vcCTool.PreprocessorDefinitions));
            }

            switch (vcCTool.RuntimeLibrary)
            {
            case runtimeLibraryOption.rtMultiThreaded:
                defines.Append("-D_MT ");
                break;

            case runtimeLibraryOption.rtMultiThreadedDebug:
                defines.Append("-D_MT -D_DEBUG ");
                break;

            case runtimeLibraryOption.rtMultiThreadedDLL:
                defines.Append("-D_MT -D_DLL ");
                break;

            case runtimeLibraryOption.rtMultiThreadedDebugDLL:
                defines.Append("-D_MT -D_DLL -D_DEBUG ");
                break;
            }

            ts.TraceInformation("GetDefinesForProject:  " + defines.ToString());
            return(defines.ToString());
        }
Ejemplo n.º 2
0
        static public string GetIncludesForProject(VCConfiguration vcConfiguration)
        {
            StringBuilder    includes = new StringBuilder();
            VCCLCompilerTool vcCTool  = GetVCCLCompilerToolForProject(vcConfiguration);

            if (String.IsNullOrEmpty(vcCTool.FullIncludePath) == false)
            {
                ts.TraceInformation("GetIncludesForProject: FullIncludePath\n" + vcCTool.FullIncludePath);
                includes.Append(BuildIncludes(vcCTool.FullIncludePath, "-I"));
            }

            if (String.IsNullOrEmpty(vcCTool.AdditionalIncludeDirectories) == false)
            {
                ts.TraceInformation("GetIncludesForProject: AdditionalIncludeDirectories\n" + vcCTool.AdditionalIncludeDirectories);
                includes.Append(BuildIncludes(vcConfiguration.Evaluate(vcCTool.AdditionalIncludeDirectories), "-I"));
            }

            if (String.IsNullOrEmpty(vcCTool.ForcedIncludeFiles) == false)
            {
                ts.TraceInformation("GetIncludesForProject: ForcedIncludeFiles\n" + vcCTool.ForcedIncludeFiles);
                //TODO HEEM
                includes.Append(BuildIncludes(vcCTool.ForcedIncludeFiles, "-include"));
            }

            ts.TraceInformation("GetIncludesForProject: \n" + includes.ToString());

            return(includes.ToString());
        }
Ejemplo n.º 3
0
        public void Compile(VCFile file)
        {
            VCConfiguration     configuration     = file.project.ActiveConfiguration;
            VCFileConfiguration fileConfiguration = file.GetFileConfigurationForProjectConfiguration(configuration);

            string toolchainConfDirs = configuration.Platform.ExecutableDirectories;

            toolchainConfDirs = configuration.Evaluate(toolchainConfDirs);

            string[] toolchainDirs = toolchainConfDirs.Split(ConfigurationSeparators,
                                                             StringSplitOptions.RemoveEmptyEntries);

            VCCLCompilerTool cl = fileConfiguration.Tool;

            foreach (string dir in toolchainDirs)
            {
                string compilerPath = Path.Combine(dir, cl.ToolPath);
                if (File.Exists(compilerPath))
                {
                    EnsureAsmDirectoryExists(configuration);

                    string compilerQuotedPath = CLCommandLineBuilder.SurroundWithQuotes(compilerPath);
                    string filePath           = CLCommandLineBuilder.SurroundWithQuotes(file.FullPath);
                    string args = ComposeCommandLine(file, cl);
                    Compile(compilerQuotedPath, args + " " + filePath, file);
                    return;
                }
            }

            OnMissingCompiler();
        }
        private LibraryConfigState.State ModifyIncludePath(VCCLCompilerTool compiler, string include_path, string project_path, string libpack_path, bool check_only = false)
        {
            if (include_path == null)
            {
                return(LibraryConfigState.State.Empty);
            }

            var full_include_path = GetAbsolutePath(include_path, libpack_path);
            var includes          = new List <string>(SplitQuoted(";", compiler.AdditionalIncludeDirectories));
            var include_found     = false;

            foreach (string project_include in includes)
            {
                string full_project_include = GetAbsolutePath(project_include, project_path);
                if (full_project_include.Equals(full_include_path, StringComparison.OrdinalIgnoreCase))
                {
                    include_found = true;
                    break;
                }
            }

            if (!check_only & !include_found)
            {
                includes.Add(full_include_path);
                compiler.AdditionalIncludeDirectories = String.Join(";", includes.ToArray());
            }

            return(include_found ? LibraryConfigState.State.All : LibraryConfigState.State.None);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Traverses the necessary Visual Studio structures to retrieve any and all
        /// C++ Preprocessor definitions currently defined.
        /// </summary>
        /// <returns></returns>
        private Defines GetPreprocessorDefines()
        {
            Defines definesHandler = new Defines();

            RegisterAnsiCompliantPredefinedMacros(definesHandler);

            // Extract defines from property sheets
            foreach (VCPropertySheet sheet in this.PropertySheets)
            {
                VCCLCompilerTool tool = GetVCppCompilerOptions(sheet.Tools);
                if (tool != null)
                {
                    GetPreprocessorDefines(tool, definesHandler);
                }
            }

            // Avoid registering the Microsoft defines if the /u option is specified
            if (!this._compiler.UndefineAllPreprocessorDefinitions)
            {
                RegisterMicrosoftPreDefinedCompilerMacros(definesHandler);
            }

            // Extract defines from compiler options
            GetPreprocessorDefines(this._compiler, definesHandler);

            return(definesHandler);
        }
Ejemplo n.º 6
0
        static private VCCLCompilerTool GetVCCLCompilerToolForProject(VCConfiguration vcConfiguration)
        {
            IVCCollection    fTools  = (IVCCollection)vcConfiguration.Tools;
            VCCLCompilerTool vcCTool = (VCCLCompilerTool)fTools.Item("VCCLCompilerTool");

            return(vcCTool);
        }
Ejemplo n.º 7
0
        private string FindCslibConfig(ref VCCLCompilerTool compilerTool)
        {
            if (compilerTool != null)
            {
                switch (compilerTool.RuntimeLibrary)
                {
                case runtimeLibraryOption.rtMultiThreaded:
                    return("/MT");

                case runtimeLibraryOption.rtMultiThreadedDebug:
                    return("/MTd");

                case runtimeLibraryOption.rtMultiThreadedDebugDLL:
                    return("/MDd");

                case runtimeLibraryOption.rtMultiThreadedDLL:
                    return("/MD");
                }
                return(null);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
        public void LoadCpps()
        {
            this.Cpps = new Dictionary <string, Cpp>();

            string config = Connect.GetActiveConfigString(this.Project);

            VCFilter unityfilter = this.Filter.GetVCFilter();

            foreach (VCFile file in this.VCProject.Files as IVCCollection)
            {
                if (file.Extension.ToLower() == ".cpp" && file.Parent != unityfilter)
                {
                    VCFileConfiguration cfg    = Connect.GetFileConfiguration(file, config);
                    VCCLCompilerTool    vctool = cfg.Tool as VCCLCompilerTool;
                    if (vctool != null)
                    {
                        if (vctool.UsePrecompiledHeader == Microsoft.VisualStudio.VCProjectEngine.pchOption.pchCreateUsingSpecific)
                        {
                            continue;
                        }
                    }

                    Cpp cpp = this.GetCppInUnity(file.RelativePath);
                    if (cpp == null)
                    {
                        cpp = new Cpp(file);
                    }
                    this.Cpps.Add(cpp.Name, cpp);
                }
            }
        }
Ejemplo n.º 9
0
        VCCLCompilerToolWrapperVs2019
#endif
            (object wrapped)
        {
            _wrapped      = wrapped as VCCLCompilerTool;
            _wrappedRules = wrapped as IVCRulePropertyStorage;
        }
Ejemplo n.º 10
0
        public bool?GetCompilerSetting_ShowIncludes(Project project, out string reasonForFailure)
        {
            VCCLCompilerTool compilerTool = GetCompilerTool(project, out reasonForFailure);

            return(compilerTool.AdditionalOptions.Contains("-d1reportTime"));
            //return compilerTool?.ShowIncludes;
        }
Ejemplo n.º 11
0
        public static VCCLCompilerTool GetCompilerTool(Project project, out string reasonForFailure)
        {
            VCProject vcProject = project?.Object as VCProject;

            if (vcProject == null)
            {
                reasonForFailure = "Failed to retrieve VCCLCompilerTool since project is not a VCProject.";
                return(null);
            }
            VCConfiguration  activeConfiguration = vcProject.ActiveConfiguration;
            var              tools        = activeConfiguration.Tools;
            VCCLCompilerTool compilerTool = null;

            foreach (var tool in activeConfiguration.Tools)
            {
                compilerTool = tool as VCCLCompilerTool;
                if (compilerTool != null)
                {
                    break;
                }
            }

            if (compilerTool == null)
            {
                reasonForFailure = "Couldn't file a VCCLCompilerTool in VC++ Project.";
                return(null);
            }

            reasonForFailure = "";
            return(compilerTool);
        }
Ejemplo n.º 12
0
        public static VCCLCompilerTool GetCompilerTool(Solution2 solution, string projectName, string buildConfig)
        {
            VCProject        fsgdGameProject = solution.Projects.Item(solution).Object as VCProject;
            VCConfiguration  debug32         = fsgdGameProject.Configurations.Item(buildConfig) as VCConfiguration;
            VCCLCompilerTool tool            = debug32.Tools.Item("VCCLCompilerTool");

            return(tool);
        }
Ejemplo n.º 13
0
        public void SetCompilerSetting_ShowIncludes(Project project, bool show, out string reasonForFailure)
        {
            VCCLCompilerTool compilerTool = GetToolFromActiveConfiguration <VCCLCompilerTool>(project, out reasonForFailure);

            if (compilerTool != null)
            {
                compilerTool.ShowIncludes = show;
            }
        }
Ejemplo n.º 14
0
        public void SetCompilerSetting_ShowIncludes(Project project, bool show, out string reasonForFailure)
        {
            VCCLCompilerTool compilerTool = GetCompilerTool(project, out reasonForFailure);

            if (compilerTool != null)
            {
                compilerTool.ShowIncludes = show;
            }
        }
 public CompilerToolWrapper(VCFileConfiguration config)
 {
     compilerTool = config.Tool as VCCLCompilerTool;
     if (compilerTool == null)
     {
         compilerObj  = config.Tool;
         compilerType = compilerObj.GetType();
     }
 }
 public CompilerToolWrapper(VCPropertySheet sheet)
 {
     compilerTool = ((IVCCollection)sheet.Tools).Item("VCCLCompilerTool") as VCCLCompilerTool;
     if (compilerTool == null)
     {
         compilerObj  = ((IVCCollection)sheet.Tools).Item("VCCLCompilerTool");
         compilerType = compilerObj.GetType();
     }
 }
 public CompilerToolWrapper(VCConfiguration config)
 {
     compilerTool = ((IVCCollection)config.Tools).Item("VCCLCompilerTool") as VCCLCompilerTool;
     if (compilerTool == null)
     {
         compilerObj  = ((IVCCollection)config.Tools).Item("VCCLCompilerTool");
         compilerType = compilerObj.GetType();
     }
 }
Ejemplo n.º 18
0
 public CompilerToolWrapper(VCFileConfiguration config)
 {
     compilerTool = config.Tool as VCCLCompilerTool;
     if (compilerTool == null)
     {
         compilerObj = config.Tool;
         compilerType = compilerObj.GetType();
     }
 }
Ejemplo n.º 19
0
 public CompilerToolWrapper(VCConfiguration config)
 {
     compilerTool = ((IVCCollection)config.Tools).Item("VCCLCompilerTool") as VCCLCompilerTool;
     if (compilerTool == null)
     {
         compilerObj = ((IVCCollection)config.Tools).Item("VCCLCompilerTool");
         compilerType = compilerObj.GetType();
     }
 }
Ejemplo n.º 20
0
        public static void SetAdditionalHeadersDirectories(this VCCLCompilerTool tool, List <string> value)
        {
            var newDirectories = PathUtilities.JoinPatches(value, ";");

            if (!string.Equals(newDirectories, tool.AdditionalIncludeDirectories,
                               StringComparison.OrdinalIgnoreCase))
            {
                tool.AdditionalIncludeDirectories = newDirectories;
            }
        }
Ejemplo n.º 21
0
        public void SetCompilerSetting_ShowIncludes(Project project, bool show, out string reasonForFailure)
        {
            VCCLCompilerTool compilerTool = GetCompilerTool(project, out reasonForFailure);

            if (compilerTool != null)
            {
                //compilerTool.ShowIncludes = show;
                compilerTool.AdditionalOptions = "-d1reportTime";
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Finds compiler settings, such as the include path, for the configuration
        /// passed in.
        /// </summary>
        private void parseConfiguration_CompilerSettings(VCConfiguration vcConfiguration, ProjectConfigurationInfo_CPP configurationInfo)
        {
            // We get the compiler-settings 'tool'...
            IVCCollection    tools        = Utils.call(() => (vcConfiguration.Tools as IVCCollection));
            VCCLCompilerTool compilerTool = Utils.call(() => (tools.Item("VCCLCompilerTool") as VCCLCompilerTool));

            // And extract various details from it...
            parseCompilerSettings_IncludePath(vcConfiguration, compilerTool, configurationInfo);
            parseCompilerSettings_PreprocessorDefinitions(vcConfiguration, compilerTool, configurationInfo);
            parseCompilerSettings_CompilerFlags(vcConfiguration, compilerTool, configurationInfo);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Parses the configuration (e.g. Debug, Release) passed in.
        /// </summary>
        private void parseConfiguration(VCConfiguration vcConfiguration)
        {
            ProjectConfigurationInfo_CPP configurationInfo = new ProjectConfigurationInfo_CPP();

            configurationInfo.ParentProjectInfo = m_projectInfo;

            IVCCollection sheets    = Utils.call(() => (vcConfiguration.PropertySheets as IVCCollection));
            int           numSheets = Utils.call(() => (sheets.Count));

            for (int i = 1; i <= numSheets; ++i)
            {
                VCPropertySheet sheet = Utils.call(() => (sheets.Item(i) as VCPropertySheet));

                // 1. The thing is that VCPropertySheet and VCConfiguration have more-or-less
                //    identical interfaces. So we should be able to merge them fairly easily.
                //
                // 2. We should try multiple layers of inheritance

                IVCCollection    tools        = Utils.call(() => (sheet.Tools as IVCCollection));
                VCCLCompilerTool compilerTool = Utils.call(() => (tools.Item("VCCLCompilerTool") as VCCLCompilerTool));
            }

            // The configuration name...
            configurationInfo.Name = Utils.call(() => (vcConfiguration.ConfigurationName));

            // The project type.
            // Note: we are assuming that all the configurations for the project build the
            //       same type of target.
            m_projectInfo.ProjectType = parseConfiguration_Type(vcConfiguration);

            // We get the intermediates folder and output folder...
            configurationInfo.IntermediateFolder = parseConfiguration_Folder(vcConfiguration, () => (vcConfiguration.IntermediateDirectory));
            configurationInfo.OutputFolder       = parseConfiguration_Folder(vcConfiguration, () => (vcConfiguration.OutputDirectory));

            // We get compiler settings, such as the include path and
            // preprocessor definitions...
            parseConfiguration_CompilerSettings(vcConfiguration, configurationInfo);

            // We get linker settings, such as any libs to link and the library path...
            parseConfiguration_LinkerSettings(vcConfiguration, configurationInfo);

            // We parse librarian settings (how libraries are linked)...
            parseConfiguration_LibrarianSettings(vcConfiguration, configurationInfo);

            // We see if there are any pre- or post- build events set up for this
            // configuration. The only types of events we know how to deal with are
            // ones that invoke a .cmd file. For these we convert them to invoke
            // a .sh file with the same name.
            parseConfiguration_PreBuildEvent(vcConfiguration, configurationInfo);
            parseConfiguration_PostBuildEvent(vcConfiguration, configurationInfo);

            // We add the configuration to the collection of them for the project...
            m_projectInfo.addConfigurationInfo(configurationInfo);
        }
Ejemplo n.º 24
0
        protected CompilerToolWrapper(object tool)
        {
            if (tool == null)
                return;

            compilerTool = tool as VCCLCompilerTool;
            if (compilerTool == null)
            {
                compilerObj = tool;
                compilerType = compilerObj.GetType();
            }
        }
Ejemplo n.º 25
0
        private bool appendToAdditionalDirectories(ref VCCLCompilerTool compilerTool, string directoryToAppend)
        {
            if (directoryToAppend.Length == 0)
            {
                directoryToAppend = ".";
            }
            string compilerAdditionalInclude;

            if (compilerTool.AdditionalIncludeDirectories == null)
            {
                compilerAdditionalInclude = "";
            }
            else
            {
                compilerAdditionalInclude = compilerTool.AdditionalIncludeDirectories;
            }

            string newCompilerAdditionalInclude = compilerAdditionalInclude;

            string[] addinc_array = compilerAdditionalInclude.Split(',');
            bool     found        = false;

            foreach (string s in addinc_array)
            {
                if (s == directoryToAppend)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                if (newCompilerAdditionalInclude.Length == 0)
                {
                    newCompilerAdditionalInclude = directoryToAppend;
                }
                else
                {
                    newCompilerAdditionalInclude += ",";
                    newCompilerAdditionalInclude += directoryToAppend;
                }
            }

            if (newCompilerAdditionalInclude != compilerAdditionalInclude)
            {
                compilerTool.AdditionalIncludeDirectories = newCompilerAdditionalInclude;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 26
0
        static public string GetDefinesForFile(VCFileConfiguration vcFileConfiguration)
        {
            StringBuilder    defines = new StringBuilder();
            VCCLCompilerTool vcCTool = (VCCLCompilerTool)vcFileConfiguration.Tool;

            if (String.IsNullOrEmpty(vcCTool.PreprocessorDefinitions) == false)
            {
                ts.TraceInformation("GetDefinesForFile: PreprocessorDefinitions\n" + vcCTool.PreprocessorDefinitions);
                defines.Append(BuildDefines(vcCTool.PreprocessorDefinitions));
            }

            ts.TraceInformation("GetDefinesForFile PreprocessorDefinitions:\n" + vcCTool.PreprocessorDefinitions);
            return(defines.ToString());
        }
Ejemplo n.º 27
0
        protected CompilerToolWrapper(object tool)
        {
            if (tool == null)
            {
                return;
            }

            compilerTool = tool as VCCLCompilerTool;
            if (compilerTool == null)
            {
                compilerObj  = tool;
                compilerType = compilerObj.GetType();
            }
        }
Ejemplo n.º 28
0
        public string GetCompilerSetting_PreprocessorDefinitions(Project project, out string reasonForFailure)
        {
            VCCLCompilerTool compilerTool = GetCompilerTool(project, out reasonForFailure);
            var defines = compilerTool?.PreprocessorDefinitions;

            //string reason2 = string.Empty;
            //VCConfiguration projectConfiguration = GetConfigurationTool(project, out reason2);
            //reasonForFailure += reason2;

            //if (projectConfiguration.CharacterSet == charSet.charSetUnicode)
            //{
            defines += ";_UNICODE";
            //}
            return(defines);
        }
Ejemplo n.º 29
0
 private void DisableClConfig(ref VCCLCompilerTool compilerTool, string config)
 {
     if (compilerTool != null)
     {
         Log("\tCompiler Configuration");
         if (compilerTool.AdditionalOptions != null)
         {
             string newargs = DisableCodeCoverageCommandLineArguments(compilerTool.AdditionalOptions);
             if (compilerTool.AdditionalOptions != newargs)
             {
                 compilerTool.AdditionalOptions = newargs;
                 Log("\t\tAdditional command line arguments set to '" + newargs + "'");
             }
         }
     }
 }
Ejemplo n.º 30
0
        private string[] GetIncludeDirectoriesFromProject(EnvDTE.Project project)
        {
            List <string> includeDirectories = new List <string>();
            VCProject     vcproject          = (VCProject)project.Object;

            IVCCollection configurationsCollection = (IVCCollection)vcproject.Configurations;

            Configuration dteActiveConfiguration = project.ConfigurationManager.ActiveConfiguration;

            VCConfiguration vcActiveConfiguration = null;

            foreach (VCConfiguration configuration in configurationsCollection)
            {
                if (configuration.ConfigurationName == dteActiveConfiguration.ConfigurationName && configuration.Platform.Name == dteActiveConfiguration.PlatformName)
                {
                    vcActiveConfiguration = configuration;
                    break;
                }
            }

            IVCCollection toolsCollection = (IVCCollection)vcActiveConfiguration.Tools;

            foreach (Object toolObject in toolsCollection)
            {
                if (toolObject is VCCLCompilerTool)
                {
                    VCCLCompilerTool compilerTool = (VCCLCompilerTool)toolObject;
                    string           additionalIncludeDirectories = compilerTool.AdditionalIncludeDirectories;
                    includeDirectories.AddRange(additionalIncludeDirectories.Split(';'));
                    break;
                }
            }

            includeDirectories.AddRange(AdditionalIncludeDirectoriesFromAllPropertySheets(vcActiveConfiguration.PropertySheets));

            List <string> evaluatedIncludeDirectories = new List <string>();

            foreach (string includeDirectory in includeDirectories)
            {
                string evaluatedIncludeDirectory = vcActiveConfiguration.Evaluate(includeDirectory);
                if (evaluatedIncludeDirectory != "")
                {
                    evaluatedIncludeDirectories.Add(evaluatedIncludeDirectory);
                }
            }
            return(evaluatedIncludeDirectories.ToArray());
        }
Ejemplo n.º 31
0
        public void SaveUnities()
        {
            try
            {
                VCFilter unityfilter = this.Filter.GetVCFilter();
                if (unityfilter == null)
                {
                    unityfilter = this.VCProject.AddFilter(this.Filter.Name) as VCFilter;
                }

                List <VCFile> oldfiles = new List <VCFile>();
                foreach (VCFile file in unityfilter.Files as IVCCollection)
                {
                    oldfiles.Add(file);
                }
                foreach (VCFile file in oldfiles)
                {
                    file.Remove();
                }

                IVCCollection    tools  = this.VCConfig.Tools as IVCCollection;
                VCCLCompilerTool vctool = tools.Item("VCCLCompilerTool") as VCCLCompilerTool;

                string pch = Connect.GetPCH(this.VCProject, this.VCConfig);

                foreach (Unity unity in this.Unities.Values)
                {
                    unity.Save(this.VCProject.ProjectDirectory, this.Filter.Path, pch);

                    VCFile file = unityfilter.AddFile(unity.FileName) as VCFile;

                    foreach (VCFileConfiguration fileconfig in file.FileConfigurations as IVCCollection)
                    {
                        vctool = fileconfig.Tool as VCCLCompilerTool;
                        if (vctool != null)
                        {
                            vctool.AdditionalIncludeDirectories = "\"$(ProjectDir)/\"";
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                Utils.ShowError("SaveUnities failed: " + ex.Message);
            }
        }
Ejemplo n.º 32
0
        private void AppendProjectProperties(ProjectProperties properties, VCCLCompilerTool cl, VCNMakeTool nmake, IMacroEvaluator evaluator)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (cl != null)
            {
                AppendMSBuildStringToList(properties.IncludeDirectories, evaluator.Evaluate(cl.AdditionalIncludeDirectories));
                AppendMSBuildStringToList(properties.ForceIncludes, evaluator.Evaluate(cl.ForcedIncludeFiles));
                AppendMSBuildStringToList(properties.PrepocessorDefinitions, evaluator.Evaluate(cl.PreprocessorDefinitions));
            }
            else if (nmake != null)
            {
                AppendMSBuildStringToList(properties.IncludeDirectories, evaluator.Evaluate(nmake.IncludeSearchPath));
                AppendMSBuildStringToList(properties.ForceIncludes, evaluator.Evaluate(nmake.ForcedIncludes));
                AppendMSBuildStringToList(properties.PrepocessorDefinitions, evaluator.Evaluate(nmake.PreprocessorDefinitions));
            }
        }
Ejemplo n.º 33
0
        public void DisableTestCocoonConfig(String config, string project)
        {
            bool foundProject = false;

            IEnumerator e = GetVCProjectRefs();

            e.Reset();
            // traverse all projects to find the right one
            while (e.MoveNext())
            {
                VCProject actVCP = (VCProject)e.Current;
                if (actVCP.Name == project)
                {
                    foundProject = true;
                    VCConfiguration vcC;
                    vcC = (VCConfiguration)(((IVCCollection)actVCP.Configurations).Item(config));
                    if (vcC != null)
                    {
                        Log("Modifying configuration '" + config + "' for the project '" + project + "'");

                        // change settings for sepcified compiler
                        IVCCollection ctools = (IVCCollection)vcC.Tools;

                        VCLinkerTool      linkerTool      = (VCLinkerTool)(ctools.Item("VCLinkerTool"));
                        VCLibrarianTool   librarianTool   = (VCLibrarianTool)(ctools.Item("VCLibrarianTool"));
                        VCCLCompilerTool  compilerTool    = (VCCLCompilerTool)(ctools.Item("VCCLCompilerTool"));
                        VCCustomBuildTool customBuildTool = (VCCustomBuildTool)(ctools.Item("VCCustomBuildTool"));

                        DisableClConfig(ref compilerTool, config);
                        DisableLinkConfig(ref linkerTool, config);
                        DisableCustomBuildConfig(ref customBuildTool, config);
                        DisableLibrarianConfig(ref librarianTool, config);
                        DisableConfigForEachFile(ref actVCP, config);
                    }
                    else
                    {
                        Log("Skipping configuration '" + config + "' for the project '" + project + "'");
                    }
                }
            }
            if (!foundProject)
            {
                ShowMessageBox("Could not find the project", "Warning");
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Finds compiler flags.
        /// </summary>
        private void parseCompilerSettings_CompilerFlags(VCConfiguration vcConfiguration, VCCLCompilerTool compilerTool, ProjectConfigurationInfo_CPP configurationInfo)
        {
            // Warning level...
            warningLevelOption warningLevel = Utils.call(() => (compilerTool.WarningLevel));
            switch (warningLevel)
            {
                case warningLevelOption.warningLevel_0:
                    configurationInfo.addCompilerFlag("-w");
                    break;

                case warningLevelOption.warningLevel_4:
                    configurationInfo.addCompilerFlag("-Wall");
                    break;
            }

            // Warnings as errors...
            bool warningsAsErrors = Utils.call(() => (compilerTool.WarnAsError));
            if (warningsAsErrors == true)
            {
                configurationInfo.addCompilerFlag("-Werror");
            }

            // Optimization...
            optimizeOption optimization = Utils.call(() => (compilerTool.Optimization));
            switch (optimization)
            {
                case optimizeOption.optimizeDisabled:
                    configurationInfo.addCompilerFlag("-O0");
                    break;

                case optimizeOption.optimizeMinSpace:
                    configurationInfo.addCompilerFlag("-Os");
                    break;

                case optimizeOption.optimizeMaxSpeed:
                    configurationInfo.addCompilerFlag("-O2");
                    break;

                case optimizeOption.optimizeFull:
                    configurationInfo.addCompilerFlag("-O3");
                    break;
            }
        }
        /// <summary>
        /// Populates the provided definesHandler with the preprocessor defines available within the compiler argument
        /// </summary>
        /// <param name="compiler">The base Visual Studio C++ compiler configuration</param>
        /// <param name="definesHandler">The target structure which will host the extracted preprocessor definitions</param>
        private static void GetPreprocessorDefines(VCCLCompilerTool compiler, Defines definesHandler)
        {
            string definitions = compiler.PreprocessorDefinitions.Trim();
            string undefinitions = compiler.UndefinePreprocessorDefinitions.Trim();

            if (definitions.Length > 0)
            {
                string[] preProcessorDefinesArray = definitions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string preProcessorDefine in preProcessorDefinesArray)
                {
                    // the below code is to support valued defines as per https://msdn.microsoft.com/en-us/library/vstudio/hhzbb5c8%28v=vs.100%29.aspx

                    Match matchResult = RegexPreProcesserDefines.Match(preProcessorDefine);

                    if (matchResult.Success)
                    {
                        definesHandler.Define(matchResult.Groups[1].Value.Trim(), matchResult.Groups[2].Value);
                    }
                    else
                    {
                        if (!preProcessorDefine.Contains("$(INHERIT)"))
                        {
                            definesHandler.Define(preProcessorDefine.Trim(), "1");
                            //by default user assigned pre-processor defines have a value of 1
                        }
                    }
                }
            }

            if (undefinitions.Length > 0)
            {
                string[] preProcessorUnDefinesArray = undefinitions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var preProcessorUnDefine in preProcessorUnDefinesArray)
                {
                    if (!preProcessorUnDefine.Contains("$(NOINHERIT)"))
                    {
                        definesHandler.UnDefine(preProcessorUnDefine.Trim());
                    }
                }
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="configuration">The Visual Studio Configuration parent of the compiler options</param>
 /// <param name="compiler">The Visual Studio compiler tool which is to be adapted</param>
 public VCppCompilerOptions(VCConfiguration configuration, VCCLCompilerTool compiler)
 {
     this._configuration = configuration;
     this._compiler = compiler;
 }
Ejemplo n.º 37
0
        private bool appendToAdditionalDirectories(ref VCCLCompilerTool compilerTool, string directoryToAppend)
        {
            if (directoryToAppend.Length == 0)
            directoryToAppend = ".";
              string compilerAdditionalInclude;
              if (compilerTool.AdditionalIncludeDirectories == null)
            compilerAdditionalInclude = "";
              else
            compilerAdditionalInclude = compilerTool.AdditionalIncludeDirectories;

              string newCompilerAdditionalInclude = compilerAdditionalInclude;
              string[] addinc_array = compilerAdditionalInclude.Split(',');
              bool found = false;
              foreach (string s in addinc_array)
              {
            if (s == directoryToAppend)
            {
              found = true;
              break;
            }
              }
              if (!found)
              {
            if (newCompilerAdditionalInclude.Length == 0)
              newCompilerAdditionalInclude = directoryToAppend;
            else
            {
              newCompilerAdditionalInclude += ",";
              newCompilerAdditionalInclude += directoryToAppend;
            }
              }

              if (newCompilerAdditionalInclude != compilerAdditionalInclude)
              {
            compilerTool.AdditionalIncludeDirectories = newCompilerAdditionalInclude;
            return true;
              }
              return false;
        }
Ejemplo n.º 38
0
        private void CreateClConfig(ref VCCLCompilerTool compilerTool, List<string> additionalParamsList, List<string> additionalIncludeDirectories, string project_directory, string config)
        {
            if (compilerTool != null)
              {
            List<string> _additionalParamsList = new List<string>(additionalParamsList);
            Log("\tCompiler Configuration");
            if (compilerTool.UsePrecompiledHeader != pchOption.pchNone)
            {
              compilerTool.UsePrecompiledHeader = pchOption.pchNone;
              Log("\t\tUsage of precompiled headers are deactivated");
              if (compilerTool.PrecompiledHeaderThrough != null)
              {
            try
            {
              string directoryToAppend = System.IO.Path.GetDirectoryName(compilerTool.PrecompiledHeaderThrough);
              if (appendToAdditionalDirectories(ref compilerTool, directoryToAppend))
                Log("\t\tAdditional of '" + directoryToAppend + "'a in the list of additional include directories");
            }
            catch (Exception e)
            {
              Debug(e);
            }
              }
            }

            if (additionalIncludeDirectories != null && compilerTool.FullIncludePath != null)
            {
              string addinc = compilerTool.FullIncludePath;
              string[] addinc_array = addinc.Split(';');
              List<string> addinc_list = new List<string>();
              foreach (string s in addinc_array)
              {
            string ss = s.Replace("\"", "");
            addinc_list.Add(ss);
              }

              foreach (string path in additionalIncludeDirectories)
              {
            try
            {
              string path_abs = System.IO.Path.GetFullPath(path).ToLower();
              foreach (string addinc_rel in addinc_list)
              {
                try
                {
                  string addinc_abs = System.IO.Path.GetFullPath(addinc_rel).ToLower();
                  string addinc_ver = addinc_rel.ToLower();
                  if (addinc_abs != addinc_rel.ToLower())
                  {
                    try
                    {
                      addinc_abs = System.IO.Path.GetFullPath(project_directory + "\\" + addinc_rel).ToLower();
                    }
                    catch (Exception e)
                    {
                      Debug(e);
                    }
                  }
                  if (addinc_abs == path_abs)
                  {
                    _additionalParamsList.Add("--cs-include-path=\"" + addinc_rel + "\"");
                    break;
                  }
                }
                catch (Exception e)
                {
                  Debug(e);
                }
              }
            }
            catch (Exception e)
            {
              Debug(e);
            }
              }
            }

            if (compilerTool.AdditionalOptions == null)
              compilerTool.AdditionalOptions = " ";
            string additionalParams = generateParamString(_additionalParamsList, compilerTool.AdditionalOptions);
            if (additionalParams.Length > 0)
            {
              compilerTool.AdditionalOptions += " " + additionalParams;
              Log("\t\tAdditional command line arguments '" + additionalParams + "' are appended");
            }
              }
        }
Ejemplo n.º 39
0
 private void DisableClConfig(ref VCCLCompilerTool compilerTool, string config)
 {
     if (compilerTool != null)
       {
     Log("\tCompiler Configuration");
     if (compilerTool.AdditionalOptions != null)
     {
       string newargs = DisableCodeCoverageCommandLineArguments(compilerTool.AdditionalOptions);
       if (compilerTool.AdditionalOptions != newargs)
       {
     compilerTool.AdditionalOptions = newargs;
     Log("\t\tAdditional command line arguments set to '" + newargs + "'");
       }
     }
       }
 }
Ejemplo n.º 40
0
 private string FindCslibConfig(ref VCCLCompilerTool compilerTool)
 {
     if (compilerTool != null)
       {
     switch (compilerTool.RuntimeLibrary)
     {
       case runtimeLibraryOption.rtMultiThreaded:
     return "/MT";
       case runtimeLibraryOption.rtMultiThreadedDebug:
     return "/MTd";
       case runtimeLibraryOption.rtMultiThreadedDebugDLL:
     return "/MDd";
       case runtimeLibraryOption.rtMultiThreadedDLL:
     return "/MD";
     }
     return null;
       }
       else
     return null;
 }
Ejemplo n.º 41
0
        private void Initialize( EnvDTE.Project prj )
        {
            project = (VCProject)prj.Object;
            configurations = (IVCCollection)project.Configurations;

            EnvDTE.ConfigurationManager configManager = prj.ConfigurationManager;
            EnvDTE.Configuration activeConfig = configManager.ActiveConfiguration;
            string activeConfigNamePlatform = activeConfig.ConfigurationName + "|" + activeConfig.PlatformName;

            foreach (VCConfiguration c in project.Configurations)
            {
                if (c.Name == activeConfigNamePlatform)
                {
                    config = c;
                    break;
                }
            }
            Debug.Assert(config != null);
            if (config == null)
                throw new InvalidOperationException("The specified file does not have a configuration corresponding to the current active configuration.");

            //config = (VCConfiguration)configurations.Item(1);
            tools = (IVCCollection)config.Tools;
            cltool = (VCCLCompilerTool)tools.Item("VCCLCompilerTool");
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Finds the collection of include paths for the configuration passed in.
        /// </summary>
        private void parseCompilerSettings_IncludePath(VCConfiguration vcConfiguration, VCCLCompilerTool compilerTool, ProjectConfigurationInfo_CPP configurationInfo)
        {
            // We:
            // 1. Read the additional include paths (which are in a semi-colon-delimited string)
            // 2. Split it into separate paths
            // 3. Resolve any symbols
            // 4. Make sure all paths are relative to the project root folder

            // 1 & 2...
            string strAdditionalIncludeDirectories = Utils.call(() => (compilerTool.AdditionalIncludeDirectories));
            if (strAdditionalIncludeDirectories == null)
            {
                return;
            }

            List<string> additionalIncludeDirectories = Utils.split(strAdditionalIncludeDirectories, ';', ',');
            foreach (string additionalIncludeDirectory in additionalIncludeDirectories)
            {
                // The string may be quoted. We need to remove the quotes...
                string unquotedIncludeDirectory = additionalIncludeDirectory.Trim('"');

                // 3 & 4...
                string resolvedPath = Utils.call(() => (vcConfiguration.Evaluate(unquotedIncludeDirectory)));
                if (resolvedPath != "")
                {
                    string relativePath = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, resolvedPath);
                    configurationInfo.addIncludePath(relativePath);
                }
            }
        }
Ejemplo n.º 43
0
        /// <summary>
        /// Finds the collection of preprocessor definitions for the configuration passed in.
        /// </summary>
        private void parseCompilerSettings_PreprocessorDefinitions(VCConfiguration vcConfiguration, VCCLCompilerTool compilerTool, ProjectConfigurationInfo_CPP configurationInfo)
        {
            // We read the delimited string of preprocessor definitions, and
            // split them...
            string strPreprocessorDefinitions = Utils.call(() => (compilerTool.PreprocessorDefinitions));
            if (strPreprocessorDefinitions == null)
            {
                return;
            }
            List<string> preprocessorDefinitions = Utils.split(strPreprocessorDefinitions, ';');

            // We add the definitions to the parsed configuration (removing ones that
            // aren't relevant to a linux build)...
            foreach (string definition in preprocessorDefinitions)
            {
                configurationInfo.addPreprocessorDefinition(definition);
            }
        }
Ejemplo n.º 44
0
 public CompilerToolWrapper(VCPropertySheet sheet)
 {
     compilerTool = ((IVCCollection)sheet.Tools).Item("VCCLCompilerTool") as VCCLCompilerTool;
     if (compilerTool == null)
     {
         compilerObj = ((IVCCollection)sheet.Tools).Item("VCCLCompilerTool");
         compilerType = compilerObj.GetType();
     }
 }