Esempio n. 1
0
        private static void ApplyPostImportSteps(QtProject qtProject)
        {
            foreach (VCConfiguration cfg in (IVCCollection)qtProject.VCProject.Configurations)
            {
#if (VS2010 || VS2012 || VS2013 || VS2015)
                cfg.IntermediateDirectory = @"$(Platform)\$(Configuration)\";
#else
                cfg.IntermediateDirectory = @"$(PlatformName)\$(ConfigurationName)";
#endif
                CompilerToolWrapper compilerTool = CompilerToolWrapper.Create(cfg);
                if (compilerTool != null)
                {
#if (VS2010 || VS2012 || VS2013 || VS2015)
                    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 */ }
        }
Esempio n. 2
0
        private void CreateProject(EnvDTE.DTE app, string proName,
                                   string proPath, string slnName, bool exclusive, FakeFilter[] filters,
                                   string qtVersion, string platformName)
        {
            QtVersionManager versionManager = QtVersionManager.The();

            if (qtVersion == null)
            {
                qtVersion = versionManager.GetDefaultVersion();
            }

            if (qtVersion == null)
            {
                throw new QtVSException("Unable to find a Qt build!\r\n"
                                        + "To solve this problem specify a Qt build");
            }

            string   solutionPath = "";
            Solution newSolution  = app.Solution;

            if (platformName == null)
            {
                string tmpQtVersion = versionManager.GetSolutionQtVersion(newSolution);
                qtVersion = tmpQtVersion != null ? tmpQtVersion : qtVersion;
                try
                {
                    VersionInformation vi = new VersionInformation(versionManager.GetInstallPath(qtVersion));
                    if (vi.is64Bit())
                    {
                        platformName = "x64";
                    }
                    else
                    {
                        platformName = "Win32";
                    }
                }
                catch (Exception e)
                {
                    Messages.DisplayErrorMessage(e);
                }
            }

            if (!string.IsNullOrEmpty(slnName) && (exclusive == true))
            {
                solutionPath = proPath.Substring(0, proPath.LastIndexOf("\\"));
                newSolution.Create(solutionPath, slnName);
            }

            System.IO.Directory.CreateDirectory(proPath);
            string templatePath = HelperFunctions.CreateProjectTemplateFile(filters, true, platformName);

            pro = newSolution.AddFromTemplate(templatePath, proPath, proName, exclusive);

            HelperFunctions.ReleaseProjectTemplateFile();

            qtPro = QtProject.Create(pro);
            QtVSIPSettings.SaveUicDirectory(pro, null);
            QtVSIPSettings.SaveMocDirectory(pro, null);
            QtVSIPSettings.SaveMocOptions(pro, null);
            QtVSIPSettings.SaveRccDirectory(pro, null);
            QtVSIPSettings.SaveLUpdateOnBuild(pro);
            QtVSIPSettings.SaveLUpdateOptions(pro, null);
            QtVSIPSettings.SaveLReleaseOptions(pro, null);

            if (platformName != "Win32")
            {
                qtPro.SelectSolutionPlatform(platformName);
            }
            versionManager.SaveProjectQtVersion(pro, qtVersion);

            qtPro.MarkAsQtProject("v1.0");
            qtPro.AddDirectories();

            if (!string.IsNullOrEmpty(slnName) && (exclusive == true))
            {
                newSolution.SaveAs(solutionPath + "\\" + slnName + ".sln");
            }
        }