Ejemplo n.º 1
0
        public static bool IsTundraProject(Project project)
        {
            if (project == null)
            {
                return(false);
            }

            Console.Write(project.Name.ToString());

            var vc_proj = project.Object as VCProject;

            if (null == vc_proj || (vc_proj.keyword != "MakefileProj" && vc_proj.keyword != "Win32Proj"))
            {
                return(false);
            }

            var activeConfig = project.ConfigurationManager.ActiveConfiguration;

            if (activeConfig != null)
            {
                var         config    = FindVCConfiguration(vc_proj, activeConfig);
                VCNMakeTool nmakeTool = GetNMakeTool(vc_proj, config);
                if (nmakeTool != null)
                {
                    Match m = TundraBuildRegex.Match(nmakeTool.BuildCommandLine);
                    return(m.Success);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        VCNMakeToolWrapperVs2017
#endif
            (object wrapped)
        {
            _wrapped      = wrapped as VCNMakeTool;
            _wrappedRules = wrapped as IVCRulePropertyStorage;
        }
Ejemplo n.º 3
0
        public string GetCompilerSetting_PreprocessorDefinitions(Project project, out string reasonForFailure)
        {
            VCCLCompilerTool compilerTool = GetToolFromActiveConfiguration <VCCLCompilerTool>(project, out reasonForFailure);

            if (compilerTool != null)
            {
                return(compilerTool?.PreprocessorDefinitions);
            }

            // If querying the NMake tool fails, keep old reason for failure, since this is what we usually expect. Using NMake is seen as mere fallback.
            VCNMakeTool nmakeTool = GetToolFromActiveConfiguration <VCNMakeTool>(project, out var _);

            if (nmakeTool == null)
            {
                return(null);
            }
            reasonForFailure = "";
            return(nmakeTool.IncludeSearchPath);
        }
        public IVCNMakeToolWrapper GetNMakeTool()
        {
            try
            {
                IEnumerable tools = _wrapped.Tools as IEnumerable;

                foreach (Object tool in tools)
                {
                    VCNMakeTool compilerTool = tool as VCNMakeTool;
                    if (compilerTool != null)
                    {
                        return(new
#if (VS2012)
                               VCNMakeToolWrapperVs2012
#elif (VS2013)
                               VCNMakeToolWrapperVs2013
#elif (VS2015)
                               VCNMakeToolWrapperVs2015
#elif (VS2017)
                               VCNMakeToolWrapperVs2017
#endif
                                   (compilerTool));
                    }
                }
            }
            catch (Exception e)
            {
                Logging.LogError("Configuration failed to retreive nmake tool: " + e.Message);
            }
            return(new
#if (VS2012)
                   VCNMakeToolWrapperVs2012
#elif (VS2013)
                   VCNMakeToolWrapperVs2013
#elif (VS2015)
                   VCNMakeToolWrapperVs2015
#elif (VS2017)
                   VCNMakeToolWrapperVs2017
#endif
                       (null));
        }
Ejemplo n.º 5
0
        public string GetCompilerSetting_PreprocessorDefinitions(Project project)
        {
            VCQueryFailure queryFailure;

            try
            {
                VCCLCompilerTool compilerTool = GetToolFromActiveConfiguration <VCCLCompilerTool>(project);
                if (compilerTool != null)
                {
                    return(compilerTool?.PreprocessorDefinitions);
                }
                else
                {
                    queryFailure = new VCQueryFailure("Unhandled error");
                }
            }
            catch (VCQueryFailure e)
            {
                queryFailure = e;
            }

            // If querying the NMake tool fails, keep old reason for failure, since this is what we usually expect. Using NMake is seen as mere fallback.
            try
            {
                VCNMakeTool nmakeTool = GetToolFromActiveConfiguration <VCNMakeTool>(project);
                if (nmakeTool == null)
                {
                    throw queryFailure;
                }

                return(nmakeTool.PreprocessorDefinitions);
            }
            catch
            {
                throw queryFailure;
            }
        }
Ejemplo n.º 6
0
        public void CreateTestCocoonConfig(String config, string project, List <string> additionalParamsList, List <string> additiona_includes, bool QtConfiguration)
        {
            bool foundProject = false;

            IEnumerator ProjectsEnumaror = GetVCProjectRefs();

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

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

                            VCActiveXReference  cVCActiveXReference  = ctools.Item("VCActiveXReference") as VCActiveXReference;
                            VCALinkTool         cVCALinkTool         = ctools.Item("VCALinkTool") as VCALinkTool;
                            VCAppVerifierTool   cVCAppVerifierTool   = ctools.Item("VCAppVerifierTool") as VCAppVerifierTool;
                            VCAssemblyReference cVCAssemblyReference = ctools.Item("VCAssemblyReference") as VCAssemblyReference;
                            VCBscMakeTool       cVCBscMakeTool       = ctools.Item("VCBscMakeTool") as VCBscMakeTool;
                            VCCLCompilerTool    cVCCLCompilerTool    = ctools.Item("VCCLCompilerTool") as VCCLCompilerTool;
                            VCConfiguration     cVCConfiguration     = ctools.Item("VCConfiguration") as VCConfiguration;
                            VCCustomBuildRule   cVCCustomBuildRule   = ctools.Item("VCCustomBuildRule") as VCCustomBuildRule;
                            VCCustomBuildTool   cVCCustomBuildTool   = ctools.Item("VCCustomBuildTool") as VCCustomBuildTool;
                            VCDebugSettings     cVCDebugSettings     = ctools.Item("VCDebugSettings") as VCDebugSettings;
                            VCFile cVCFile = ctools.Item("VCFile") as VCFile;
                            VCFileConfiguration            cVCFileConfiguration            = ctools.Item("VCFileConfiguration") as VCFileConfiguration;
                            VCFilter                       cVCFilter                       = ctools.Item("VCFilter") as VCFilter;
                            VCFxCopTool                    cVCFxCopTool                    = ctools.Item("VCFxCopTool") as VCFxCopTool;
                            VCLibrarianTool                cVCLibrarianTool                = ctools.Item("VCLibrarianTool") as VCLibrarianTool;
                            VCLinkerTool                   cVCLinkerTool                   = ctools.Item("VCLinkerTool") as VCLinkerTool;
                            VCManagedResourceCompilerTool  cVCManagedResourceCompilerTool  = ctools.Item("VCManagedResourceCompilerTool") as VCManagedResourceCompilerTool;
                            VCManifestTool                 cVCManifestTool                 = ctools.Item("VCManifestTool") as VCManifestTool;
                            VCMidlTool                     cVCMidlTool                     = ctools.Item("VCMidlTool") as VCMidlTool;
                            VCNMakeTool                    cVCNMakeTool                    = ctools.Item("VCNMakeTool") as VCNMakeTool;
                            VCPlatform                     cVCPlatform                     = ctools.Item("VCPlatform") as VCPlatform;
                            VCPostBuildEventTool           cVCPostBuildEventTool           = ctools.Item("VCPostBuildEventTool") as VCPostBuildEventTool;
                            VCPreBuildEventTool            cVCPreBuildEventTool            = ctools.Item("VCPreBuildEventTool") as VCPreBuildEventTool;
                            VCPreLinkEventTool             cVCPreLinkEventTool             = ctools.Item("VCPreLinkEventTool") as VCPreLinkEventTool;
                            VCProject                      cVCProject                      = ctools.Item("VCProject") as VCProject;
                            VCProjectEngine                cVCProjectEngine                = ctools.Item("VCProjectEngine") as VCProjectEngine;
                            VCProjectEngineEvents          cVCProjectEngineEvents          = ctools.Item("VCProjectEngineEvents") as VCProjectEngineEvents;
                            VCProjectEngineObject          cVCProjectEngineObject          = ctools.Item("VCProjectEngineObject") as VCProjectEngineObject;
                            VCProjectItem                  cVCProjectItem                  = ctools.Item("VCProjectItem") as VCProjectItem;
                            VCProjectReference             cVCProjectReference             = ctools.Item("VCProjectReference") as VCProjectReference;
                            VCPropertySheet                cVCPropertySheet                = ctools.Item("VCPropertySheet") as VCPropertySheet;
                            VCReference                    cVCReference                    = ctools.Item("VCReference") as VCReference;
                            VCReferences                   cVCReferences                   = ctools.Item("VCReferences") as VCReferences;
                            VCResourceCompilerTool         cVCResourceCompilerTool         = ctools.Item("VCResourceCompilerTool") as VCResourceCompilerTool;
                            VCRuntimeBooleanProperty       cVCRuntimeBooleanProperty       = ctools.Item("VCRuntimeBooleanProperty") as VCRuntimeBooleanProperty;
                            VCRuntimeEnumProperty          cVCRuntimeEnumProperty          = ctools.Item("VCRuntimeEnumProperty") as VCRuntimeEnumProperty;
                            VCRuntimeEnumValue             cVCRuntimeEnumValue             = ctools.Item("VCRuntimeEnumValue") as VCRuntimeEnumValue;
                            VCRuntimeIntegerProperty       cVCRuntimeIntegerProperty       = ctools.Item("VCRuntimeIntegerProperty") as VCRuntimeIntegerProperty;
                            VCRuntimeProperty              cVCRuntimeProperty              = ctools.Item("VCRuntimeProperty") as VCRuntimeProperty;
                            VCRuntimeStringProperty        cVCRuntimeStringProperty        = ctools.Item("VCRuntimeStringProperty") as VCRuntimeStringProperty;
                            VCToolFile                     cVCToolFile                     = ctools.Item("VCToolFile") as VCToolFile;
                            VCUserMacro                    cVCUserMacro                    = ctools.Item("VCUserMacro") as VCUserMacro;
                            VCWebDeploymentTool            cVCWebDeploymentTool            = ctools.Item("VCWebDeploymentTool") as VCWebDeploymentTool;
                            VCWebServiceProxyGeneratorTool cVCWebServiceProxyGeneratorTool = ctools.Item("VCWebServiceProxyGeneratorTool") as VCWebServiceProxyGeneratorTool;
                            VCXDCMakeTool                  cVCXDCMakeTool                  = ctools.Item("VCXDCMakeTool") as VCXDCMakeTool;
                            VCXMLDataGeneratorTool         cVCXMLDataGeneratorTool         = ctools.Item("VCXMLDataGeneratorTool") as VCXMLDataGeneratorTool;

                            VCLinkerTool      linkerTool                    = ctools.Item("VCLinkerTool") as VCLinkerTool;
                            VCLibrarianTool   librarianTool                 = ctools.Item("VCLibrarianTool") as VCLibrarianTool;
                            VCCLCompilerTool  compilerTool                  = ctools.Item("VCCLCompilerTool") as VCCLCompilerTool;
                            VCCustomBuildTool customBuildTool               = ctools.Item("VCCustomBuildTool") as VCCustomBuildTool;
                            string            libgen                        = FindCslibConfig(ref compilerTool);
                            List <string>     additionalParamsListLink      = new List <string>(additionalParamsList);
                            List <string>     additionalParamsListLibrarian = new List <string>(additionalParamsList);
                            if (libgen != null)
                            {
                                additionalParamsListLink.Add("--cs-libgen=" + libgen);
                                additionalParamsListLibrarian.Add("--cs-libgen=" + libgen);
                            }

                            if (compilerTool != null)
                            {
                                CreateClConfig(ref compilerTool, additionalParamsList, additiona_includes, actVCP.ProjectDirectory, config);
                            }
                            if (linkerTool != null)
                            {
                                CreateLinkConfig(ref linkerTool, additionalParamsListLink, config);
                            }
                            if (customBuildTool != null)
                            {
                                CreateCustomBuildConfig(ref customBuildTool, additionalParamsList, config);
                            }
                            if (librarianTool != null)
                            {
                                CreateLibrarianConfig(ref librarianTool, additionalParamsListLibrarian, config);
                            }
                            if (actVCP != null)
                            {
                                CreateConfigForEachFile(ref actVCP, additionalParamsList, config);
                            }
                        }
                    }
                }
            }
            if (!foundProject)
            {
                ShowMessageBox("Could not find the project", "Warning");
            }
        }
