コード例 #1
0
        public static CompilerToolWrapper Create(VCFileConfiguration config)
        {
            CompilerToolWrapper wrapper = null;

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

            return(wrapper.IsNull() ? null : wrapper);
        }
コード例 #2
0
        public static CompilerToolWrapper Create(VCPropertySheet sheet)
        {
            CompilerToolWrapper wrapper = null;

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

            return(wrapper.IsNull() ? null : wrapper);
        }
コード例 #3
0
        public static CompilerToolWrapper Create(VCConfiguration config)
        {
            CompilerToolWrapper wrapper = null;

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

            return(wrapper.IsNull() ? null : wrapper);
        }
コード例 #4
0
ファイル: ProjectImporter.cs プロジェクト: qt-labs/vstools
        public void ImportProject(FileInfo mainInfo, string qtVersion)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var versionInfo = QtVersionManager.The().GetVersionInfo(qtVersion);
            var VCInfo      = RunQmake(mainInfo, projectFileExtension, false, versionInfo);

            if (null == VCInfo)
            {
                return;
            }

            ImportQMakeProject(VCInfo, versionInfo);

            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.Print("--- (Import): Generated project could not be loaded.");
                            Messages.Print("--- (Import): Please look in the output above for errors and warnings.");
                            return;
                        }
                        Messages.Print("--- (Import): Added " + VCInfo.Name + " to Solution");
                    }
                    else
                    {
                        Messages.Print("Project already in Solution");
                    }

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

                        if (qtVersion != null)
                        {
                            QtVersionManager.The().SaveProjectQtVersion(pro, qtVersion, platformName);
                        }

                        if (!qtPro.SelectSolutionPlatform(platformName) || !qtPro.HasPlatform(platformName))
                        {
                            var newProject = false;
                            qtPro.CreatePlatform("Win32", platformName, null, versionInfo, ref newProject);
                            if (!qtPro.SelectSolutionPlatform(platformName))
                            {
                                Messages.Print("Can't select the platform " + platformName + ".");
                            }
                        }

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

                        qtPro.SetQtEnvironment();
                        ApplyPostImportSteps(qtPro);
                    }
                }
            } catch (Exception e) {
                Messages.DisplayCriticalErrorMessage(SR.GetString("ExportProject_ProjectOrSolutionCorrupt", e.ToString()));
            }
        }
