private void CleanLibraries(VCProject oProject, VCConfiguration oConfiguration) { VCLinkerTool Linker = (VCLinkerTool)((IVCCollection)oConfiguration.Tools).Item("VCLinkerTool"); if (Linker != null) { List<String> Libraries = GetLibraries(Linker); for (int i=0; i<Libraries.Count; i++) { List<String> NewLibs = Libraries.GetRange(i, 1); Libraries.RemoveRange(i, 1); Linker.AdditionalDependencies = String.Join(" ", Libraries.ToArray()); oProject.Save(); if (BuildOperations.BuildConfiguration(oProject, oConfiguration)) { i--; mLogger.PrintMessage("Library " + String.Join(" ", NewLibs.ToArray()) + " in project '" + oProject.Name + "'has been found unnesessary and removed."); } else { Libraries.InsertRange(i, NewLibs); } } Libraries.Sort(); Linker.AdditionalDependencies = String.Join(" ", Libraries.ToArray()); oProject.Save(); } }
public void RemoveUnnesessaryLibraries(VCProject oProject) { mLogger.PrintHeaderMessage("Removing additional dependencies for project '" + oProject.Name + "'"); try { DTE2 oApp = (DTE2)((((Project)(oProject).Object)).DTE); mDependencyCleaner.CleanDependencies((Solution2)oApp.Solution); IVCCollection oConfigurations = (IVCCollection)oProject.Configurations; foreach (VCConfiguration oConfiguration in oConfigurations) { if (!BuildOperations.BuildConfiguration(oProject, oConfiguration)) { mLogger.PrintError("ERROR: Project '" + oProject.Name + "' configuration '" + oConfiguration.Name + "|" + oConfiguration.Platform + "' must be in a buildable condition before you proceed! Aborting..."); continue; } else { CleanLibraries(oProject, oConfiguration); } } mDependencyCleaner.RebuildDependecies((Solution2)oApp.Solution); } catch (Exception) { } mLogger.PrintHeaderMessage("Finished removing additional dependencies for project '" + oProject.Name + "'"); }
/// <summary> /// Constructor /// </summary> public ProjectParser_CPP(VCProject vcProject, string solutionRootFolder) { try { m_vcProject = vcProject; m_solutionRootFolder = solutionRootFolder; // We get the project name... m_projectInfo.Name = Utils.call(() => (m_vcProject.Name)); if (MakeItSoConfig.Instance.ignoreProject(m_projectInfo.Name) == true) Log.log("- project " + m_projectInfo.Name + "ignored"); else { Log.log("- parsing project " + m_projectInfo.Name); // and parse the project... parseProject(); Log.log(" - done"); } } catch (Exception ex) { Log.log(String.Format(" - FAILED ({0})", ex.Message)); } }
public UnityManager(VCProject vcproject) { this.Project = vcproject.Object as Project; this.VCProject = vcproject; this.VCConfig = Connect.GetActiveVCConfig(this.VCProject); this.Filter = new UnityFilter(this.Project); }
private QtProject(EnvDTE.Project project) { if (project == null) throw new Qt4VSException(SR.GetString("QtProject_CannotConstructWithoutValidProject")); envPro = project; dte = envPro.DTE; vcPro = envPro.Object as VCProject; }
public UnityForm(VCProject project) { this.UnityManager = new UnityManager(project); this.Cpps = new DataTable(); this.Cpps.Columns.Add("Cpp"); this.Cpps.Columns.Add("VirtualPath"); this.Cpps.Columns.Add("Unity"); this.Cpps.Columns.Add("Condition"); this.Cpps.Columns.Add("Size", typeof(long)); this.InitializeComponent(); }
private static void MakeFilesRelativePath(VCProject vcproj, List <string> files, string path) { for (var i = 0; i < files.Count; i++) { var relPath = string.Empty; if (files[i].IndexOf(':') != 1) { relPath = HelperFunctions.GetRelativePath(path, vcproj.ProjectDirectory + "\\" + files[i]); } else { relPath = HelperFunctions.GetRelativePath(path, files[i]); } files[i] = HelperFunctions.ChangePathFormat(relPath); } }
public async Task <ConanProject> ExtractConanProject(VCProject vcProject) { var projectPath = await ConanPathHelper.GetNearestConanfilePath(vcProject.ProjectDirectory); var project = new ConanProject { Path = projectPath, InstallPath = Path.Combine(projectPath, "conan") }; foreach (VCConfiguration configuration in vcProject.Configurations) { project.Configurations.Add(ExtractConanConfiguration(configuration)); } return(project); }
/// <summary> /// Parses the project passed in. /// </summary> private void parseProject(EnvDTE.Project project) { // We get the project name... string projectName = Utils.call(() => (project.Name)); // We check if the project is loaded in the solution if (Utils.call(() => project.Object) == null && Utils.call(() => project.UniqueName) != "<MiscFiles>") { Log.log("Warning: " + projectName + " is currently unloaded in the solution! No conversion performed"); return; } // We check if this project is a kind we know how to convert... string strProjectType = Utils.call(() => (project.Kind)); ProjectType eProjectType = convertProjectTypeToEnum(strProjectType); switch (eProjectType) { // It's a C++ project... case ProjectType.CPP_PROJECT: { // We get the Visual Studio project, parse it and store the // parsed project in our collection of results... VCProject vcProject = Utils.call(() => (project.Object as VCProject)); ProjectParser_CPP parser = new ProjectParser_CPP(vcProject, m_parsedSolution.RootFolderAbsolute); m_parsedSolution.addProjectInfo(projectName, parser.Project); } break; // It's a C# project... case ProjectType.CSHARP_PROJECT: { // We get the Visual Studio project, parse it and store the // parsed project in our collection of results... VSProject2 vsProject = Utils.call(() => (project.Object as VSProject2)); ProjectParser_CSharp parser = new ProjectParser_CSharp(vsProject, m_parsedSolution.RootFolderAbsolute); m_parsedSolution.addProjectInfo(projectName, parser.Project); } break; } // We parse the project's items, to check whether there are any nested // projects... EnvDTE.ProjectItems projectItems = Utils.call(() => (project.ProjectItems)); parseProjectItems(projectItems); }
public void AddGeneratedFiles(EnvDTE.Project dteProject, EnvDTE.Configuration config, String filterName, List <String> paths, bool generatedFilesPerConfiguration) { VCProject project = dteProject.Object as VCProject; VCFilter filter = FindOrCreateFilter(project, filterName); if (generatedFilesPerConfiguration) { filter = FindOrCreateFilter(filter, config.PlatformName); filter = FindOrCreateFilter(filter, config.ConfigurationName); } String configurationName = config.ConfigurationName; String platformName = config.PlatformName; foreach (String path in paths) { VCFile file = filter.AddFile(path); // // Exclude the file from all other configurations // if (generatedFilesPerConfiguration) { foreach (VCFileConfiguration c in file.FileConfigurations) { if (!c.ProjectConfiguration.ConfigurationName.Equals(configurationName) || !c.ProjectConfiguration.Platform.Name.Equals(platformName)) { c.ExcludedFromBuild = true; } } } try { // // Remove the file otherwise it will be considered up to date. // File.Delete(path); } catch (Exception) { } } }
private void AnalyseNextProject() { ts.TraceInformation("AnalyseNextProject #project still to be processed " + _vcProjectQueue.Count); if (_vcProjectQueue.Count == 0) { OnStopSolution(false); } else { VCProject vcProject = _vcProjectQueue.Dequeue(); _report.NextProject(); ts.TraceInformation("AnalyseNextProject " + _report.ProjectCurrent.Name); ts.TraceInformation("AnalyseNextProject " + vcProject.Name); DoAnalyzeProject(vcProject); } }
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> /// Parses the project passed in. /// </summary> private void parseProject(EnvDTE.Project project) { // We get the project name... string projectName = Utils.call(() => (project.Name)); if (MakeItSoConfig.Instance.ignoreProject(projectName)) { Log.log("- Ignoring project: " + projectName); return; } // We check if this project is a kind we know how to convert... string strProjectType = Utils.call(() => (project.Kind)); ProjectType eProjectType = convertProjectTypeToEnum(strProjectType); switch (eProjectType) { // It's a C++ project... case ProjectType.CPP_PROJECT: { // We get the Visual Studio project, parse it and store the // parsed project in our collection of results... VCProject vcProject = Utils.call(() => (project.Object as VCProject)); ProjectParser_CPP parser = new ProjectParser_CPP(vcProject, m_parsedSolution.RootFolderAbsolute); m_parsedSolution.addProjectInfo(projectName, parser.Project); } break; // It's a C# project... case ProjectType.CSHARP_PROJECT: { // We get the Visual Studio project, parse it and store the // parsed project in our collection of results... VSProject2 vsProject = Utils.call(() => (project.Object as VSProject2)); ProjectParser_CSharp parser = new ProjectParser_CSharp(vsProject, m_parsedSolution.RootFolderAbsolute); m_parsedSolution.addProjectInfo(projectName, parser.Project); } break; } // We parse the project's items, to check whether there are any nested // projects... EnvDTE.ProjectItems projectItems = Utils.call(() => (project.ProjectItems)); parseProjectItems(projectItems); }
/// <summary> /// This recursive function will add project and all its dependencies in a sorted way /// </summary> /// <param name="vcp"></param> /// <param name="projects"></param> private void AddProject(VCProject vcp, List <VCProject> projects) { if (vcp != null && !projects.Contains(vcp)) { //check direct references foreach (VCReference r in vcp.VCReferences) { VCProjectReference vcref = r as VCProjectReference; if (vcref != null && vcref.ReferencedProject != null) { AddProject(vcref.ReferencedProject.Object, projects); } } //TODO: this only gets direct references to other projects, but does not check dependencies or project references set by other means //this might need to be evaluated by explicitly loading the microsoft.build.evaluation.project and checking its references... projects.Add(vcp); } }
static private void ParseLibraries(StreamWriter streamWriter, VCProject project, VCLinkerTool tool, int indent) { var indentText = Indent(indent); var dependencies = tool.AdditionalDependencies; if (dependencies != "") { var items = dependencies.Split(' '); streamWriter.WriteLine(indentText + "target_link_libraries({0}", project.Name); foreach (var item in items) { streamWriter.WriteLine(Indent(indent + 1) + "{0}", item.Replace(".lib", "")); } streamWriter.WriteLine(indentText + ")"); streamWriter.WriteLine(); } }
private IEnumerator GetVCProjectRefs() { IVCCollection projects = null; // we must use this way around, since the projects collection from the applicationObject does not work // Google News says this is a confirmed VS bug for (int i = 1; i < 2; i++) { try { VCProject vcP = (VCProject)_applicationObject.Solution.Item(i).Object; if (vcP != null) { VCProjectEngine projEngine = (VCProjectEngine)vcP.VCProjectEngine; if (projEngine != null) { projects = (IVCCollection)projEngine.Projects; if (projects != null) { break; } else { Debug(String.Format("Reading item {0} not possible, projects==null", i)); } } else { Debug(String.Format("Reading item {0} not possible, projEngine==null", i)); } } else { Debug(String.Format("Reading item {0} not possible, vcP==null", i)); } } catch (Exception e) { Debug(String.Format("Reading item {0} not possible", i)); Debug(e); } } return(projects.GetEnumerator()); }
private static VCProject InternalGetVCProject(ProjectItems items, Guid id, IServiceProvider serviceProvider) { ThreadHelper.ThrowIfNotOnUIThread(); foreach (ProjectItem item in items) { Project pj = item.Object as Project; if (pj == null && item.SubProject != null) { pj = item.SubProject as Project; } if (pj != null) { if (pj.GetProjectGuid(serviceProvider) == id) { Object opj = pj.Object; if (opj == null) { return(null); } return(opj as VCProject); } } if (item.ProjectItems != null) { VCProject vcpj1 = InternalGetVCProject(item.ProjectItems, id, serviceProvider); if (vcpj1 != null) { return(vcpj1); } } else if (pj != null && pj.ProjectItems != null) { VCProject vcpj2 = InternalGetVCProject(pj.ProjectItems, id, serviceProvider); if (vcpj2 != null) { return(vcpj2); } } } return(null); }
static public Queue <VCFile> CreateFileQueue(VCProject vcProject) { ts.TraceInformation("CreateFileQueue"); Queue <VCFile> fileQueue = new Queue <VCFile>(); var vcFileCollection = (IVCCollection)vcProject.Files; if (vcFileCollection == null) { ts.TraceData(TraceEventType.Verbose, 1, "CreateFileList cannot get vc file collection"); return(null); } ts.TraceInformation("CreateFileQueue #vcFileCollection " + vcFileCollection.Count); foreach (VCFile vcFile in vcFileCollection) { try { VCFileConfiguration vcFileConfiguration = DTE2Utils.GetVcFileConfiguration( vcFile, DTE2Utils.GetVcConfiguratioForVcProject(vcProject)); if (vcFileConfiguration != null) { if ((vcFileConfiguration.ExcludedFromBuild == false) && (vcFile.FileType == eFileType.eFileTypeCppCode)) { ts.TraceData(TraceEventType.Verbose, 1, "CreateFileList add " + vcFile.FullPath); fileQueue.Enqueue(vcFile); } else { ts.TraceData(TraceEventType.Verbose, 1, "CreateFileList exclude " + vcFile.FullPath); } } } catch (Exception exception) { ts.TraceData(TraceEventType.Verbose, 1, "CreateFileList exception " + exception.Message); } } ts.TraceInformation("CreateFileList project " + vcProject.Name + " #files " + fileQueue.Count); return(fileQueue); }
/// <summary> /// Removes custom build data from .fx files. It actually just sets the tool command line /// and outputs to an empty string. /// </summary> /// <param name="project">Project to remove custom build stuff from</param> public static void RemoveCustomBuildToolsFromFxFiles(Project project) { if (!(project.Object is VCProject)) { return; } VCProject vcProject = project.Object as VCProject; foreach (var item in vcProject.Files) { if (item is VCFile) { VCFile file = item as VCFile; if (!Path.HasExtension(file.Name) || Path.GetExtension(file.Name) != ".fx") { continue; } foreach (VCFileConfiguration fileConfig in file.FileConfigurations) { if (fileConfig.Tool is VCCustomBuildTool) { VCCustomBuildTool customTool = fileConfig.Tool as VCCustomBuildTool; if (customTool == null) { continue; } try { customTool.Outputs = String.Empty; customTool.CommandLine = String.Empty; } catch (Exception) { continue; } } } } } }
private void DisableConfigForEachFile(ref VCProject actVCP, string BuildMode) { Log("\tFile Specific Configuration"); 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) { try { // Preprocessed headers VCFileConfiguration fileConfiguration = (VCFileConfiguration)(((IVCCollection)file.FileConfigurations).Item(BuildMode)); // Access the release configuration of this file. VCCLCompilerTool compilerTool = (VCCLCompilerTool)fileConfiguration.Tool; // Get the compiler tool associated with this file. if (compilerTool.AdditionalOptions != null) { string newargs = DisableCodeCoverageCommandLineArguments(compilerTool.AdditionalOptions); if (compilerTool.AdditionalOptions != newargs) { compilerTool.AdditionalOptions = newargs; Log("\t\tAdditional command line arguments set to '" + newargs + "' for the file '" + file.Name + "'"); } } } catch (Exception e) { Debug(e); } } } catch (Exception e) { Debug(e); } } } }
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 += ";\n" + libs32Debug.Aggregate((sum, value) => { return(sum + ";\n\"" + value + "\""); }); } else if (config.Name == "Debug|x64" && libs64Debug.Count > 0) { linker.AdditionalDependencies += ";\n" + libs64Debug.Aggregate((sum, value) => { return(sum + ";\n\"" + value + "\""); }); } else if (config.Name == "Release|Win32" && libs32Release.Count > 0) { linker.AdditionalDependencies += ";\n" + libs32Release.Aggregate((sum, value) => { return(sum + ";\n\"" + value + "\""); }); } else if (config.Name == "Release|x64" && libs64Release.Count > 0) { linker.AdditionalDependencies += ";\n" + libs64Debug.Aggregate((sum, value) => { return(sum + ";\n\"" + value + "\""); }); } } } } }
static public VCConfiguration GetVcConfiguratioForVcProject(VCProject vcProject) { ts.TraceData(TraceEventType.Verbose, 1, "GetVcConfiguratioForVcProject project " + vcProject.Name); Project project = vcProject.Object as Project; if ((project == null) || (project.ConfigurationManager == null)) { return(null); } Configuration configuration = project.ConfigurationManager.ActiveConfiguration; if (configuration == null) { return(null); } ts.TraceData(TraceEventType.Verbose, 1, "GetVcConfiguration configuration name " + configuration.ConfigurationName); return(GetVcConfiguration(vcProject, configuration)); }
private void QueueProject(List <QueueEntry> queue, VCProject src) { foreach (var item in src.Items) { var vcfilter = item as VCFilter; if (vcfilter != null) { QueueFiltersRecursive(queue, vcfilter); } var vcfile = item as VCFile; if (vcfile != null && vcfile.Parent as VCFilter != null) { queue.Add(new QueueEntry() { _vcfile = vcfile, _vcfilter = vcfile.Parent as VCFilter }); } } }
public void AnalyzeProject(Solution solution, VCProject vcProject) { try { ts.TraceInformation("AnalyzeProject " + vcProject.Name); _analyzeType = AnalyzeType.PROJECT; _vcProject = vcProject; _report = Reporting.ReportFactory.CreateReportForVCProject(solution, vcProject); OnStartAnalyze(); DoAnalyzeProject(vcProject); } catch (Exception exception) { ts.TraceData(TraceEventType.Error, 1, "AnalyzeProject exception: " + exception.Message); OnStopProject(true); } }
/// <summary> /// Constructor /// </summary> public ProjectParser_CPP(VCProject vcProject, string solutionRootFolder) { try { m_vcProject = vcProject; m_solutionRootFolder = solutionRootFolder; // We get the project name... m_projectInfo.Name = Utils.call(() => (m_vcProject.Name)); Log.log("- parsing project " + m_projectInfo.Name); // and parse the project... parseProject(); Log.log(" - done"); } catch (Exception ex) { Log.log(String.Format(" - FAILED ({0})", ex.Message)); } }
/// <summary> /// Constructor /// </summary> public ProjectParser_CPP(VCProject vcProject, string solutionRootFolder) { try { m_vcProject = vcProject; m_solutionRootFolder = solutionRootFolder; // We get the project name... m_projectInfo.Name = Utils.call(() => (m_vcProject.Name)); Log.log("- parsing project " + m_projectInfo.Name); // and parse the project... parseProject(); Log.log(" - done"); } catch (Exception ex) { Log.log(String.Format(" - FAILED ({0})", ex.Message)); } }
private void OnQRCFileSaved(string fileName) { foreach (EnvDTE.Project project in HelperFunctions.ProjectsInSolution(dte)) { VCProject vcProject = project.Object as VCProject; if (vcProject == null || vcProject.Files == null) { continue; } VCFile vcFile = (VCFile)((IVCCollection)vcProject.Files).Item(fileName); if (vcFile == null) { continue; } QtProject qtProject = QtProject.Create(project); qtProject.UpdateRccStep(vcFile, null); } }
static private void AddProject(Reporting.Solution solution, VCProject vcProject) { //Project Queue <VCFile> vcFileQueue = DTE2Utils.CreateFileQueue(vcProject); Reporting.Project project = solution.CreateProject(); EnvDTE.Project dteProject = vcProject.Object as EnvDTE.Project; if (dteProject != null) { project.Name = dteProject.Name; } foreach (VCFile vcFile in vcFileQueue) { Reporting.File file = project.CreateFile(); file.Name = vcFile.Name; file.FullPath = vcFile.FullPath; } }
public static IEnumerable <VCFile> GetAllVCFiles(this VCProject col) { IVCCollection files = col.Files; foreach (VCFile vcfile in files) { yield return(vcfile); } IVCCollection filters = col.Filters; foreach (VCFilter vcfilter in filters) { var sfiles = vcfilter.GetAllVCFiles(); foreach (VCFile svcfile in sfiles) { yield return(svcfile); } } yield break; }
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); } }
public static bool IsVcProjectSelected(DTE2 dte2) { try { Solution solution = dte2.Solution; Array projects = (Array)dte2.ActiveSolutionProjects; if ((projects != null) && (projects.Length > 0)) { Project project = (Project)projects.GetValue(0); VCProject vcProject = project.Object as VCProject; if (vcProject != null) { return(true); } } } catch (Exception) { } return(false); }
private void Project_ImportUnity(VCProject project, XmlNode xProject) { if (project == null) { return; } UnityManager um = new UnityManager(project); um.Filter.Name = xProject.Attributes["UnityFilterName"].Value; um.Filter.Path = xProject.Attributes["UnityFilterPath"].Value; um.Filter.SaveSettings(); um.Unities = new Dictionary <string, Unity>(); foreach (XmlNode xUnity in xProject.ChildNodes) { if (xUnity.Name != "Unity") { throw new Exception("Invalid xml file format!"); } Unity unity = new Unity(xUnity.Attributes["Name"].Value); um.Unities.Add(unity.Name, unity); foreach (XmlNode xCpp in xUnity.ChildNodes) { if (xCpp.Name != "Cpp") { throw new Exception("Invalid xml file format!"); } Cpp cpp = new Cpp(xCpp.Attributes["Name"].Value); cpp.Condition = xCpp.Attributes["Condition"].Value; unity.Cpps.Add(cpp.Name, cpp); } } um.SaveUnities(); }
public void addIncludePathsToVCProject(VCProject project) { var includes = includePaths.Aggregate((sum, value) => { return(sum + ";\n\"" + value + "\""); }); foreach (VCConfiguration config in project.Configurations) { IVCCollection tools = config.Tools; foreach (Object tool in tools) { if (tool is VCCLCompilerTool) { VCCLCompilerTool compilerTool = (VCCLCompilerTool)tool; var currentIncludes = compilerTool.AdditionalIncludeDirectories; compilerTool.AdditionalIncludeDirectories = currentIncludes + ";\n" + includes; } } } }
public bool SetupSliceFilter(EnvDTE.Project dteProject) { VCProject project = dteProject.Object as VCProject; foreach (VCFilter f in project.Filters) { if (f.Name.Equals("Slice Files")) { if (string.IsNullOrEmpty(f.Filter) || !f.Filter.Equals("ice")) { f.Filter = "ice"; return(true); } return(false); } } VCFilter filter = project.AddFilter("Slice Files"); filter.Filter = "ice"; return(true); }
/// <summary> /// Given a generic project, checks that it is a Visual C project, and /// extracts the active VCConfiguration object. /// </summary> /// <param name="proj">Generic project object.</param> /// <returns>The active configuration, or null if failure.</returns> public static VCConfiguration GetActiveVCConfiguration(Project proj) { if (!IsVisualCProject(proj)) { return(null); } VCProject vcproj = (VCProject)proj.Object; IVCCollection configs = vcproj.Configurations; Configuration active = proj.ConfigurationManager.ActiveConfiguration; foreach (VCConfiguration config in configs) { if (config.ConfigurationName == active.ConfigurationName && config.Platform.Name == active.PlatformName) { return(config); } } return(null); }
private void ProjItemCallback(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); List <VCProject> projects = new List <VCProject>(); Dte.ExecuteCommand("File.SaveAll"); foreach (var item in Dte.SelectedItems) { EnvDTE.Project proj = (item as SelectedItem).Project; if (proj != null) { VCProject vcp = proj.Object as VCProject; AddProject(vcp, projects); } } var config = Dte.Solution.SolutionBuild.ActiveConfiguration as EnvDTE80.SolutionConfiguration2; RequestBuildProjects(config, projects); }
/// <summary> /// Get the filter that is represented by the specified path /// </summary> private static VCFilter GetFilter(VCProject vcProject, string folderPath, bool createIfNotExists) { Debug.Assert(!String.IsNullOrEmpty(folderPath)); string[] paths = folderPath.Split(Path.DirectorySeparatorChar); // recursively walks the folder path to get the last folder dynamic parent = vcProject; foreach (string path in paths) { VCFilter childFilter = null; foreach (VCFilter child in parent.Filters) { if (child.Name.Equals(path, StringComparison.OrdinalIgnoreCase)) { childFilter = child; break; } } if (childFilter == null) { if (createIfNotExists) { // if a child folder doesn't already exist, create it childFilter = parent.AddFilter(path); } else { return null; } } parent = childFilter; } return (VCFilter)parent; }
public static void SyncIncludeFiles(VCProject vcproj, List<string> priFiles, List<string> projFiles, EnvDTE.DTE dte) { SyncIncludeFiles(vcproj, priFiles, projFiles, dte, false, null); }
public ProFileContent(VCProject proj) { export = true; vcproj = proj; options = new List<ProFileOption>(); }
private static void MakeFilesRelativePath(VCProject vcproj, List<string> files, string path) { for(int i=0; i<files.Count; i++) { string relPath; if (files[i].IndexOf(":") != 1) relPath = HelperFunctions.GetRelativePath(path, vcproj.ProjectDirectory + "\\" + (string)files[i]); else relPath = HelperFunctions.GetRelativePath(path, (string)files[i]); files[i] = HelperFunctions.ChangePathFormat(relPath); } }
public static bool IsVcProject(VCProject proj) { return proj != null; }
public static void SyncIncludeFiles(VCProject vcproj, List<string> priFiles, List<string> projFiles, EnvDTE.DTE dte, bool flat, FakeFilter fakeFilter) { List<string> cmpPriFiles = new List<string>(priFiles.Count); foreach (string s in priFiles) cmpPriFiles.Add(HelperFunctions.NormalizeFilePath(s).ToLower()); cmpPriFiles.Sort(); List<string> cmpProjFiles = new List<string>(projFiles.Count); foreach (string s in projFiles) cmpProjFiles.Add(HelperFunctions.NormalizeFilePath(s).ToLower()); QtProject qtPro = QtProject.Create(vcproj); Hashtable filterPathTable = new Hashtable(17); Hashtable pathFilterTable = new Hashtable(17); if (!flat && fakeFilter != null) { VCFilter rootFilter = qtPro.FindFilterFromGuid(fakeFilter.UniqueIdentifier); if (rootFilter == null) qtPro.AddFilterToProject(Filters.SourceFiles()); CollectFilters(rootFilter, null, ref filterPathTable, ref pathFilterTable); } // first check for new files foreach(string file in cmpPriFiles) { if (cmpProjFiles.IndexOf(file) > -1) continue; if (flat) { vcproj.AddFile(file); // the file is not in the project } else { string path = HelperFunctions.GetRelativePath(vcproj.ProjectDirectory, file); if (path.StartsWith(".\\")) path = path.Substring(2); int i = path.LastIndexOf('\\'); if (i > -1) path = path.Substring(0, i); else path = "."; if (pathFilterTable.Contains(path)) { VCFilter f = pathFilterTable[path] as VCFilter; f.AddFile(file); continue; } VCFilter filter = BestMatch(path, pathFilterTable); string filterDir = filterPathTable[filter] as string; string name = path; if (!name.StartsWith("..") && name.StartsWith(filterDir)) name = name.Substring(filterDir.Length + 1); VCFilter newFilter = filter.AddFilter(name) as VCFilter; newFilter.AddFile(file); filterPathTable.Add(newFilter, path); pathFilterTable.Add(path, newFilter); } } // then check for deleted files foreach (string file in cmpProjFiles) { if (cmpPriFiles.IndexOf(file) == -1) { // the file is not in the pri file // (only removes it from the project, does not del. the file) FileInfo info = new FileInfo(file); HelperFunctions.RemoveFileInProject(vcproj, file); Messages.PaneMessage(dte, "--- (Importing .pri file) file: " + info.Name + " does not exist in .pri file, move to " + vcproj.ProjectDirectory + "Deleted"); } } }
public static void removeAddons(VCProject vcproject, string ofRoot, IEnumerable<string> addonsNames) { // Parse current settings in the project List<string> includes32Debug = new List<string>(); List<string> includes32Release = new List<string>(); List<string> includes64Debug = new List<string>(); List<string> includes64Release = new List<string>(); List<string> libs32Debug = new List<string>(); List<string> libs32Release = new List<string>(); List<string> libs64Debug = new List<string>(); List<string> libs64Release = new List<string>(); foreach (VCConfiguration config in vcproject.Configurations) { IVCCollection tools = config.Tools; foreach (Object tool in tools) { if (config.Name == "Debug|Win32") { ParseProjectConfig(tool, includes32Debug, libs32Debug); } else if(config.Name == "Release|Win32") { ParseProjectConfig(tool, includes32Release, libs32Release); } else if (config.Name == "Debug|x64") { ParseProjectConfig(tool, includes64Debug, libs64Debug); } else if (config.Name == "Release|x64") { ParseProjectConfig(tool, includes64Release, libs64Release); } } } // Retrieve all addons config var addons = addonsNames.Select((addonName) => { return new Addon(ofRoot, addonName, vcproject.ProjectDirectory); }); // Filter out the addons to remove config from the existing one foreach(var addon in addons) { libs32Debug = libs32Debug.Except(addon.getLibs32Debug()).ToList(); libs32Release = libs32Release.Except(addon.getLibs32Release()).ToList(); libs64Debug = libs64Debug.Except(addon.getLibs64Debug()).ToList(); libs64Release = libs32Release.Except(addon.getLibs64Release()).ToList(); includes32Debug = includes32Debug.Except(addon.getIncludes()).ToList(); includes32Release = includes32Release.Except(addon.getIncludes()).ToList(); includes64Debug = libs64Debug.Except(addon.getIncludes()).ToList(); includes64Release = includes32Release.Except(addon.getIncludes()).ToList(); } // Add the config back to the project: foreach (VCConfiguration config in vcproject.Configurations) { IVCCollection tools = config.Tools; foreach (Object tool in tools) { if (config.Name == "Debug|Win32") { ListToProjectConfig(tool, includes32Debug, libs32Debug); } else if (config.Name == "Release|Win32") { ListToProjectConfig(tool, includes32Release, libs32Release); } else if (config.Name == "Debug|x64") { ListToProjectConfig(tool, includes64Debug, libs64Debug); } else if (config.Name == "Release|x64") { ListToProjectConfig(tool, includes64Release, libs64Release); } } } // Find addons filter and remove the specified addons from it VCFilter addonsFolder = null; List<VCFilter> addonsFiltersToRemove = new List<VCFilter>(); IVCCollection filters = vcproject.Filters; foreach (var filter in filters) { if (filter is VCFilter) { if (((VCFilter)filter).Name == "addons") { addonsFolder = ((VCFilter)filter); foreach(var addon in addonsFolder.Filters) { if(addon is VCFilter && addonsNames.Contains(((VCFilter)addon).Name)) { addonsFiltersToRemove.Add((VCFilter)addon); } } break; } } } foreach(var addon in addonsFiltersToRemove) { addonsFolder.RemoveFilter(addon); } }
/// <summary> /// compile a single VCFile, do nothing with the OBJ /// </summary> public bool CompileSingleFile(VCFile vcFile, VCProject vcProject, VCConfiguration vcCfg, String additionalCmds = "") { CVXBuildSystem buildSystem; try { buildSystem = new CVXBuildSystem(_vsOutputWindow, _outputPane); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "ClangVSx Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } try { return buildSystem.CompileSingleFile(vcFile, vcProject, vcCfg, additionalCmds); } catch (System.Exception ex) { WriteToOutputPane("Exception During File Compile : \n" + ex.Message + "\n"); } return false; }
/// <summary> /// Return true if the project is a Qt5 project, otherwise false. /// </summary> /// <param name="proj">project</param> /// <returns></returns> public static bool IsQt5Project(VCProject proj) { if (!IsQMakeProject(proj)) return false; EnvDTE.Project envPro = proj.Object as EnvDTE.Project; if (envPro.Globals == null || envPro.Globals.VariableNames == null) return false; foreach (string global in envPro.Globals.VariableNames as string[]) if (global.StartsWith("Qt5Version") && envPro.Globals.get_VariablePersists(global)) return true; return false; }
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>(); }
/// <summary> /// Return true if the project is a Qt project, otherwise false. /// </summary> /// <param name="proj">project</param> /// <returns></returns> public static bool IsQtProject(VCProject proj) { return HelperFunctions.IsQt4Project(proj) || HelperFunctions.IsQt5Project(proj); }
/// <summary> /// Get the active code file, project and configuration /// </summary> /// <returns>true if we have found an active C/C++ document</returns> private 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 Configuration cfg = _applicationObject.ActiveDocument.ProjectItem.ConfigurationManager.ActiveConfiguration; try { var cfgArray = (IVCCollection)vcProject.Configurations; foreach (VCConfiguration vcr in cfgArray) { if (vcr.ConfigurationName == cfg.ConfigurationName && vcr.Platform.Name == cfg.PlatformName) { vcCfg = vcr; } } } catch (Exception) { return false; } return true; } } } return false; }
public static QtProject Create(VCProject vcProject) { return Create((EnvDTE.Project)vcProject.Object); }
public void CreatePlatform(string oldPlatform, string newPlatform, VersionInformation viOld, VersionInformation viNew, ref bool newProjectCreated) { try { ConfigurationManager cfgMgr = envPro.ConfigurationManager; cfgMgr.AddPlatform(newPlatform, oldPlatform, true); vcPro.AddPlatform(newPlatform); newProjectCreated = false; } catch { // That stupid ConfigurationManager can't handle platform names // containing dots (e.g. "Windows Mobile 5.0 Pocket PC SDK (ARMV4I)") // So we have to do it the nasty way... string projectFileName = envPro.FullName; envPro.Save(null); dte.Solution.Remove(envPro); AddPlatformToVCProj(projectFileName, oldPlatform, newPlatform); envPro = dte.Solution.AddFromFile(projectFileName, false); vcPro = (VCProject)envPro.Object; newProjectCreated = true; } // update the platform settings foreach (VCConfiguration config in (IVCCollection)vcPro.Configurations) { VCPlatform vcplatform = (VCPlatform)config.Platform; if (vcplatform.Name == newPlatform) { if (viOld != null) RemovePlatformDependencies(config, viOld); SetupConfiguration(config, viNew); } } SelectSolutionPlatform(newPlatform); }
/// <summary> /// Changes the Qt version of this project. /// </summary> /// <param name="oldVersion">the current Qt version</param> /// <param name="newVersion">the new Qt version we want to change to</param> /// <param name="newProjectCreated">is set to true if a new Project object has been created</param> /// <returns>true, if the operation performed successfully</returns> public bool ChangeQtVersion(string oldVersion, string newVersion, ref bool newProjectCreated) { newProjectCreated = false; QtVersionManager versionManager = QtVersionManager.The(); versionManager.SetPlatform(Project.ConfigurationManager.ActiveConfiguration.PlatformName); VersionInformation viOld = versionManager.GetVersionInfo(oldVersion); VersionInformation viNew = versionManager.GetVersionInfo(newVersion); string vsPlatformNameOld = null; if (viOld != null) vsPlatformNameOld = viOld.GetVSPlatformName(); string vsPlatformNameNew = viNew.GetVSPlatformName(); bool bRefreshMocSteps = (vsPlatformNameNew != vsPlatformNameOld); try { if (vsPlatformNameOld != vsPlatformNameNew) { if (!SelectSolutionPlatform(vsPlatformNameNew) || !HasPlatform(vsPlatformNameNew)) { CreatePlatform(vsPlatformNameOld, vsPlatformNameNew, viOld, viNew, ref newProjectCreated); bRefreshMocSteps = false; UpdateMocSteps(QtVSIPSettings.GetMocDirectory(envPro)); } } ConfigurationManager configManager = envPro.ConfigurationManager; if (configManager.ActiveConfiguration.PlatformName != vsPlatformNameNew) { string projectName = envPro.FullName; envPro.Save(null); dte.Solution.Remove(envPro); envPro = dte.Solution.AddFromFile(projectName, false); dte = envPro.DTE; vcPro = envPro.Object as VCProject; } } catch { Messages.DisplayErrorMessage(SR.GetString("CannotChangeQtVersion")); return false; } // We have to delete the generated files because of // major differences between the platforms or Qt-Versions. if (vsPlatformNameOld != vsPlatformNameNew || viOld.qtPatch != viNew.qtPatch || viOld.qtMinor != viNew.qtMinor || viOld.qtMajor != viNew.qtMajor) { DeleteGeneratedFiles(); Clean(); } if (bRefreshMocSteps) RefreshMocSteps(); SetQtEnvironment(newVersion); UpdateModules(viOld, viNew); versionManager.SaveProjectQtVersion(envPro, newVersion, vsPlatformNameNew); return true; }
public static void addAddons(VCProject vcproject, String ofRoot, IEnumerable<String> addons) { VCFilter addonsFolder = null; try { addonsFolder = vcproject.AddFilter("addons"); }catch(Exception e) { IVCCollection filters = vcproject.Filters; foreach(var filter in filters) { if(filter is VCFilter) { if(((VCFilter)filter).Name == "addons") { addonsFolder = ((VCFilter)filter); break; } } } } if (addonsFolder != null) { foreach (var addon in addons) { VCFilter addonFolder = addonsFolder.AddFilter(addon); var addonObj = new Addon(ofRoot, addon, vcproject.ProjectDirectory); addonObj.addFilesToVCFilter(addonFolder); addonObj.addIncludePathsToVCProject(vcproject); addonObj.addLibsToVCProject(vcproject); } vcproject.Save(); } else { throw new Exception("Couldn't create or find addonsFolder"); } }
public VSProject(VCProject project, String afilepath, String rfilepath) { vcproj = project; absfilepath = afilepath; relfilepath = rfilepath; }
public static void saveAddonsMake(VCProject vcproject, IEnumerable<string> addons) { var addonsMake = new FileInfo(vcproject.ProjectDirectory + "\\addons.make"); var addonsMakeStrm = new StreamWriter(addonsMake.FullName); foreach (var addon in addons) { addonsMakeStrm.WriteLine(addon); } addonsMakeStrm.Close(); }
/// <summary> /// Return true if the project is a QMake -tp vc project, otherwise false. /// </summary> /// <param name="proj">project</param> /// <returns></returns> public static bool IsQMakeProject(VCProject proj) { if (proj == null) return false; string keyword = proj.keyword; if (keyword == null || !keyword.StartsWith(Resources.qtProjectKeyword)) return false; return true; }
/// <summary> /// Sets the target project, platform, and configuration to get settings from. /// </summary> /// <param name="proj">Project to read settings from.</param> /// <param name="targetPlatformName">Platform type to read settings from.</param> /// <param name="targetConfigName">Configuration to read from (Debug or Release).</param> public void SetTarget(Project proj, string targetPlatformName, string targetConfigName) { // Set the project platform. If it is set to Other then no settings are valid to be read. SetPlatform(targetPlatformName); if (!IsPepperPlatform(targetPlatformName) && !IsNaClPlatform(targetPlatformName)) return; // We don't support non-visual C/C++ projects. if (!Utility.IsVisualCProject(proj)) { PlatformType = ProjectPlatformType.Other; return; } // Set the member variables for configuration and project to the target. project_ = (VCProject)proj.Object; foreach (VCConfiguration config in project_.Configurations) { if (config.ConfigurationName == targetConfigName && config.Platform.Name == targetPlatformName) { configuration_ = config; break; } } }
/// <summary> /// Overload of SetTarget if the VCConfiguration is already known. /// </summary> /// <param name="config">Configuration to read settings from.</param> public void SetTarget(VCConfiguration config) { if (config == null) { throw new ArgumentNullException("Config"); } configuration_ = config; project_ = config.project; SetPlatform(config.Platform.Name); }
public static EnvDTE.Project VCProjectToProject(VCProject vcproj) { return (EnvDTE.Project)vcproj.Object; }
/// <summary> /// Removes a file reference from the project and moves the file to the "Deleted" folder. /// </summary> /// <param name="vcpro"></param> /// <param name="fileName"></param> public static void RemoveFileInProject(VCProject vcpro, string fileName) { QtProject qtProj = QtProject.Create(vcpro); FileInfo fi = new FileInfo(fileName); foreach(VCFile vcfile in (IVCCollection)vcpro.Files) { if (vcfile.FullPath.ToLower() == fi.FullName.ToLower()) { vcpro.RemoveFile(vcfile); qtProj.MoveFileToDeletedFolder(vcfile); } } }