Ejemplo n.º 7
0
        public override ProjectProperties GetProjectData()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            OutputLog.Log("Capturing configuration from VS projects...");

            Project project = EditorUtils.GetActiveProject();

            VCProject prj = project.Object as VCProject;

            if (prj == null)
            {
                return(null);
            }

            VCConfiguration config = prj.ActiveConfiguration;

            if (config == null)
            {
                return(null);
            }

            VCPlatform platform = config.Platform;

            if (platform == null)
            {
                return(null);
            }

            var vctools = config.Tools as IVCCollection;

            if (vctools == null)
            {
                return(null);
            }

            var midl = vctools.Item("VCMidlTool") as VCMidlTool;

            var evaluator = new MacroEvaluatorVisualPlatform(platform);

            ProjectProperties ret = new ProjectProperties();

            ret.Target   = midl != null && midl.TargetEnvironment == midlTargetEnvironment.midlTargetWin32 ? ProjectProperties.TargetType.x86 : ProjectProperties.TargetType.x64;
            ret.Standard = GetStandardVersion(config);

            //Working directory (always local to processed file)
            ret.WorkingDirectory = Path.GetDirectoryName(project.FullName);

            //Include dirs / files and preprocessor
            AppendMSBuildStringToList(ret.IncludeDirectories, evaluator.Evaluate(platform.IncludeDirectories));
            AppendProjectProperties(ret, vctools.Item("VCCLCompilerTool") as VCCLCompilerTool, vctools.Item("VCNMakeTool") as VCNMakeTool, evaluator);

            //Get settings from the single file (this might fail badly if there are no settings to catpure)
            var applicationObject = EditorUtils.ServiceProvider.GetService(typeof(DTE)) as EnvDTE80.DTE2;

            Assumes.Present(applicationObject);
            ProjectItem         item       = applicationObject.ActiveDocument.ProjectItem;
            VCFile              vcfile     = item != null ? item.Object as VCFile : null;
            IVCCollection       fileCfgs   = vcfile != null ? (IVCCollection)vcfile.FileConfigurations : null;
            VCFileConfiguration fileConfig = fileCfgs != null?fileCfgs.Item(config.Name) as VCFileConfiguration : null;

            VCCLCompilerTool fileToolCL    = null;
            VCNMakeTool      fileToolNMake = null;

            try
            {
                fileToolCL    = fileConfig.Tool as VCCLCompilerTool;
                fileToolNMake = fileConfig.Tool as VCNMakeTool;
            }
            catch (Exception e)
            {
                //If we really need this data we can always parse the vcxproj as an xml
                OutputLog.Log("File specific properties not found, only project properties used (" + e.Message + ")");
            }

            AppendProjectProperties(ret, fileToolCL, fileToolNMake, evaluator);

            CaptureExtraProperties(ret, evaluator);

            AddCustomSettings(ret, evaluator);

            RemoveMSBuildStringFromList(ret.IncludeDirectories, evaluator.Evaluate(platform.ExcludeDirectories)); //Exclude directories

            ProcessPostProjectData(ret);

            return(ret);
        }
Ejemplo n.º 8
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));
            }
        }