public static CompilerToolWrapper Create(VCPropertySheet sheet)
        {
            CompilerToolWrapper wrapper = null;

            try
            {
                wrapper = new CompilerToolWrapper(((IVCCollection)sheet.Tools).Item("VCCLCompilerTool"));
            }
            catch
            {
            }

            return(wrapper.IsNull() ? null : wrapper);
        }
        public static CompilerToolWrapper Create(VCFileConfiguration config)
        {
            CompilerToolWrapper wrapper = null;

            try
            {
                wrapper = new CompilerToolWrapper(config.Tool);
            }
            catch
            {
            }

            return(wrapper.IsNull() ? null : wrapper);
        }
        public static CompilerToolWrapper Create(VCConfiguration config)
        {
            CompilerToolWrapper wrapper = null;

            try
            {
                wrapper = new CompilerToolWrapper(((IVCCollection)config.Tools).Item("VCCLCompilerTool"));
            }
            catch
            {
            }

            return(wrapper.IsNull() ? null : wrapper);
        }
Exemple #4
0
        private static void ApplyPostImportSteps(QtProject qtProject)
        {
            foreach (VCConfiguration cfg in (IVCCollection)qtProject.VCProject.Configurations)
            {
#if (VS2010 || VS2012 || VS2013)
                cfg.IntermediateDirectory = @"$(Platform)\$(Configuration)\";
#else
                cfg.IntermediateDirectory = @"$(PlatformName)\$(ConfigurationName)";
#endif
                CompilerToolWrapper compilerTool = CompilerToolWrapper.Create(cfg);
                if (compilerTool != null)
                {
#if (VS2010 || VS2012 || VS2013)
                    compilerTool.ObjectFile = @"$(IntDir)";
                    compilerTool.ProgramDataBaseFileName = @"$(IntDir)vc$(PlatformToolsetVersion).pdb";
#else
                    compilerTool.ObjectFile = @"$(IntDir)\";
                    compilerTool.ProgramDataBaseFileName = @"$(IntDir)\vc90.pdb";
#endif
                }
            }

            qtProject.RemoveResFilesFromGeneratedFilesFilter();
            qtProject.RepairGeneratedFilesStructure();
            qtProject.TranslateFilterNames();

            QtVSIPSettings.SaveUicDirectory(qtProject.Project, QtVSIPSettings.GetUicDirectory());
            qtProject.UpdateUicSteps(".", false); // false is to not remove given path from includes
            QtVSIPSettings.SaveRccDirectory(qtProject.Project, QtVSIPSettings.GetRccDirectory());
            qtProject.RefreshRccSteps();

            // collapse the generated files/resources filters afterwards
            qtProject.CollapseFilter(Filters.ResourceFiles().Name);
            qtProject.CollapseFilter(Filters.GeneratedFiles().Name);

            try
            {
                // save the project after modification
                qtProject.Project.Save(null);
            }
            catch { /* ignore */ }
        }
