コード例 #1
0
        public static void SetIncludesForNewProject(VCProject vcProject,
                                                    CompilerSpecificationCommandResult compilerSpecsCommandResult,
                                                    ProjectInformationCommandResult projectInformation)
        {
            (IEnumerable <CompilerMacroResult> macros, IEnumerable <string> includes) =
                ProjectIncludesManager.FindMacrosAndIncludesForMinTarget(compilerSpecsCommandResult,
                                                                         projectInformation);

            if (macros == null)
            {
                macros = Enumerable.Empty <CompilerMacroResult>();
            }
            if (includes == null)
            {
                includes = Enumerable.Empty <string>();
            }

            foreach (VCConfiguration2 config in vcProject.Configurations)
            {
                IVCRulePropertyStorage plcnextCommonPropertiesRule = config.Rules.Item(Constants.PLCnextRuleName);
                if (plcnextCommonPropertiesRule == null)
                {
                    MessageBox.Show("PLCnextCommonProperties rule was not found in configuration rules collection.");
                }

                string joinedMacros = macros.Any() ? string.Join(";",
                                                                 macros.Select(m => m.Name + (string.IsNullOrEmpty(m.Value.Trim()) ? null : "=" + m.Value)))
                        : string.Empty;
                string joinedIncludes = includes.Any() ? string.Join(";", includes) : string.Empty;

                plcnextCommonPropertiesRule.SetPropertyValue(Constants.PLCnextMacrosKey, joinedMacros);
                plcnextCommonPropertiesRule.SetPropertyValue(Constants.PLCnextIncludesKey, joinedIncludes);
            }
        }
コード例 #2
0
        public static void AddToProperty(Solution2 solution, string projectName, string buildConfig, string ruleName, string property, string additionalData)
        {
            IVCRulePropertyStorage rule = GetPropertyStorage(solution, projectName, buildConfig, ruleName, property);
            string previousDependencies = rule.GetUnevaluatedPropertyValue(property);

            rule.SetPropertyValue(property, additionalData + ';' + previousDependencies);
        }
