コード例 #1
0
ファイル: ProjectImporter.cs プロジェクト: manp1212/QtPackage
        private static void RepairMocSteps(EnvDTE.Project project)
        {
            VCProject vcProject = project.Object as VCProject;

            if (vcProject == null)
            {
                return;
            }

            foreach (VCFile vcfile in (IVCCollection)vcProject.Files)
            {
                foreach (VCFileConfiguration config in (IVCCollection)vcfile.FileConfigurations)
                {
                    try
                    {
                        VCCustomBuildTool tool = HelperFunctions.GetCustomBuildTool(config);
                        if (tool == null)
                        {
                            continue;
                        }
                        string[] commandLines     = tool.CommandLine.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                        string   commandLineToSet = "";
                        bool     firstLoop        = true;
                        for (int i = 0; i < commandLines.Length; i++)
                        {
                            string commandLine = commandLines[i];
                            // If CONFIG contains silent in the pro file, there is an @echo at the beginning of the
                            // command line which we remove.
                            if (commandLine.Contains("moc.exe") && commandLine.StartsWith("@echo"))
                            {
                                commandLine = commandLine.Substring(commandLine.IndexOf("&&") + 3);
                            }
                            if (firstLoop)
                            {
                                firstLoop = false;
                            }
                            else
                            {
                                commandLineToSet += "\r\n";
                            }
                            commandLineToSet += commandLine;
                        }
                        tool.CommandLine = commandLineToSet;
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
コード例 #2
0
 void SolutionEvents_ProjectAdded(Project project)
 {
     if (HelperFunctions.IsQMakeProject(project))
     {
         RegisterVCProjectEngineEvents(project);
         VCProject vcpro  = project.Object as VCProject;
         VCFilter  filter = null;
         foreach (VCFilter f in vcpro.Filters as IVCCollection)
         {
             if (f.Name == Filters.HeaderFiles().Name)
             {
                 filter = f;
                 break;
             }
         }
         if (filter != null)
         {
             foreach (VCFile file in filter.Files as IVCCollection)
             {
                 foreach (VCFileConfiguration config in file.FileConfigurations as IVCCollection)
                 {
                     VCCustomBuildTool tool = HelperFunctions.GetCustomBuildTool(config);
                     if (tool != null && tool.CommandLine != null && tool.CommandLine.Contains("moc.exe"))
                     {
                         Regex           reg     = new Regex("[^ ^\n]+moc\\.exe");
                         MatchCollection matches = reg.Matches(tool.CommandLine);
                         string          qtDir   = null;
                         if (matches.Count != 1)
                         {
                             QtVersionManager vm = QtVersionManager.The();
                             qtDir = vm.GetInstallPath(vm.GetDefaultVersion());
                         }
                         else
                         {
                             qtDir = matches[0].ToString();
                             qtDir = qtDir.Remove(qtDir.LastIndexOf("\\"));
                             qtDir = qtDir.Remove(qtDir.LastIndexOf("\\"));
                         }
                         qtDir = qtDir.Replace("_(QTDIR)", "$(QTDIR)");
                         HelperFunctions.SetDebuggingEnvironment(project, "PATH=" + qtDir + "\\bin;$(PATH)", false);
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: TestCocoon.cs プロジェクト: testcocoon/testcocoon
        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");
            }
        }
コード例 #4
0
        /// <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;
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        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));
        }
コード例 #6
0
ファイル: TestCocoon.cs プロジェクト: testcocoon/testcocoon
 private void CreateCustomBuildConfig(ref VCCustomBuildTool customBuildTool, List <string> additionalParamsList, string BuildMode)
 {
     if (customBuildTool != null)
     {
     }
 }
コード例 #7
0
ファイル: TestCocoon.cs プロジェクト: testcocoon/testcocoon
 private void DisableCustomBuildConfig(ref VCCustomBuildTool customBuildTool, string BuildMode)
 {
     if (customBuildTool != null)
     {
     }
 }
コード例 #8
0
ファイル: TestCocoon.cs プロジェクト: testcocoon/testcocoon
        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");
            }
        }
コード例 #9
0
ファイル: TestCocoon.cs プロジェクト: testcocoon/testcocoon
 private void DisableCustomBuildConfig(ref VCCustomBuildTool customBuildTool, string BuildMode)
 {
     if (customBuildTool != null)
       {
       }
 }
コード例 #10
0
ファイル: TestCocoon.cs プロジェクト: testcocoon/testcocoon
        private void CreateCustomBuildConfig(ref VCCustomBuildTool customBuildTool, List<string> additionalParamsList, string BuildMode)
        {
            if (customBuildTool != null)
              {

              }
        }
コード例 #11
0
        public void ProjectItemsEvents_ItemAdded(ProjectItem projectItem)
        {
            try
            {
                VCFile file = projectItem.Object as VCFile;

                if (!file.Name.EndsWith(".jst") && !file.Name.EndsWith(".json"))
                {
                    return;
                }

                //// open added file
                //projectItem.Open();

                foreach (VCFileConfiguration fc in (IVCCollection)file.FileConfigurations)
                {
                    VCCustomBuildTool cbt = fc.Tool as VCCustomBuildTool;

                    if (file.Name.EndsWith(".jst"))
                    {
                        cbt.CommandLine = "jstructcompiler --multi_build=off --include_path=\"$(IncludePath)\" --h_out --input_file=\"%(FullPath)\" --output_file=\"$(ProjectDir)mjst\\%(Filename).h\"";
                        cbt.Description = "jstructcompiler%27ing %(Identity)...";
                        cbt.Outputs     = "$(ProjectDir)mjst\\%(Filename).h";
                    }
                    else if (file.Name.EndsWith(".json"))
                    {
                        cbt.CommandLine = "jstructdecompiler \"%(FullPath)\" \"$(ProjectDir)%(Filename).jst\"";
                        cbt.Description = "jstructdecompiler%27ing %(Identity)...";
                        cbt.Outputs     = "$(ProjectDir)__%(Filename).jst";
                    }
                }

                if (file.Name.EndsWith(".json"))
                {
                    return;
                }

                VCProject        proj;
                IVCCollection    cfgs, tools;
                VCLinkerTool     linktool;
                VCCLCompilerTool comptool;

                proj = projectItem.ContainingProject.Object  as VCProject;
                cfgs = proj.Configurations                   as IVCCollection;

                string incpath = "$(VisualStudioDir)\\Addins\\inc;";
                string libpath = "$(VisualStudioDir)\\Addins\\lib;";

                foreach (VCConfiguration cfg in cfgs as IVCCollection)
                {
                    tools    = cfg.Tools                         as IVCCollection;
                    comptool = tools.Item("VCCLCompilerTool")    as VCCLCompilerTool;
                    linktool = tools.Item("VCLinkerTool")        as VCLinkerTool;

                    StringBuilder sbcomp = new StringBuilder(comptool.AdditionalIncludeDirectories);
                    StringBuilder sblink = new StringBuilder(linktool.AdditionalLibraryDirectories);

                    if (!sbcomp.ToString().Contains("$(VisualStudioDir)"))
                    {
                        sbcomp.Insert(0, incpath + ".\\mjst;");

                        comptool.AdditionalIncludeDirectories = sbcomp.ToString();
                    }

                    if (!sblink.ToString().Contains("$(VisualStudioDir)"))
                    {
                        sblink.Insert(0, libpath);

                        linktool.AdditionalLibraryDirectories = sblink.ToString();
                    }
                }
            }
            catch (Exception e)
            {
            }
        }