コード例 #5
0
ファイル: ProjectExporter.cs プロジェクト: qt-labs/vstools
        private static ProFileContent CreateProFileContent(Project project)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            ProFileOption option;
            var           qtPro   = QtProject.Create(project);
            var           content = new ProFileContent(qtPro.VCProject);

            // hack to get active config
            var activeConfig   = project.ConfigurationManager.ActiveConfiguration.ConfigurationName;
            var activePlatform = project.ConfigurationManager.ActiveConfiguration.PlatformName;
            var config         = (VCConfiguration)((IVCCollection)qtPro.VCProject.Configurations).Item(activeConfig);
            var compiler       = CompilerToolWrapper.Create(config);
            var linker         = (VCLinkerTool)((IVCCollection)config.Tools).Item("VCLinkerTool");
            var libTool        = (VCLibrarianTool)((IVCCollection)config.Tools).Item("VCLibrarianTool");

            var outPut  = config.PrimaryOutput;
            var fi      = new FileInfo(outPut);
            var destdir = HelperFunctions.GetRelativePath(qtPro.VCProject.ProjectDirectory, fi.DirectoryName);

            destdir = HelperFunctions.ChangePathFormat(destdir);
            var target = qtPro.VCProject.Name;

            option              = new ProFileOption("TEMPLATE");
            option.Comment      = Resources.ec_Template;
            option.ShortComment = "Template";
            option.NewOption    = null; // just one option...
            option.AssignSymbol = ProFileOption.AssignType.AT_Equals;
            content.Options.Add(option);
            if (config.ConfigurationType == ConfigurationTypes.typeApplication)
            {
                option.List.Add("app");
            }
            else
            {
                option.List.Add("lib");
            }

            option              = new ProFileOption("TARGET");
            option.Comment      = Resources.ec_Target;
            option.ShortComment = "Target Name";
            option.NewOption    = null; // just one option...
            option.AssignSymbol = ProFileOption.AssignType.AT_Equals;
            content.Options.Add(option);
            option.List.Add(target);

            option              = new ProFileOption("DESTDIR");
            option.Comment      = Resources.ec_DestDir;
            option.ShortComment = "Destination Directory";
            option.NewOption    = null; // just one option...
            option.AssignSymbol = ProFileOption.AssignType.AT_Equals;
            content.Options.Add(option);
            option.List.Add(destdir);

            // add the qt option
            option = new ProFileOption("QT");
            var optionQT = option;

            option.Comment      = Resources.ec_Qt;
            option.ShortComment = "Qt Options";
            option.NewOption    = " "; // just space between the options...
            content.Options.Add(option);

            // add the config option
            option = new ProFileOption("CONFIG");
            var optionCONFIG = option;

            option.Comment      = Resources.ec_Config;
            option.ShortComment = "Config Options";
            option.NewOption    = " "; // just space between the options...
            content.Options.Add(option);

            AddModules(qtPro, optionQT, optionCONFIG);

            if (config.ConfigurationType == ConfigurationTypes.typeStaticLibrary)
            {
                option.List.Add("staticlib");
            }
            if (linker != null)
            {
                var generateDebugInformation = (linker is IVCRulePropertyStorage linkerRule) ?
                                               linkerRule.GetUnevaluatedPropertyValue("GenerateDebugInformation") : null;
                if (generateDebugInformation != "false")
                {
                    option.List.Add("debug");
                }
                else
                {
                    option.List.Add("release");
                }

                if (linker.SubSystem == subSystemOption.subSystemConsole)
                {
                    option.List.Add("console");
                }

                if (linker.AdditionalDependencies != null)
                {
                    if (linker.AdditionalDependencies.IndexOf("QAxServer", StringComparison.Ordinal) > -1)
                    {
                        option.List.Add("qaxserver");
                    }
                    else if (linker.AdditionalDependencies.IndexOf("QAxContainer", StringComparison.Ordinal) > -1)
                    {
                        option.List.Add("qaxcontainer");
                    }
                    else if (linker.AdditionalDependencies.IndexOf("QtHelp", StringComparison.Ordinal) > -1)
                    {
                        option.List.Add("help");
                    }
                }
            }

            if (qtPro.IsDesignerPluginProject())
            {
                option.List.Add("designer");
                option.List.Add("plugin");
            }

            // add defines
            option              = new ProFileOption("DEFINES");
            option.Comment      = Resources.ec_Defines;
            option.ShortComment = "Defines";
            option.NewOption    = " ";
            option.AssignSymbol = ProFileOption.AssignType.AT_PlusEquals;
            content.Options.Add(option);
            AddPreprocessorDefinitions(option, compiler.GetPreprocessorDefinitions());

            // add the include path option
            option              = new ProFileOption("INCLUDEPATH");
            option.Comment      = Resources.ec_IncludePath;
            option.ShortComment = "Include Path";
            content.Options.Add(option);
            AddIncludePaths(project, option, compiler.GetAdditionalIncludeDirectories());

            option              = new ProFileOption("LIBS");
            option.Comment      = Resources.ec_Libs;
            option.ShortComment = "Additional Libraries";
            content.Options.Add(option);
            if (linker != null)
            {
                AddLibraries(project, option, linker.AdditionalLibraryDirectories,
                             linker.AdditionalDependencies);
            }
            else if (libTool != null)
            {
                AddLibraries(project, option, libTool.AdditionalLibraryDirectories,
                             libTool.AdditionalDependencies);
            }

            option              = new ProFileOption("PRECOMPILED_HEADER");
            option.Comment      = Resources.ec_PrecompiledHeader;
            option.ShortComment = "Using Precompiled Headers";
            option.AssignSymbol = ProFileOption.AssignType.AT_Equals;
            content.Options.Add(option);

            if (qtPro.UsesPrecompiledHeaders())
            {
                option.List.Add(compiler.GetPrecompiledHeaderThrough());
            }

            // add the depend path option
            option              = new ProFileOption("DEPENDPATH");
            option.Comment      = Resources.ec_DependPath;
            option.ShortComment = "Depend Path";
            content.Options.Add(option);
            option.List.Add(".");

            var mocDir = QtVSIPSettings.GetMocDirectory(project, activeConfig.ToLower(), activePlatform.ToLower());

            mocDir              = mocDir.Replace('\\', '/');
            option              = new ProFileOption("MOC_DIR");
            option.Comment      = Resources.ec_MocDir;
            option.ShortComment = "Moc Directory";
            option.NewOption    = null; // just one option...
            content.Options.Add(option);
            option.List.Add(mocDir);

            option              = new ProFileOption("OBJECTS_DIR");
            option.Comment      = Resources.ec_ObjDir;
            option.ShortComment = "Objects Directory";
            option.NewOption    = null; // just one option...
            content.Options.Add(option);
            option.List.Add(config.ConfigurationName.ToLower());

            var uiDir = QtVSIPSettings.GetUicDirectory(project);

            uiDir               = uiDir.Replace('\\', '/');
            option              = new ProFileOption("UI_DIR");
            option.Comment      = Resources.ec_UiDir;
            option.ShortComment = "UI Directory";
            option.NewOption    = null; // just one option...
            content.Options.Add(option);
            option.List.Add(uiDir);

            var rccDir = QtVSIPSettings.GetRccDirectory(project);

            rccDir              = rccDir.Replace('\\', '/');
            option              = new ProFileOption("RCC_DIR");
            option.Comment      = Resources.ec_RccDir;
            option.ShortComment = "RCC Directory";
            option.NewOption    = null; // just one option...
            content.Options.Add(option);
            option.List.Add(rccDir);

            // add the include path option
            option                = new ProFileOption("include");
            option.Comment        = Resources.ec_Include;
            option.ShortComment   = "Include file(s)";
            option.IncludeComment = false; // print the comment in the output file
            option.AssignSymbol   = ProFileOption.AssignType.AT_Function;
            content.Options.Add(option);

            // add the translation files
            option                = new ProFileOption("TRANSLATIONS");
            option.Comment        = Resources.ec_Translations;
            option.ShortComment   = "Translation files";
            option.IncludeComment = false;
            content.Options.Add(option);
            option.List.AddRange(HelperFunctions.GetProjectFiles(project, FilesToList.FL_Translation));

            // add the rc file
            if (File.Exists(qtPro.VCProject.ProjectDirectory + "\\" + project.Name + ".rc"))
            {
                option                = new ProFileOption("win32:RC_FILE");
                option.Comment        = Resources.ec_rcFile;
                option.ShortComment   = "Windows resource file";
                option.IncludeComment = false;
                option.AssignSymbol   = ProFileOption.AssignType.AT_Equals;
                content.Options.Add(option);
                option.List.Add(project.Name + ".rc");
            }

            if (qtPro.IsDesignerPluginProject())
            {
                option = new ProFileOption("target.path");
                option.ShortComment   = "Install the plugin in the designer plugins directory.";
                option.IncludeComment = true;
                option.AssignSymbol   = ProFileOption.AssignType.AT_Equals;
                option.List.Add("$$[QT_INSTALL_PLUGINS]/designer");
                content.Options.Add(option);

                option = new ProFileOption("INSTALLS");
                option.IncludeComment = false;
                option.AssignSymbol   = ProFileOption.AssignType.AT_PlusEquals;
                option.List.Add("target");
                content.Options.Add(option);
            }

            return(content);
        }