public String[] FindConfigs(String project, String platform) { String[] entries = null; int actCount = 0; IEnumerator e = GetVCProjectRefs(); e.Reset(); while (e.MoveNext()) { VCProject actVCP = (VCProject)e.Current; if (actVCP.Name == project) { IVCCollection configs = (IVCCollection)actVCP.Configurations; entries = new String[configs.Count]; IEnumerator eConfs = configs.GetEnumerator(); eConfs.Reset(); while (eConfs.MoveNext()) { String actEntry = ((VCConfiguration)eConfs.Current).Name; // configuration name comes in the form "Debug|Win32" actEntry = actEntry.Substring(0, actEntry.IndexOf("|")); entries[actCount++] = actEntry; } } } return(entries); }
public static VCFile AddRelativeFile(this VCFilter root, string relativepath, string fullpath) { VCFilter cur = root; var dirs = relativepath.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (dirs.Count > 1) { for (int i = 0; i < dirs.Count - 1; i++) { string idir = dirs[i]; if (cur != null) { VCFilter next = null; IVCCollection subs = cur.Filters; foreach (VCFilter sub in subs) { if (sub.Name == idir) { next = sub; break; } } if (next != null) { next = cur.AddFilter(idir); cur = next; } } } } return(cur.AddFile(fullpath)); }
/// <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); }
private void IntegrateIntoConfiguration(VCConfiguration configuration) { string absPropFilePath = GetPropsFilePath(configuration); string relativePropFilePath = ConanPathHelper.GetRelativePath(configuration.project.ProjectDirectory, absPropFilePath); IVCCollection tools = (IVCCollection)configuration.Tools; if (tools != null) { VCLinkerTool ltool = (VCLinkerTool)tools.Item("VCLinkerTool"); if (ltool != null) { string deps = ltool.AdditionalDependencies; ltool.AdditionalDependencies = deps.Replace("$(NOINHERIT)", ""); } } foreach (VCPropertySheet sheet in configuration.PropertySheets) { if (ConanPathHelper.NormalizePath(sheet.PropertySheetFile) == ConanPathHelper.NormalizePath(absPropFilePath)) { return; } } configuration.AddPropertySheet(relativePropFilePath); configuration.CollectIntelliSenseInfo(); }
public void addLibsToVCProject(VCProject project) { foreach (VCConfiguration config in project.Configurations) { IVCCollection tools = config.Tools; foreach (Object tool in tools) { if (tool is VCLinkerTool) { VCLinkerTool linker = (VCLinkerTool)tool; if (config.Name == "Debug|Win32" && libs32Debug.Count > 0) { linker.AdditionalDependencies.AppendSemiColon(); linker.AdditionalDependencies += libs32Debug.ConcatenateWithSeparator(' '); } else if (config.Name == "Debug|x64" && libs64Debug.Count > 0) { linker.AdditionalDependencies.AppendSemiColon(); linker.AdditionalDependencies += libs64Debug.ConcatenateWithSeparator(' '); } else if (config.Name == "Release|Win32" && libs32Release.Count > 0) { linker.AdditionalDependencies.AppendSemiColon(); linker.AdditionalDependencies += libs32Release.ConcatenateWithSeparator(' '); } else if (config.Name == "Release|x64" && libs64Release.Count > 0) { linker.AdditionalDependencies.AppendSemiColon(); linker.AdditionalDependencies += libs64Debug.ConcatenateWithSeparator(' '); } } } } }
public static void RunlUpdate(EnvDTE.Project project) { QtProject qtPro = QtProject.Create(project); if (qtPro == null) { return; } FakeFilter ts = Filters.TranslationFiles(); VCFilter tsFilter = qtPro.FindFilterFromGuid(ts.UniqueIdentifier); if (tsFilter == null) { return; } IVCCollection files = tsFilter.Files as IVCCollection; foreach (VCFile file in files) { VCFile vcFile = file as VCFile; if (HelperFunctions.IsTranslationFile(vcFile)) { if (!RunlUpdate(vcFile, project)) { return; } } } }
/// <summary> /// We parse the librarian settings, ie link options for libraries. /// </summary> private void parseConfiguration_LibrarianSettings(VCConfiguration vcConfiguration, ProjectConfigurationInfo_CPP configurationInfo) { // We get the librarian 'tool'... IVCCollection tools = Utils.call(() => (vcConfiguration.Tools as IVCCollection)); VCLibrarianTool librarianTool = Utils.call(() => (tools.Item("VCLibrarianTool") as VCLibrarianTool)); if (librarianTool == null) { // Not all projects have a librarian tool... return; } // We find if this library is set to link together other libraries it depends on... // (We are assuming that all configurations of the project have the same link-library-dependencies setting.) m_projectInfo.LinkLibraryDependencies = Utils.call(() => (librarianTool.LinkLibraryDependencies)); // - Target Machine (TODO: complete the machine type) string platform = Utils.call(() => (vcConfiguration.Evaluate("$(Platform)"))); if (!string.IsNullOrEmpty(platform)) { configurationInfo.Platform = platform; configurationInfo.addLinkerFlag("/MACHINE:X64"); } // - Import Library configurationInfo.DynamicLibOutputPath = configurationInfo.OutputFolderAbsolute + m_projectInfo.Name + ".lib"; }
/// <summary> /// Finds the collection of source files in the project. /// </summary> private void parseProject_SourceFiles() { // We loop through the collection of files in the project... IVCCollection files = Utils.call(() => (m_vcProject.Files as IVCCollection)); int numFiles = Utils.call(() => (files.Count)); for (int i = 1; i <= numFiles; ++i) { // We get one file... VCFile file = Utils.call(() => (files.Item(i) as VCFile)); string path = Utils.call(() => (file.FullPath)); string extension = Path.GetExtension(path).ToLower(); // We check if the file has a custom build rule... parseCustomBuildRule(file); // We find the extension, and see if it is one we treat // as a source file... switch (extension) { // It looks like a source file... case ".cpp": case ".c": case ".cc": case ".cp": case ".cxx": case ".c++": // We add it to the project... string relativePath = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, path); m_projectInfo.addFile(relativePath); break; } } }
static private VCCLCompilerTool GetVCCLCompilerToolForProject(VCConfiguration vcConfiguration) { IVCCollection fTools = (IVCCollection)vcConfiguration.Tools; VCCLCompilerTool vcCTool = (VCCLCompilerTool)fTools.Item("VCCLCompilerTool"); return(vcCTool); }
private bool CorrectVCppDirectories() { string testcocoon_install_path = TestCocoonInstallPath(); try { for (int iplfCol = 1; iplfCol <= _applicationObject.Solution.Count; iplfCol++) { try { VCProject prj = (VCProject)_applicationObject.Solution.Item(iplfCol).Object; IVCCollection plfColl = (IVCCollection)prj.Platforms; for (int iPlf = 1; iPlf <= plfColl.Count; iPlf++) { try { VCPlatform plf = (VCPlatform)plfColl.Item(iPlf); string dirs = plf.ExecutableDirectories; string[] dirList = dirs.Split(';'); bool append_testcocoon_path = false; if (dirList.Length == 0) { append_testcocoon_path = true; } else if (dirList[0] != testcocoon_install_path) { append_testcocoon_path = true; } if (append_testcocoon_path) { plf.ExecutableDirectories = testcocoon_install_path + ";" + dirs; prj.Save(); Log("Directory '" + testcocoon_install_path + "' added in the list of executable directories for the platform '" + plf.Name + "'"); } } catch (Exception e) { // maybe the plugin was loaded without an open solution Debug(e); } } } catch (Exception e) { // maybe the plugin was loaded without an open solution Debug(e); } } return(true); } catch (Exception e) { // maybe the plugin was loaded without an open solution Debug(e); return(false); } }
public void ClearTheFakeObject() { _fackProjObj = null; _fakeActiveConfiguration = null; _fakeConfigurationManager = null; _fakeCollection = null; _fakeVcConfiguration = null; }
/// <summary> /// Get the active code file, project and configuration /// </summary> /// <returns>true if we have found an active C/C++ document</returns> bool GetActiveVCFile(out VCFile vcFile, out VCProject vcProject, out VCConfiguration vcCfg) { vcFile = null; vcProject = null; vcCfg = null; if (_applicationObject.ActiveDocument != null) { // GUID equates to 'code file' as far as I can make out if (_applicationObject.ActiveDocument.Kind == "{8E7B96A8-E33D-11D0-A6D5-00C04FB67F6A}" && _applicationObject.ActiveDocument.Language == "C/C++") { // GUID equates to physical file on disk [http://msdn.microsoft.com/en-us/library/z4bcch80(VS.80).aspx] if (_applicationObject.ActiveDocument.ProjectItem.Kind == "{6BB5F8EE-4483-11D3-8BCF-00C04F8EC28C}") { // leap of faith vcFile = (VCFile)_applicationObject.ActiveDocument.ProjectItem.Object; vcProject = (VCProject)vcFile.project; if (vcFile.FileType != eFileType.eFileTypeCppCode) { return(false); } // save the file (should be optional!) if (!_applicationObject.ActiveDocument.Saved) { _applicationObject.ActiveDocument.Save(vcFile.FullPath); } // get current configuration to pass to the bridge EnvDTE.Configuration cfg = _applicationObject.ActiveDocument.ProjectItem.ConfigurationManager.ActiveConfiguration; try { IVCCollection cfgArray = (IVCCollection)vcProject.Configurations; foreach (VCConfiguration vcr in cfgArray) { if (vcr.ConfigurationName == cfg.ConfigurationName && vcr.Platform.Name == cfg.PlatformName) { vcCfg = vcr; } } } catch (System.Exception) { return(false); } return(true); } } } return(false); }
public bool LaunchAndDoInject() { IVsOutputWindowPane output = (IVsOutputWindowPane)Package.GetGlobalService(typeof(SVsGeneralOutputWindowPane)); String exepath = ""; String workdir = ""; String environment = ""; String addindir = ""; Solution sln = _applicationObject.Solution; String startup = (String)((Array)sln.SolutionBuild.StartupProjects).GetValue(0); foreach (EnvDTE.Project project in sln.Projects) { if (project.UniqueName == startup) { VCProject vcproj = (VCProject)project.Object; if (vcproj == null) { // this is not a visual c++ project continue; } IVCCollection cfgs = vcproj.Configurations; VCConfiguration cfg = cfgs.Item(1); exepath = cfg.Evaluate("$(LocalDebuggerCommand)"); workdir = cfg.Evaluate("$(LocalDebuggerWorkingDirectory)"); environment = cfg.Evaluate("$(LocalDebuggerEnvironment)"); addindir = cfg.Evaluate("$(USERPROFILE)\\Documents\\Visual Studio 2012\\Addins"); output.OutputString(exepath); } } uint pid = dpVSHelper.ExecuteSuspended(exepath, addindir, environment); if (pid != 0) { VsDebugTargetProcessInfo[] res = new VsDebugTargetProcessInfo[1]; VsDebugTargetInfo4[] info = new VsDebugTargetInfo4[1]; info[0].bstrExe = exepath; info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_AlreadyRunning; //info[0].dlo = (uint)_DEBUG_LAUNCH_OPERATION4.DLO_AttachToSuspendedLaunchProcess; // somehow this makes debugger not work info[0].dwProcessId = pid; info[0].LaunchFlags = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd | (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop; Guid guidDbgEngine = VSConstants.DebugEnginesGuids.ManagedAndNative_guid; IntPtr pGuids = Marshal.AllocCoTaskMem(Marshal.SizeOf(guidDbgEngine)); Marshal.StructureToPtr(guidDbgEngine, pGuids, false); info[0].pDebugEngines = pGuids; info[0].dwDebugEngineCount = 1; IVsDebugger4 idbg = (IVsDebugger4)Package.GetGlobalService(typeof(SVsShellDebugger)); idbg.LaunchDebugTargets4(1, info, res); dpVSHelper.Resume(pid); } return(true); }
public List <string> FindListOfIncludeDirectories() { List <string> files = new List <string>(); IEnumerator e = GetVCProjectRefs(); e.Reset(); while (e.MoveNext()) { VCProject actVCP = (VCProject)e.Current; IVCCollection filesCollection = (IVCCollection)actVCP.Files; if (filesCollection != null) { for (int item_idx = 0; item_idx < filesCollection.Count + 1; ++item_idx) { try { VCFile file = (VCFile)(filesCollection.Item(item_idx)); if (file != null) { switch (file.FileType) { default: break; case eFileType.eFileTypeCppHeader: { string path = System.IO.Path.GetDirectoryName(file.FullPath); bool found = false; foreach (string item in files) { if (item.ToLower() == path.ToLower()) { found = true; break; } } if (!found) { files.Add(path); } } break; } } } catch (Exception exp) { Debug(exp); } } } } return(files); }
/// <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); }
/// <summary> /// Given an IVCCollection of tools, identifies and returns the C++ tools. /// </summary> /// <param name="toolsCollection">The IVCCollection to search</param> /// <returns>The C++ tools or null if not available</returns> private static VCCLCompilerTool GetVCppCompilerOptions(dynamic toolsCollection) { IVCCollection tools = toolsCollection as IVCCollection; if (tools != null) { return(tools.OfType <VCCLCompilerTool>().FirstOrDefault()); } return(null); }
/// <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); }
/// <summary> /// We parse the post-build events. /// </summary> private void parseConfiguration_PostBuildEvent(VCConfiguration vcConfiguration, ProjectConfigurationInfo_CPP configurationInfo) { // We see if there is a pre-build event... IVCCollection tools = Utils.call(() => (vcConfiguration.Tools as IVCCollection)); VCPostBuildEventTool postBuildEvent = Utils.call(() => (tools.Item("VCPostBuildEventTool") as VCPostBuildEventTool)); if (postBuildEvent == null) { return; } string commandLine = Utils.call(() => (postBuildEvent.CommandLine)); configurationInfo.PostBuildEvent = convertBuildEventCommandLine(commandLine); }
/// <summary> /// Finds the configurations, e.g. debug, release etc. /// </summary> private void parseProject_Configurations() { // We loop through the collection of configurations for the project... IVCCollection configurations = Utils.call(() => (m_vcProject.Configurations as IVCCollection)); int numConfigurations = Utils.call(() => (configurations.Count)); for (int i = 1; i <= numConfigurations; ++i) { // We parse this configuration, and add the parsed data to the collection // for this project... VCConfiguration vcConfiguration = Utils.call(() => (configurations.Item(i) as VCConfiguration)); parseConfiguration(vcConfiguration); } }
private VCFilter GetOrCreateTestFilter() { VCProject vcproj = (VCProject)project.GetExtObjectAs <Project>().Object; IVCCollection filters = (IVCCollection)vcproj.Filters; VCFilter filter = (VCFilter)filters.Item("Test Suites"); if (filter == null) { filter = (VCFilter)vcproj.AddFilter("Test Suites"); } return(filter); }
// ------------------------------------------------------ /// <summary> /// Creates the test runner source file for the current startup /// project and adds it to the project. /// </summary> /// <param name="doNotRunTests"> /// If true, the file will be generated but will not include any /// statements to run any tests. If false, the tests will be run /// based on the current selection in the CxxTest Suites view. /// </param> public void CreateTestRunnerFile(bool doNotRunTests) { TestSuiteCollection suites = AllTestSuites; Dictionary <string, bool> testsToRun; if (doNotRunTests) { testsToRun = null; } else { testsToRun = TryToGetTestsToRun(); } HierarchyItem startupProject = VsShellUtils.GetStartupProject(this); string projectDir = startupProject.ProjectDirectory; string workingDir = GetActiveWorkingDirectory(startupProject); Project project = startupProject.GetExtObjectAs <Project>(); string runnerPath = Path.Combine( projectDir, Constants.TestRunnerFilename); // Remove the file from the project if necessary, and delete it // from the file system if it exists. VCProject vcproj = (VCProject)project.Object; if (!vcproj.CanAddFile(runnerPath)) { IVCCollection coll = (IVCCollection)vcproj.Files; vcproj.RemoveFile(coll.Item(Constants.TestRunnerFilename)); } if (File.Exists(runnerPath)) { File.Delete(runnerPath); } TestRunnerGenerator generator = new TestRunnerGenerator(runnerPath, suites, testsToRun); generator.Generate(); // Add the file to the project. vcproj.AddFile(runnerPath); }
/// <summary> /// </summary> protected string GetPropertyValue(string pageRule, string propertyName, bool evaluated = true, object configName = null) { if (configName == null) { configName = 1; } IVCCollection configs = Project.Configurations; VCConfiguration config = configs.Item(configName); IVCRulePropertyStorage storage = config.Rules.Item(pageRule); return(evaluated ? storage.GetEvaluatedPropertyValue(propertyName) : storage.GetUnevaluatedPropertyValue(propertyName)); }
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); } }
/// <summary> /// Returns a VCConfiguration object with a matching configuration name and platform type. /// </summary> /// <param name="project">Project to get the configuration from.</param> /// <param name="name">Name of configuration (e.g. 'Debug').</param> /// <param name="platform">Name of the platform (e.g. 'NaCl').</param> /// <returns>A matching VCConfiguration object.</returns> public static VCConfiguration GetVCConfiguration(Project project, string name, string platform) { VCProject vcproj = (VCProject)project.Object; IVCCollection configs = vcproj.Configurations; foreach (VCConfiguration config in configs) { if (config.ConfigurationName == name && config.Platform.Name == platform) { return(config); } } throw new Exception( string.Format("Project does not have configuration: {0}|{1}", platform, name)); }
/// <summary> /// We parse the librarian settings, ie link options for libraries. /// </summary> private void parseConfiguration_LibrarianSettings(VCConfiguration vcConfiguration, ProjectConfigurationInfo_CPP configurationInfo) { // We get the librarian 'tool'... IVCCollection tools = Utils.call(() => (vcConfiguration.Tools as IVCCollection)); VCLibrarianTool librarianTool = Utils.call(() => (tools.Item("VCLibrarianTool") as VCLibrarianTool)); if (librarianTool == null) { // Not all projects have a librarian tool... return; } // We find if this library is set to link together other libraries it depends on... // (We are assuming that all configurations of the project have the same link-library-dependencies setting.) m_projectInfo.LinkLibraryDependencies = Utils.call(() => (librarianTool.LinkLibraryDependencies)); }
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()); }
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); } }
/// <summary> /// Finds the linker settings, such as the collection of libraries to link, /// for the configuration passed in. /// </summary> private void parseConfiguration_LinkerSettings(VCConfiguration vcConfiguration, ProjectConfigurationInfo_CPP configurationInfo) { // We get the linker-settings 'tool'... IVCCollection tools = Utils.call(() => (vcConfiguration.Tools as IVCCollection)); VCLinkerTool linkerTool = Utils.call(() => (tools.Item("VCLinkerTool") as VCLinkerTool)); if (linkerTool == null) { // Not all projects have a linker tools... return; } // And extract various details from it... parseLinkerSettings_LibraryPath(vcConfiguration, configurationInfo); parseLinkerSettings_Libraries(vcConfiguration, configurationInfo); parseLinkerSettings_Misc(vcConfiguration, linkerTool, configurationInfo); }
public void OnBuildProjConfigBegin(string projName, string projConfig , string platform, string solConfig) { if (solConfig.Contains(" [ChartPoints]")) { extensionServ.SetMode(EMode.Build); ServiceHost serviceHost = null; try { EnvDTE.Project proj = Globals.dte.Solution.Projects.Item(projName); //!!! Needed for newly created project to update vcxproj file !!! //Orchestrate(proj.FullName); IProjectChartPoints pPnts = Globals.processor.GetProjectChartPoints(proj.Name); if (pPnts != null) { VCProject vcProj = (VCProject)proj.Object; VCConfiguration vcConfig = vcProj.Configurations.Item(projConfig); IVCCollection tools = vcConfig.Tools as IVCCollection; VCLinkerTool tool = tools.Item("VCLinkerTool") as VCLinkerTool; tool.GenerateDebugInformation = false; pPnts.Validate(); if (!serviceHostsCont.TryGetValue(proj.FullName, out serviceHost)) { serviceHostsCont.Add(proj.FullName, serviceHost); } if (serviceHost == null) { serviceHost = new ServiceHost(typeof(IPCChartPoint)); serviceHostsCont[proj.FullName] = serviceHost; //if (serviceHost.State != CommunicationState.Opening && serviceHost.State != CommunicationState.Opened) //{ NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None); string address = "net.pipe://localhost/IPCChartPoint/" + System.IO.Path.GetFullPath(proj.FullName).ToLower(); serviceHost.AddServiceEndpoint(typeof(IIPCChartPoint), binding, address); serviceHost.Open(); //} } } } catch (Exception /*ex*/) { serviceHost = null; } } }
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"); } }
/// <summary> /// Checks the file passes in to see if it has a custom build rule set up, /// and parses it if it does. /// </summary> private void parseCustomBuildRule(VCFile file) { // We find the relative path to the file from the project root... string path = Utils.call(() => (file.FullPath)); string relativePath = Utils.makeRelativePath(m_projectInfo.RootFolderAbsolute, path); // The custom build rules (if there are any) are per configuration. So // we loop through the configurations for this file... IVCCollection configurations = Utils.call(() => (file.FileConfigurations as IVCCollection)); int numConfigurations = Utils.call(() => (configurations.Count)); for (int i = 1; i <= numConfigurations; ++i) { // We check if there is a rule for each configuration... VCFileConfiguration configuration = Utils.call(() => (configurations.Item(i) as VCFileConfiguration)); parseCustomBuildRule_Configuration(configuration, relativePath);; } }
public void FakeTheProjectInterface() { _fackProjObj = A.Fake<Project>(); _fakeConfigurationManager = A.Fake<ConfigurationManager>(); _fakeActiveConfiguration = A.Fake<Configuration>(); _fackVcProject = A.Fake<VCProject>(); _fakeCollection = A.Fake<IVCCollection>(); _fakeVcConfiguration = A.Fake<VCConfiguration>(); }
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"); }