Exemple #5
0
 private bool UsePrecompiledHeaders(CompilerToolWrapper compiler)
 {
     try
     {
         compiler.SetUsePrecompiledHeader(pchOption.pchUseUsingSpecific);
         string pcHeaderThrough = GetPrecompiledHeaderThrough();
         if (string.IsNullOrEmpty(pcHeaderThrough))
             pcHeaderThrough = "stdafx.h";
         compiler.SetPrecompiledHeaderThrough(pcHeaderThrough);
         string pcHeaderFile = GetPrecompiledHeaderFile();
         if (string.IsNullOrEmpty(pcHeaderFile))
             pcHeaderFile = ".\\$(ConfigurationName)/"
             + Project.Name + ".pch";
         compiler.SetPrecompiledHeaderFile(pcHeaderFile);
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #6
0
        private string GetPCHMocOptions(VCFile file, CompilerToolWrapper compiler)
        {
            // As .moc files are included, we should not add anything there
            if (!HelperFunctions.HasHeaderFileExtension(file.Name))
                return "";

            string additionalMocOptions = "\"-f" + compiler.GetPrecompiledHeaderThrough().Replace('\\', '/') + "\" ";
            //Get mocDir without .\\ at the beginning of it
            string mocDir = QtVSIPSettings.GetMocDirectory(envPro);
            if (mocDir.StartsWith(".\\"))
                mocDir = mocDir.Substring(2);

            //Get the absolute path
            mocDir = vcPro.ProjectDirectory + mocDir;
            string relPathToFile = HelperFunctions.GetRelativePath(mocDir, file.FullPath).Replace('\\', '/');
            additionalMocOptions += "\"-f" + relPathToFile + "\"";
            return additionalMocOptions;
        }
Exemple #7
0
 private static bool UsesPrecompiledHeaders(CompilerToolWrapper compiler)
 {
     try
     {
         if (compiler.GetUsePrecompiledHeader() != pchOption.pchNone)
             return true;
     }
     catch { }
     return false;
 }
Exemple #8
0
 private static string GetPrecompiledHeaderThrough(CompilerToolWrapper compiler)
 {
     try
     {
         string header = compiler.GetPrecompiledHeaderThrough();
         if (!string.IsNullOrEmpty(header))
             return header;
     }
     catch { }
     return null;
 }
Exemple #9
0
 private static string GetPrecompiledHeaderFile(CompilerToolWrapper compiler)
 {
     try
     {
         string file = compiler.GetPrecompiledHeaderFile();
         if (!string.IsNullOrEmpty(file))
             return file;
     }
     catch { }
     return null;
 }
Exemple #10
0
 private static List<string> GetIncludesFromCompilerTool(CompilerToolWrapper compiler)
 {
     try
     {
         if (compiler.GetAdditionalIncludeDirectories() != null && compiler.GetAdditionalIncludeDirectories().Length > 0)
         {
             string[] includes = compiler.GetAdditionalIncludeDirectoriesList();
             return new List<string>(includes);
         }
     }
     catch { }
     return new List<string>();
 }
Exemple #11
0
        public void ImportProject(FileInfo mainInfo, string qtVersion)
        {
            VersionInformation versionInfo = QtVersionManager.The().GetVersionInfo(qtVersion);
            FileInfo           VCInfo      = RunQmake(mainInfo, projectFileExtension, false, versionInfo);

            if (null == VCInfo)
            {
                return;
            }

            ReplaceAbsoluteQtDirInProject(VCInfo);

            try
            {
                if (CheckQtVersion(versionInfo))
                {
                    // no need to add the project again if it's already there...
                    if (!HelperFunctions.IsProjectInSolution(dteObject, VCInfo.FullName))
                    {
                        try
                        {
                            dteObject.Solution.AddFromFile(VCInfo.FullName, false);
                        }
                        catch (Exception /*exception*/)
                        {
                            Messages.PaneMessage(dteObject, "--- (Import): Generated project could not be loaded.");
                            Messages.PaneMessage(dteObject, "--- (Import): Please look in the output above for errors and warnings.");
                            return;
                        }
                        Messages.PaneMessage(dteObject, "--- (Import): Added " + VCInfo.Name + " to Solution");
                    }
                    else
                    {
                        Messages.PaneMessage(dteObject, "Project already in Solution");
                    }

                    EnvDTE.Project pro = null;
                    foreach (EnvDTE.Project p in HelperFunctions.ProjectsInSolution(dteObject))
                    {
                        if (p.FullName.ToLower() == VCInfo.FullName.ToLower())
                        {
                            pro = p;
                            break;
                        }
                    }
                    if (pro != null)
                    {
                        QtProject qtPro = QtProject.Create(pro);
                        qtPro.SetQtEnvironment();
                        string platformName = versionInfo.GetVSPlatformName();

                        if (qtVersion != null)
                        {
                            QtVersionManager.The().SaveProjectQtVersion(pro, qtVersion, platformName);
                        }
                        if (!qtPro.SelectSolutionPlatform(platformName) || !qtPro.HasPlatform(platformName))
                        {
                            bool newProject = false;
                            qtPro.CreatePlatform("Win32", platformName, null, versionInfo, ref newProject);
                            if (!qtPro.SelectSolutionPlatform(platformName))
                            {
                                Messages.PaneMessage(dteObject, "Can't select the platform " + platformName + ".");
                            }
                        }

                        // try to figure out if the project is a plugin project
                        try
                        {
                            string          activeConfig = pro.ConfigurationManager.ActiveConfiguration.ConfigurationName;
                            VCConfiguration config       = (VCConfiguration)((IVCCollection)qtPro.VCProject.Configurations).Item(activeConfig);
                            if (config.ConfigurationType == ConfigurationTypes.typeDynamicLibrary)
                            {
                                CompilerToolWrapper compiler = CompilerToolWrapper.Create(config);
                                VCLinkerTool        linker   = (VCLinkerTool)((IVCCollection)config.Tools).Item("VCLinkerTool");
                                if (compiler.GetPreprocessorDefinitions().IndexOf("QT_PLUGIN") > -1 &&
                                    compiler.GetPreprocessorDefinitions().IndexOf("QDESIGNER_EXPORT_WIDGETS") > -1 &&
                                    compiler.GetAdditionalIncludeDirectories().IndexOf("QtDesigner") > -1 &&
                                    linker.AdditionalDependencies.IndexOf("QtDesigner") > -1)
                                {
                                    qtPro.MarkAsDesignerPluginProject();
                                }
                            }
                        }
                        catch (Exception)
                        { }

                        ApplyPostImportSteps(qtPro);
                    }
                }
            }
            catch (Exception e)
            {
                Messages.DisplayCriticalErrorMessage(SR.GetString("ExportProject_ProjectOrSolutionCorrupt", e.ToString()));
            }
        }
        public static CompilerToolWrapper Create(VCPropertySheet sheet)
        {
            CompilerToolWrapper wrapper = null;
            try
            {
                wrapper = new CompilerToolWrapper(((IVCCollection)sheet.Tools).Item("VCCLCompilerTool"));
            }
            catch
            {
            }

            return wrapper.IsNull() ? null : wrapper;
        }
        public static CompilerToolWrapper Create(VCFileConfiguration config)
        {
            CompilerToolWrapper wrapper = null;
            try
            {
                wrapper = new CompilerToolWrapper(config.Tool);
            }
            catch
            {
            }

            return wrapper.IsNull() ? null : wrapper;
        }
        public static CompilerToolWrapper Create(VCConfiguration config)
        {
            CompilerToolWrapper wrapper = null;
            try
            {
                wrapper = new CompilerToolWrapper(((IVCCollection)config.Tools).Item("VCCLCompilerTool"));
            }
            catch
            {
            }

            return wrapper.IsNull() ? null : wrapper;
        }