コード例 #1
0
ファイル: ProjectImporter.cs プロジェクト: manp1212/QtPackage
        private FileInfo RunQmake(FileInfo mainInfo, string ext, bool recursive, VersionInformation vi)
        {
            string name = mainInfo.Name.Remove(mainInfo.Name.IndexOf('.'));

            FileInfo VCInfo = new FileInfo(mainInfo.DirectoryName + "\\" + name + ext);

            if (!VCInfo.Exists || DialogResult.Yes == MessageBox.Show(SR.GetString("ExportProject_ProjectExistsRegenerateOrReuse", VCInfo.Name),
                                                                      SR.GetString("ProjectExists"), MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                Messages.PaneMessage(dteObject, "--- (Import): Generating new project of " + mainInfo.Name + " file");

                InfoDialog dialog = new InfoDialog(mainInfo.Name);
                QMake      qmake  = new QMake(dteObject, mainInfo.FullName, recursive, vi);

                qmake.CloseEvent           += new QMake.ProcessEventHandler(dialog.CloseEventHandler);
                qmake.PaneMessageDataEvent += new QMake.ProcessEventHandlerArg(this.PaneMessageDataReceived);

                System.Threading.Thread qmakeThread = new System.Threading.Thread(new ThreadStart(qmake.RunQMake));
                qmakeThread.Start();
                dialog.ShowDialog();
                qmakeThread.Join();

                if (qmake.ErrorValue == 0)
                {
                    return(VCInfo);
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: ProjectImporter.cs プロジェクト: manp1212/QtPackage
        private void ReplaceAbsoluteQtDirInProject(FileInfo projectFile)
        {
            StreamReader sr      = projectFile.OpenText();
            string       content = sr.ReadToEnd();

            sr.Close();

            string qtDir = ParseQtDirFromFileContent(content);

            if (!string.IsNullOrEmpty(qtDir))
            {
                content = HelperFunctions.ReplaceCaseInsensitive(content, qtDir, "$(QTDIR)\\");
                StreamWriter sw = projectFile.CreateText();
                sw.Write(content);
                sw.Flush();
                sw.Close();
            }
            else
            {
                Messages.PaneMessage(dteObject, SR.GetString("ImportProject_CannotFindQtDirectory", projectFile.Name));
            }
        }
コード例 #3
0
ファイル: ProjectImporter.cs プロジェクト: manp1212/QtPackage
        private void ImportSolution(FileInfo mainInfo, string qtVersion)
        {
            var versionInfo = QtVersionManager.The().GetVersionInfo(qtVersion);
            var VCInfo      = RunQmake(mainInfo, ".sln", true, versionInfo);

            if (null == VCInfo)
            {
                return;
            }
            ReplaceAbsoluteQtDirInSolution(VCInfo);

            try
            {
                if (CheckQtVersion(versionInfo))
                {
                    dteObject.Solution.Open(VCInfo.FullName);
                    if (qtVersion != null)
                    {
                        QtVersionManager.The().SaveSolutionQtVersion(dteObject.Solution, qtVersion);
                        foreach (Project prj in HelperFunctions.ProjectsInSolution(dteObject))
                        {
                            QtVersionManager.The().SaveProjectQtVersion(prj, qtVersion);
                            QtProject qtPro = QtProject.Create(prj);
                            qtPro.SetQtEnvironment();
                            ApplyPostImportSteps(qtPro);
                        }
                    }
                }

                Messages.PaneMessage(dteObject, "--- (Import): Finished opening " + VCInfo.Name);
            }
            catch (Exception e)
            {
                Messages.DisplayCriticalErrorMessage(e);
            }
        }
コード例 #4
0
ファイル: ProjectImporter.cs プロジェクト: manp1212/QtPackage
 private void PaneMessageDataReceived(string data)
 {
     Messages.PaneMessage(dteObject, data);
 }
コード例 #5
0
ファイル: ProjectImporter.cs プロジェクト: manp1212/QtPackage
        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()));
            }
        }