コード例 #3
0
        public void OverrideSDKRootPepper()
        {
            string slnName = TestUtilities.CreateBlankValidNaClSolution(
                dte_,
                "OverrideSDKRootPepper",
                Strings.PepperPlatformName,
                Strings.PepperPlatformName,
                TestContext);

            OpenSolutionAndGetProperties(slnName, Strings.PepperPlatformName);

            // VC++ Directories
            string page = "ConfigurationGeneral";
            IVCRulePropertyStorage pageStorage = debug_.Rules.Item(page);

            pageStorage.SetPropertyValue("VSNaClSDKRoot", @"foo\");

            page = "ConfigurationDirectories";
            TestUtilities.AssertPropertyContains(debug_, page, "IncludePath", @"foo\include;", true, true);
            TestUtilities.AssertPropertyContains(debug_, page, "IncludePath", @"foo\include\win;", true, true);
            TestUtilities.AssertPropertyContains(debug_, page, "IncludePath", @"foo\include", true, true);
            TestUtilities.AssertPropertyContains(debug_,
                                                 page, "LibraryPath", @"foo\lib\win_x86_32_host", true, true);
            TestUtilities.AssertPropertyContains(debug_, page, "LibraryPath", @"foo\lib", true, true);

            dte_.Solution.Close();
        }
コード例 #4
0
        public void ProjectFinishedGenerating(Project project)
        {
            // use VCProject.LatestTargetPlatformVersion property, which is what the stock wizards use.
            VCProject vcProject = (VCProject)project.Object;
            string    wtpv      = vcProject.LatestTargetPlatformVersion;

            if (wtpv != null)
            {
                // we only have to do this for a single config, as the property in question is global.
                IVCCollection          configs     = (IVCCollection)vcProject.Configurations;
                VCConfiguration        firstConfig = (VCConfiguration)configs.Item(1);
                IVCRulePropertyStorage rule        = (IVCRulePropertyStorage)firstConfig.Rules.Item("ConfigurationGeneral");
                rule?.SetPropertyValue("WindowsTargetPlatformVersion", wtpv);
            }
        }
コード例 #5
0
 /// <summary>
 /// </summary>
 protected void SetPropertyValue(string pageRule, string propertyName, string propertyValue, object configName = null)
 {
     if (configName == null)
     {
         foreach (VCConfiguration config in Project.Configurations)
         {
             IVCRulePropertyStorage storage = config.Rules.Item(pageRule);
             storage.SetPropertyValue(propertyName, propertyValue);
         }
     }
     else
     {
         IVCCollection          configs = Project.Configurations;
         VCConfiguration        config  = configs.Item(configName);
         IVCRulePropertyStorage storage = config.Rules.Item(pageRule);
         storage.SetPropertyValue(propertyName, propertyValue);
     }
 }
コード例 #6
0
        public void ProjectFinishedGenerating(Project project)
        {
            VCProject vcproject = null;

            vcproject = project.Object as VCProject;

            var addons = inputForm.getAddons();

            itemName = vcproject.ItemName;
            Wizard.addAddons(vcproject, ofRoot, addons);
            Wizard.saveAddonsMake(vcproject, addons);
            string ofProject;

            if (Path.IsPathRooted(ofRoot))
            {
                ofProject = Path.Combine(ofRoot, "libs\\openFrameworksCompiled\\project\\vs\\openFrameworksLib.vcxproj");
            }
            else
            {
                string[] path = { Path.GetDirectoryName(project.FullName), ofRoot, "libs\\openFrameworksCompiled\\project\\vs\\openFrameworksLib.vcxproj" };
                ofProject = Path.Combine(path);
            }
            dte.Solution.AddFromFile(ofProject);

            //Setting the Windows target platform version of the project
            //to avoid the error with Windows SDK
            //Same problem as described here: https://sharepointforum.org/threads/creating-a-vsix-deployable-c-project-template.142260/

            // use VCProject.LatestTargetPlatformVersion property, which is what the stock wizards use.
            VCProject vcProject = (VCProject)project.Object;
            string    wtpv      = vcProject.LatestTargetPlatformVersion;

            if (wtpv != null)
            {
                // we only have to do this for a single config, as the property in question is global.
                IVCCollection          configs     = (IVCCollection)vcProject.Configurations;
                VCConfiguration        firstConfig = (VCConfiguration)configs.Item(1);
                IVCRulePropertyStorage rule        = (IVCRulePropertyStorage)firstConfig.Rules.Item("ConfigurationGeneral");
                rule?.SetPropertyValue("WindowsTargetPlatformVersion", wtpv);
            }
        }
コード例 #7
0
        public static void SetProperty(Solution2 solution, string projectName, string buildConfig, string ruleName, string property, string additionalData)
        {
            IVCRulePropertyStorage rule = GetPropertyStorage(solution, projectName, buildConfig, ruleName, property);

            rule.SetPropertyValue(property, additionalData);
        }
コード例 #8
0
        /// <summary>
        /// Sets any generic property to the current target properties.
        /// </summary>
        /// <param name="page">Page where property is located.</param>
        /// <param name="name">Name of the property.</param>
        /// <param name="value">Unevaluated string value to set.</param>
        public virtual void SetProperty(string page, string name, string value)
        {
            IVCRulePropertyStorage pageStorage = configuration_.Rules.Item(page);

            pageStorage.SetPropertyValue(name, value);
        }
コード例 #9
0
        public static void UpdateIncludesAndMacrosForExistingProject(VCProject vcProject,
                                                                     IEnumerable <CompilerMacroResult> oldMacros,
                                                                     CompilerSpecificationCommandResult newCompilerSpecs,
                                                                     IEnumerable <string> oldIncludes,
                                                                     ProjectInformationCommandResult newProjectInformation)
        {
            var(newMacros, newIncludes) =
                ProjectIncludesManager.FindMacrosAndIncludesForMinTarget(newCompilerSpecs,
                                                                         newProjectInformation);
            if (newMacros == null)
            {
                newMacros = Enumerable.Empty <CompilerMacroResult>();
            }
            if (newIncludes == null)
            {
                newIncludes = Enumerable.Empty <string>();
            }

            IVCRulePropertyStorage plcnextCommonPropertiesRule = vcProject.ActiveConfiguration.Rules.Item(Constants.PLCnextRuleName);


            foreach (VCConfiguration2 config in vcProject.Configurations)
            {
                plcnextCommonPropertiesRule = config.Rules.Item(Constants.PLCnextRuleName);

                CheckIncludesVariableIsInProjectIncludes(config);
                CheckMacrosVariableIsInProjectMacros(config);

                DeleteObsoleteIncludes();
                DeleteObsoleteMacros();

                void DeleteObsoleteIncludes()
                {
                    string savedIncludes = plcnextCommonPropertiesRule.GetUnevaluatedPropertyValue(Constants.PLCnextIncludesKey);

                    if (!string.IsNullOrEmpty(savedIncludes) || oldIncludes == null || !oldIncludes.Any())
                    {
                        return;
                    }

                    IVCRulePropertyStorage rule            = config.Rules.Item(Constants.VCppIncludesRuleName);
                    IEnumerable <string>   currentIncludes = rule.GetUnevaluatedPropertyValue(Constants.VCppIncludesKey)
                                                             .Split(';')
                                                             .Where(i => !oldIncludes.Contains(i));

                    rule.SetPropertyValue(Constants.VCppIncludesKey, currentIncludes.Any() ?
                                          string.Join(";", currentIncludes) : string.Empty);
                }

                void DeleteObsoleteMacros()
                {
                    string savedMacros = plcnextCommonPropertiesRule.GetUnevaluatedPropertyValue(Constants.PLCnextMacrosKey);

                    if (!string.IsNullOrEmpty(savedMacros) || oldMacros == null || !oldMacros.Any())
                    {
                        return;
                    }

                    IVCRulePropertyStorage            clRule        = config.Rules.Item(Constants.CLRuleName);
                    IEnumerable <CompilerMacroResult> currentMacros =
                        clRule.GetUnevaluatedPropertyValue(Constants.VCPreprocessorsKey)
                        .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(m => m.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries))
                        .Select(m => new CompilerMacroResult {
                        Name = m[0], Value = m.Length == 2 ? m[1].Trim() : null
                    });

                    currentMacros = currentMacros.Where(m => !oldMacros.Any(y => y.Name.Equals(m.Name) &&
                                                                            (y.Value != null ?
                                                                             (m.Value == null ?
                                                                              string.IsNullOrEmpty(y.Value.Trim()) :
                                                                              y.Value.Trim().Equals(m.Value.Trim())) :
                                                                             string.IsNullOrEmpty(m.Value?.Trim()))));
                    IEnumerable <string> macros = currentMacros.Select(m => m.Name + (string.IsNullOrEmpty(m.Value?.Trim()) ? string.Empty : ("=" + m.Value)));

                    clRule.SetPropertyValue(Constants.VCPreprocessorsKey, macros.Any() ? string.Join(";", macros) : string.Empty);
                }
            }

            plcnextCommonPropertiesRule.SetPropertyValue(Constants.PLCnextIncludesKey, newIncludes.Any() ?
                                                         string.Join(";", newIncludes) :
                                                         string.Empty);

            plcnextCommonPropertiesRule.SetPropertyValue(Constants.PLCnextMacrosKey, newMacros.Any() ?
                                                         string.Join(";", newMacros.Select(m => m.Name + (string.IsNullOrEmpty(m.Value?.Trim()) ? string.Empty : ("=" + m.Value))))
                : string.Empty);


            void CheckIncludesVariableIsInProjectIncludes(VCConfiguration2 config)
            {
                IVCRulePropertyStorage rule = config.Rules.Item(Constants.VCppIncludesRuleName);
                string currentIncludes      = rule.GetUnevaluatedPropertyValue(Constants.VCppIncludesKey);

                if (!currentIncludes.Split(';').Where(i => i.Trim().Equals($"$({Constants.PLCnextIncludesKey})", StringComparison.OrdinalIgnoreCase)).Any())
                {
                    string includes = string.IsNullOrEmpty(currentIncludes) ? $"$({Constants.PLCnextIncludesKey})"
                                                        : string.Join(";", currentIncludes, $"$({Constants.PLCnextIncludesKey})");
                    rule.SetPropertyValue(Constants.VCppIncludesKey, includes);
                }
            }

            void CheckMacrosVariableIsInProjectMacros(VCConfiguration2 config)
            {
                IVCRulePropertyStorage clRule = config.Rules.Item(Constants.CLRuleName);
                string currentMacros          =
                    clRule.GetUnevaluatedPropertyValue(Constants.VCPreprocessorsKey);

                if (!currentMacros.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                    .Where(m => m.Trim()
                           .Equals($"$({Constants.PLCnextMacrosKey})", StringComparison.OrdinalIgnoreCase))
                    .Any())
                {
                    string macros = string.IsNullOrEmpty(currentMacros) ? $"$({Constants.PLCnextMacrosKey})"
                                                       : string.Join(";", currentMacros, $"$({Constants.PLCnextMacrosKey})");
                    clRule.SetPropertyValue(Constants.VCPreprocessorsKey, macros);
                }
            }
        }