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); } }
/// <summary> /// Parses the configuration (e.g. Debug, Release) passed in. /// </summary> private void parseConfiguration(VCConfiguration vcConfiguration) { // The configuration name... String configName = Utils.call(() => (vcConfiguration.ConfigurationName)); if (!MakeItSoConfig.Instance.ShouldConvertConfig(configName)) { return; } VCPlatform vcPlatform = Utils.call(() => (vcConfiguration.Platform as VCPlatform)); String platformName = Utils.call(() => (vcPlatform.Name)); if (!MakeItSoConfig.Instance.ShouldConvertPlatform(platformName)) { return; } ProjectConfigurationInfo_CPP configurationInfo = new ProjectConfigurationInfo_CPP(); configurationInfo.ParentProjectInfo = m_projectInfo; configurationInfo.Name = configName + "_" + platformName; // 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 and output folder, and the Target Name. configurationInfo.IntermediateFolder = parseConfiguration_Folder(vcConfiguration, () => (vcConfiguration.IntermediateDirectory)); configurationInfo.OutputFolder = parseConfiguration_Folder(vcConfiguration, () => (vcConfiguration.OutputDirectory)); configurationInfo.TargetName = parseConfiguration_TargetName(vcConfiguration); // 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); }
public static void AddVCTool(this VCFile vcfile, string config, string platform) { foreach (VCFileConfiguration ffs in (IVCCollection)vcfile.FileConfigurations) { VCConfiguration fvc = ffs.ProjectConfiguration as VCConfiguration; if (fvc != null) { if (fvc.ConfigurationName == config) { VCPlatform fplat = fvc.Platform; if (fplat != null) { if (fplat.Name == platform) { VCCLCompilerTool clt = (VCCLCompilerTool)fvc.Tools.Item("VCCLCompilerTool"); clt.ObjectFile = @"$(IntDir)%(RelativeDir)"; } } } } } }
// ------------------------------------------------------ /// <summary> /// Add the CxxTest and Dereferee paths to the Visual C++ settings, /// if they aren't already there. /// </summary> private void AddIncludesAndLibrariesPaths() { DTE dte = (DTE)GetService(typeof(DTE)); Projects projects = (Projects)dte.GetObject("VCProjects"); VCProjectEngine projectEngine = (VCProjectEngine) projects.Properties.Item("VCProjectEngine").Object; IVCCollection platforms = (IVCCollection)projectEngine.Platforms; VCPlatform vcp = (VCPlatform)platforms.Item("Win32"); string packageDir = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location); string cxxTestIncludePath = Path.Combine( packageDir, "Include\\cxxtest"); string derefereeIncludePath = Path.Combine( packageDir, "Include\\dereferee"); string supportLibPath = Path.Combine(packageDir, "Libraries"); string newIncludes = AddPathsToDirectories( vcp.IncludeDirectories, new string[] { cxxTestIncludePath, derefereeIncludePath }); vcp.IncludeDirectories = newIncludes; string newLibraries = AddPathsToDirectories( vcp.LibraryDirectories, new string[] { supportLibPath }); vcp.LibraryDirectories = newLibraries; vcp.CommitChanges(); }
public override ProjectProperties GetProjectData() { ThreadHelper.ThrowIfNotOnUIThread(); OutputLog.Log("Using manual configuration..."); var ret = new ProjectProperties(); Project project = EditorUtils.GetActiveProject(); VCProject prj = project == null ? null : project.Object as VCProject; VCConfiguration config = prj == null ? null : prj.ActiveConfiguration; VCPlatform platform = config == null ? null : config.Platform; if (platform != null) { AddCustomSettings(ret, new MacroEvaluatorVisualPlatform(platform)); } else { AddCustomSettings(ret, new MacroEvaluatorCMake()); } return(ret); }
VCPlatformWrapperVs2017 #endif (object wrapped) { _wrapped = wrapped as VCPlatform; }
public void DocumentSaved(EnvDTE.Document document) { QtProject qtPro = QtProject.Create(document.ProjectItem.ContainingProject); if (!HelperFunctions.IsQtProject(qtPro.VCProject)) { return; } VCFile file = (VCFile)((IVCCollection)qtPro.VCProject.Files).Item(document.FullName); if (file.Extension == ".ui") { if (QtVSIPSettings.AutoUpdateUicSteps() && !QtProject.HasUicStep(file)) { qtPro.AddUic4BuildStep(file); } return; } if (!HelperFunctions.HasSourceFileExtension(file.Name) && !HelperFunctions.HasHeaderFileExtension(file.Name)) { return; } if (HelperFunctions.HasQObjectDeclaration(file)) { if (!qtPro.HasMocStep(file)) { qtPro.AddMocStep(file); } } else { qtPro.RemoveMocStep(file); } if (HelperFunctions.HasSourceFileExtension(file.Name)) { string moccedFileName = "moc_" + file.Name; if (qtPro.IsMoccedFileIncluded(file)) { // exclude moc_foo.cpp from build //#if (VS2012 || VS2013 || VS2015) // Code copied here from 'GetFilesFromProject' // For some reason error CS1771 was generated from function call List <VCFile> tmpList = new System.Collections.Generic.List <VCFile>(); moccedFileName = HelperFunctions.NormalizeRelativeFilePath(moccedFileName); FileInfo fi = new FileInfo(moccedFileName); foreach (VCFile f in (IVCCollection)qtPro.VCProject.Files) { if (f.Name.ToLower() == fi.Name.ToLower()) { tmpList.Add(f); } } foreach (VCFile moccedFile in tmpList) { QtProject.ExcludeFromAllBuilds(moccedFile); } //#else /// foreach (VCFile moccedFile in qtPro.GetFilesFromProject(moccedFileName)) // QtProject.ExcludeFromAllBuilds(moccedFile); //#endif } else { // make sure that moc_foo.cpp isn't excluded from build //#if (VS2012 || VS2013 || VS2015) // Code copied here from 'GetFilesFromProject' // For some reason error CS1771 was generated from function call List <VCFile> moccedFiles = new System.Collections.Generic.List <VCFile>(); moccedFileName = HelperFunctions.NormalizeRelativeFilePath(moccedFileName); FileInfo fi = new FileInfo(moccedFileName); foreach (VCFile f in (IVCCollection)qtPro.VCProject.Files) { if (f.Name.ToLower() == fi.Name.ToLower()) { moccedFiles.Add(f); } } //#else // List<VCFile> moccedFiles = qtPro.GetFilesFromProject(moccedFileName); //#endif if (moccedFiles.Count > 0) { bool hasDifferentMocFilesPerConfig = QtVSIPSettings.HasDifferentMocFilePerConfig(qtPro.Project); bool hasDifferentMocFilesPerPlatform = QtVSIPSettings.HasDifferentMocFilePerPlatform(qtPro.Project); VCFilter generatedFiles = qtPro.FindFilterFromGuid(Filters.GeneratedFiles().UniqueIdentifier); foreach (VCFile fileInFilter in (IVCCollection)generatedFiles.Files) { if (fileInFilter.Name == moccedFileName) { foreach (VCFileConfiguration config in (IVCCollection)fileInFilter.FileConfigurations) { bool exclude = true; VCConfiguration vcConfig = config.ProjectConfiguration as VCConfiguration; if (hasDifferentMocFilesPerConfig && hasDifferentMocFilesPerPlatform) { VCPlatform platform = vcConfig.Platform as VCPlatform; string platformName = platform.Name; if (fileInFilter.RelativePath.ToLower().Contains(vcConfig.ConfigurationName.ToLower()) && fileInFilter.RelativePath.ToLower().Contains(platform.Name.ToLower())) { exclude = false; } } else if (hasDifferentMocFilesPerConfig) { if (fileInFilter.RelativePath.ToLower().Contains(vcConfig.ConfigurationName.ToLower())) { exclude = false; } } else if (hasDifferentMocFilesPerPlatform) { VCPlatform platform = vcConfig.Platform as VCPlatform; string platformName = platform.Name; if (fileInFilter.RelativePath.ToLower().Contains(platformName.ToLower())) { exclude = false; } } else { exclude = false; } if (config.ExcludedFromBuild != exclude) { config.ExcludedFromBuild = exclude; } } } } foreach (VCFilter filt in (IVCCollection)generatedFiles.Filters) { foreach (VCFile f in (IVCCollection)filt.Files) { if (f.Name == moccedFileName) { foreach (VCFileConfiguration config in (IVCCollection)f.FileConfigurations) { VCConfiguration vcConfig = config.ProjectConfiguration as VCConfiguration; string filterToLookFor = ""; if (hasDifferentMocFilesPerConfig) { filterToLookFor = vcConfig.ConfigurationName; } if (hasDifferentMocFilesPerPlatform) { VCPlatform platform = vcConfig.Platform as VCPlatform; if (!string.IsNullOrEmpty(filterToLookFor)) { filterToLookFor += '_'; } filterToLookFor += platform.Name; } if (filt.Name == filterToLookFor) { if (config.ExcludedFromBuild) { config.ExcludedFromBuild = false; } } else { if (!config.ExcludedFromBuild) { config.ExcludedFromBuild = true; } } } } } } } } } }
private static string GetDirectory(EnvDTE.Project project, string type) { // check for directory in following order: // - stored in project // - stored in cache // - retrieve from moc/uic steps // - globally defined default directory // - fallback on hardcoded directory if (project != null) { if (project.Globals.get_VariablePersists(type)) { return(HelperFunctions.NormalizeRelativeFilePath((string)project.Globals[type])); } else { try { if (type == Resources.mocDirKeyword && mocDirCache.Contains(project.FullName)) { return((string)mocDirCache[project.FullName]); } else if (type == Resources.uicDirKeyword && uicDirCache.Contains(project.FullName)) { return((string)uicDirCache[project.FullName]); } else if (type == Resources.rccDirKeyword && rccDirCache.Contains(project.FullName)) { return((string)rccDirCache[project.FullName]); } VCCustomBuildTool tool = null; string configName = null; string platformName = null; VCProject vcpro = (VCProject)project.Object; foreach (VCFile vcfile in (IVCCollection)vcpro.Files) { if ((type == Resources.mocDirKeyword && (HelperFunctions.HasHeaderFileExtension(vcfile.Name) || vcfile.Name.ToLower().EndsWith(".moc"))) || (type == Resources.uicDirKeyword && vcfile.Name.ToLower().EndsWith(".ui")) || (type == Resources.rccDirKeyword && vcfile.Name.ToLower().EndsWith(".qrc"))) { foreach (VCFileConfiguration config in (IVCCollection)vcfile.FileConfigurations) { tool = HelperFunctions.GetCustomBuildTool(config); configName = config.Name.Remove(config.Name.IndexOf('|')); VCConfiguration vcConfig = config.ProjectConfiguration as VCConfiguration; VCPlatform platform = vcConfig.Platform as VCPlatform; platformName = platform.Name; if (tool != null && (tool.CommandLine.ToLower().IndexOf("moc.exe") != -1 || (tool.CommandLine.ToLower().IndexOf("uic.exe") != -1) || (tool.CommandLine.ToLower().IndexOf("rcc.exe") != -1))) { break; } tool = null; } if (tool != null) { break; } } } if (tool != null) { string dir = null; int lastindex = tool.Outputs.LastIndexOf('\\'); if (tool.Outputs.LastIndexOf('/') > lastindex) { lastindex = tool.Outputs.LastIndexOf('/'); } if (lastindex == -1) { dir = "."; } else { dir = tool.Outputs.Substring(0, lastindex); } dir = dir.Replace("\"", ""); if (type == Resources.mocDirKeyword) { int index; if ((index = dir.ToLower().IndexOf(configName.ToLower())) != -1) { dir = dir.Replace(dir.Substring(index, configName.Length), "$(ConfigurationName)"); } if ((index = dir.ToLower().IndexOf(platformName.ToLower())) != -1) { dir = dir.Replace(dir.Substring(index, platformName.Length), "$(PlatformName)"); } mocDirCache.Add(project.FullName, HelperFunctions.NormalizeRelativeFilePath(dir)); } else if (type == Resources.uicDirKeyword) { uicDirCache.Add(project.FullName, HelperFunctions.NormalizeRelativeFilePath(dir)); } else if (type == Resources.rccDirKeyword) { rccDirCache.Add(project.FullName, HelperFunctions.NormalizeRelativeFilePath(dir)); } cleanUpCache(project); return(HelperFunctions.NormalizeRelativeFilePath(dir)); } } catch {} } } return(GetDirectory(type)); }
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"); } }
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); }
private void ProjectContextMenuItemCallback(object sender, EventArgs e) { var dte = this.dte.DTE; OutputWindow outputWindow = null; try { outputWindow = new OutputWindow(dte); OleMenuCommand menuCommand = sender as OleMenuCommand; if (menuCommand != null && dte != null) { Array selectedProjects = (Array)dte.ActiveSolutionProjects; //only support 1 selected project if (selectedProjects.Length == 1) { EnvDTE.Project project = (EnvDTE.Project)selectedProjects.GetValue(0); var vcproj = project.Object as VCProject; if (vcproj != null) { IVCCollection configs = (IVCCollection)vcproj.Configurations; VCConfiguration cfg = (VCConfiguration)vcproj.ActiveConfiguration; VCDebugSettings debug = (VCDebugSettings)cfg.DebugSettings; string command = null; string arguments = null; string workingDirectory = null; if (debug != null) { command = cfg.Evaluate(debug.Command); workingDirectory = cfg.Evaluate(debug.WorkingDirectory); arguments = cfg.Evaluate(debug.CommandArguments); } VCPlatform currentPlatform = (VCPlatform)cfg.Platform; string platform = currentPlatform == null ? null : currentPlatform.Name; if (platform != null) { platform = platform.ToLower(); if (platform.Contains("x64")) { platform = "x64"; } else if (platform.Contains("x86") || platform.Contains("win32")) { platform = "x86"; } else { throw new NotSupportedException("Platform is not supported."); } } else { cfg = (VCConfiguration)configs.Item("Debug|x64"); platform = "x64"; if (cfg == null) { throw new NotSupportedException("Cannot find x64 platform for project."); } } if (command == null || String.IsNullOrEmpty(command)) { command = cfg.PrimaryOutput; } if (command != null) { var solutionFolder = System.IO.Path.GetDirectoryName(dte.Solution.FileName); CoverageExecution executor = new CoverageExecution(dte, outputWindow); executor.Start( solutionFolder, platform, System.IO.Path.GetDirectoryName(command), System.IO.Path.GetFileName(command), workingDirectory, arguments); } } } } } catch (NotSupportedException ex) { if (outputWindow != null) { outputWindow.WriteLine("Error running coverage: {0}", ex.Message); } } catch (Exception ex) { if (outputWindow != null) { outputWindow.WriteLine("Unexpected code coverage failure; error: {0}", ex.ToString()); } } }
/****************************************************************/ #endregion /* Members */ #region LifeCycle /****************************************************************/ public VcProjInfo(string vcProjFile, string outFile, string[] projDependencies) { Console.WriteLine("Going to read project file '{0}'", vcProjFile); Console.WriteLine("aiming to write result to file '{0}'", outFile); if (projDependencies.GetLength(0) <= 0) { Console.WriteLine("With no dependencies."); } else { Console.WriteLine("With dependencies:"); foreach (String s in projDependencies) { Console.WriteLine("\t" + s); } //projDependencies.ToString()); } Console.WriteLine(""); // to visually separate output. //Init project name and .mak file name m_ProjectName = Path.GetFileNameWithoutExtension(vcProjFile); m_MakeFileName = outFile; m_VcProjDependencies = projDependencies; VCProjectEngine vcprojEngine = new VCProjectEngineObject(); try { //Init VCProject vcProj object m_VcProj = (VCProject)vcprojEngine.LoadProject(vcProjFile); } catch (Exception ex) { Console.WriteLine("Some errors occurred during project loading: {0}\n\n\n", ex.Message); Console.WriteLine("This tool knows to convert Visual Studio 2005 projects only\n"); Console.WriteLine("For converting Visual Studio 2008 projects, compile this tool on VS2008 \n"); Console.WriteLine("add Microsoft.VisualStudio.VCProjectEngine9.0.0 reference\n"); } //Init vcproj configurations list m_ConfigCollection = (IVCCollection)m_VcProj.Configurations; //Init targets dictionary (Key is configuration name, Value is VcTargetType object m_TargetDictionary = new Dictionary <string, VcTargetType>(); foreach (VCConfiguration config in m_ConfigCollection) { m_TargetDictionary.Add(config.ConfigurationName, new VcTargetType(config)); } //Init number of vcProj configurations m_NumOfConfigs = m_ConfigCollection.Count; //Init platform name of vcProj IVCCollection platformCollection = (IVCCollection)m_VcProj.Platforms; VCPlatform platform = (VCPlatform)platformCollection.Item(1); m_PlatfromName = platform.Name; //Init Filters collection m_FileFilterCollection = (IVCCollection)m_VcProj.Filters; Console.WriteLine("Creating file " + m_MakeFileName + "..."); //Open StreamWriter for writing into makFileName m_MakFWriter = new StreamWriter(m_MakeFileName); m_SRCGroups = "SRCS="; }
private ProjectProperties GetProjectData() { ThreadHelper.ThrowIfNotOnUIThread(); Solution solution = GetActiveSolution(); if (solution == null) { return(null); } Project project = GetActiveProject(); if (project == null) { return(null); } 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; ProjectProperties ret = new ProjectProperties(); ret.Target = midl != null && midl.TargetEnvironment == midlTargetEnvironment.midlTargetWin32 ? ProjectProperties.TargetType.x86 : ProjectProperties.TargetType.x64; //Working directory (always local to processed file) ret.WorkingDirectory = Path.GetDirectoryName(project.FullName); //TODO ~ ramonv ~ find a way to extract the /std value //Include dirs / files and preprocessor AppendMSBuildStringToList(ret.IncludeDirectories, platform.Evaluate(platform.IncludeDirectories)); AppendProjectProperties(ret, vctools.Item("VCCLCompilerTool") as VCCLCompilerTool, vctools.Item("VCNMakeTool") as VCNMakeTool, platform); try { //Get settings from the single file (this might fail badly if there are no settings to catpure) var applicationObject = ServiceProvider.GetService(typeof(DTE)) as EnvDTE80.DTE2; Assumes.Present(applicationObject); ProjectItem item = applicationObject.ActiveDocument.ProjectItem; VCFile vcfile = item.Object as VCFile; IVCCollection fileCfgs = (IVCCollection)vcfile.FileConfigurations; VCFileConfiguration fileConfig = fileCfgs.Item(config.Name) as VCFileConfiguration; AppendProjectProperties(ret, fileConfig.Tool as VCCLCompilerTool, fileConfig.Tool as VCNMakeTool, platform); } catch (Exception) {} SolutionSettings customSettings = SettingsManager.Instance.Settings; if (customSettings != null) { AppendMSBuildStringToList(ret.IncludeDirectories, platform.Evaluate(customSettings.AdditionalIncludeDirs)); AppendMSBuildStringToList(ret.ForceIncludes, platform.Evaluate(customSettings.AdditionalForceIncludes)); AppendMSBuildStringToList(ret.PrepocessorDefinitions, platform.Evaluate(customSettings.AdditionalPreprocessorDefinitions)); ret.ExtraArguments = platform.Evaluate(customSettings.AdditionalCommandLine); ret.ShowWarnings = customSettings.EnableWarnings; } //Exclude directories RemoveMSBuildStringFromList(ret.IncludeDirectories, platform.Evaluate(platform.ExcludeDirectories)); return(ret); }
private void AppendProjectProperties(ProjectProperties properties, VCCLCompilerTool cl, VCNMakeTool nmake, VCPlatform platform) { ThreadHelper.ThrowIfNotOnUIThread(); if (cl != null) { AppendMSBuildStringToList(properties.IncludeDirectories, platform.Evaluate(cl.AdditionalIncludeDirectories)); AppendMSBuildStringToList(properties.ForceIncludes, platform.Evaluate(cl.ForcedIncludeFiles)); AppendMSBuildStringToList(properties.PrepocessorDefinitions, platform.Evaluate(cl.PreprocessorDefinitions)); } else if (nmake != null) { AppendMSBuildStringToList(properties.IncludeDirectories, platform.Evaluate(nmake.IncludeSearchPath)); AppendMSBuildStringToList(properties.ForceIncludes, platform.Evaluate(nmake.ForcedIncludes)); AppendMSBuildStringToList(properties.PrepocessorDefinitions, platform.Evaluate(nmake.PreprocessorDefinitions)); } }
public MacroEvaluatorVisualPlatform(VCPlatform platform) { Platform = platform; }