Ejemplo n.º 1
0
        /// <summary>
        /// Finds the collection of properties associated with the custom build
        /// rule passed in. These are passed back in a map of:
        /// PropertyName => PropertyValueString
        /// </summary>
        private Dictionary <string, string> getCustomBuildRuleProperties(VCCustomBuildRule rule)
        {
            Dictionary <string, string> results = new Dictionary <string, string>();

            // We loop through the collection of properties for the rule...
            IVCCollection properties    = Utils.call(() => (rule.Properties));
            int           numProperties = Utils.call(() => (properties.Count));

            for (int i = 1; i <= numProperties; ++i)
            {
                VCRuntimeProperty property = Utils.call(() => (properties.Item(i) as VCRuntimeProperty));

                // We find the property's name...
                string name = property.Name;

                // We have to use this rather bizarre method to get the property's value.
                // (It seems that the property is a dynamically created COM object.)
                Type   ruleType      = rule.GetType();
                object valueAsObject = Utils.call(() => (ruleType.InvokeMember(name, BindingFlags.GetProperty, null, rule, null)));
                string valueAsString = valueAsObject.ToString();

                results.Add(name, valueAsString);
            }

            return(results);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds the collection of properties associated with the custom build
        /// rule passed in. These are passed back in a map of:
        /// PropertyName => PropertyValueString
        /// </summary>
        private Dictionary<string, string> getCustomBuildRuleProperties(VCCustomBuildRule rule)
        {
            Dictionary<string, string> results = new Dictionary<string, string>();

            // We loop through the collection of properties for the rule...
            IVCCollection properties = Utils.call(() => (rule.Properties));
            int numProperties = Utils.call(() => (properties.Count));
            for (int i = 1; i <= numProperties; ++i)
            {
                VCRuntimeProperty property = Utils.call(() => (properties.Item(i) as VCRuntimeProperty));

                // We find the property's name...
                string name = property.Name;

                // We have to use this rather bizarre method to get the property's value.
                // (It seems that the property is a dynamically created COM object.)
                Type ruleType = rule.GetType();
                object valueAsObject = Utils.call(() => (ruleType.InvokeMember(name, BindingFlags.GetProperty, null, rule, null)));
                string valueAsString = valueAsObject.ToString();

                results.Add(name, valueAsString);
            }

            return results;
        }
Ejemplo n.º 3
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.º 4
0
        /// <summary>
        /// Parses one configuration for a custom build rule.
        /// </summary>
        private void parseCustomBuildRule_Configuration(VCFileConfiguration configuration, string relativePath)
        {
            // We find the custom build rule for this configuration (if there is one)...
            VCCustomBuildRule rule = Utils.call(() => (configuration.Tool as VCCustomBuildRule));

            if (rule == null)
            {
                return;
            }

            // We will store info about this rule in a CustomBuildRuleInfo_CPP object...
            CustomBuildRuleInfo_CPP ruleInfo = new CustomBuildRuleInfo_CPP();

            ruleInfo.RelativePathToFile = relativePath;

            // There is a custom build rule, so we parse it...
            ruleInfo.RuleName = Utils.call(() => (rule.Name));
            string commandLine         = Utils.call(() => (rule.CommandLine));
            string expandedCommandLine = Utils.call(() => (configuration.Evaluate(commandLine)));

            // We find the collection of output files generated by the rule...
            string outputs         = Utils.call(() => (rule.Outputs));
            string expandedOutputs = Utils.call(() => (configuration.Evaluate(outputs)));

            // The command-line may contain references to custom properties for
            // the rule. These will be in square brackets,like [property]. We find
            // these and replace the property markers in the command-line...
            Dictionary <string, string> properties = getCustomBuildRuleProperties(rule);

            foreach (KeyValuePair <string, string> property in properties)
            {
                // We replace values in the command line, and in the output files...
                string tokenToReplace = "[" + property.Key + "]";
                expandedCommandLine = expandedCommandLine.Replace(tokenToReplace, property.Value);
                expandedOutputs     = expandedOutputs.Replace(tokenToReplace, property.Value);
            }

            // We split the command-line to find the executable and the parameters...
            List <string> splitCommandLine = Utils.split(expandedCommandLine, ' ');

            // The executable...
            if (splitCommandLine.Count >= 1)
            {
                string ruleExecutable           = splitCommandLine[0];
                string relativePathToExecutable = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, ruleExecutable);
                ruleInfo.RelativePathToExecutable = relativePathToExecutable;
            }

            // The parameters...
            for (int j = 1; j < splitCommandLine.Count; ++j)
            {
                string parameter = splitCommandLine[j];

                // Many parameters will be path names. We cnvert these
                // to be relative to the project root (and in Linux format).
                // Non-path parameters should be unaffected...
                parameter = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, parameter);
                ruleInfo.addParameter(parameter);
            }

            // We store the info in the configuration...
            m_projectInfo.addCustomBuildRuleInfo(ruleInfo, configuration.Name);
        }