private void ImportSolution(FileInfo mainInfo, string qtVersion) { var versionInfo = QtVersionManager.The().GetVersionInfo(qtVersion); var VCInfo = RunQmake(mainInfo, ".sln", true, versionInfo); if (null == VCInfo) { return; } ImportQMakeSolution(VCInfo, versionInfo); try { if (CheckQtVersion(versionInfo)) { dteObject.Solution.Open(VCInfo.FullName); if (qtVersion != null) { QtVersionManager.The().SaveSolutionQtVersion(dteObject.Solution, qtVersion); foreach (var prj in HelperFunctions.ProjectsInSolution(dteObject)) { QtVersionManager.The().SaveProjectQtVersion(prj, qtVersion); var qtPro = QtProject.Create(prj); qtPro.SetQtEnvironment(); ApplyPostImportSteps(qtPro); } } } Messages.PaneMessage(dteObject, "--- (Import): Finished opening " + VCInfo.Name); } catch (Exception e) { Messages.DisplayCriticalErrorMessage(e); } }
private static void AddIncludePaths(Project project, ProFileOption option, string includePaths) { if (QtProject.GetFormatVersion(project) >= Resources.qtMinFormatVersion_ClProperties) { return; } if (includePaths == null) { return; } var versionManager = QtVersionManager.The(); var qtDir = versionManager.GetInstallPath(project); if (qtDir == null) { qtDir = Environment.GetEnvironmentVariable("QTDIR"); } if (qtDir == null) { qtDir = ""; } qtDir = HelperFunctions.NormalizeRelativeFilePath(qtDir); foreach (var s in includePaths.Split(';', ',')) { var d = HelperFunctions.NormalizeRelativeFilePath(s); if (!d.StartsWith("$(qtdir)\\include", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(qtDir + "\\include", StringComparison.OrdinalIgnoreCase) && !d.EndsWith("win32-msvc2005", StringComparison.OrdinalIgnoreCase)) { var vcConfig = project.ConfigurationManager.ActiveConfiguration.Object as VCConfiguration; if (vcConfig != null) { HelperFunctions.ExpandString(ref d, vcConfig); } if (HelperFunctions.IsAbsoluteFilePath(d)) { d = HelperFunctions.GetRelativePath(project.FullName, d); } if (!HelperFunctions.IsAbsoluteFilePath(d)) { option.List.Add(HelperFunctions.ChangePathFormat(d)); } } } }
public static bool IsInstalled(string moduleName) { var qtVersion = QtVersionManager.The().GetDefaultVersion(); if (qtVersion == null) { throw new QtVSException("Unable to find a Qt build!" + Environment.NewLine + "To solve this problem specify a Qt build."); } var installPath = QtVersionManager.The().GetInstallPath(qtVersion); if (moduleName.StartsWith("Qt", StringComparison.Ordinal)) { moduleName = "Qt5" + moduleName.Substring(2); } return(new FileInfo(Path.Combine(installPath, "lib", moduleName + ".lib")).Exists); }
private static void AddIncludePaths(Project project, ProFileOption option, string includePaths) { if (includePaths == null) { return; } var versionManager = QtVersionManager.The(); var qtDir = versionManager.GetInstallPath(project); if (qtDir == null) { qtDir = Environment.GetEnvironmentVariable("QTDIR"); } if (qtDir == null) { qtDir = ""; } qtDir = HelperFunctions.NormalizeRelativeFilePath(qtDir); foreach (var s in includePaths.Split(';', ',')) { var d = HelperFunctions.NormalizeRelativeFilePath(s); if (!d.StartsWith("$(qtdir)\\include", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(qtDir + "\\include", StringComparison.OrdinalIgnoreCase) && !d.EndsWith("win32-msvc2005", StringComparison.OrdinalIgnoreCase)) { d = d.Replace("$(ConfigurationName)", project.ConfigurationManager.ActiveConfiguration.ConfigurationName); d = d.Replace("$(PlatformName)", project.ConfigurationManager.ActiveConfiguration.PlatformName); if (HelperFunctions.IsAbsoluteFilePath(d)) { d = HelperFunctions.GetRelativePath(project.FullName, d); } if (!HelperFunctions.IsAbsoluteFilePath(d)) { option.List.Add(HelperFunctions.ChangePathFormat(d)); } } } }
private static void AddLibraries(Project project, ProFileOption option, string paths, string deps) { if (QtProject.GetFormatVersion(project) < Resources.qtMinFormatVersion_ClProperties) { return; } var versionManager = QtVersionManager.The(); var qtDir = versionManager.GetInstallPath(project); if (qtDir == null) { qtDir = Environment.GetEnvironmentVariable("QTDIR"); } if (qtDir == null) { qtDir = ""; } qtDir = HelperFunctions.NormalizeRelativeFilePath(qtDir); if (paths != null) { foreach (var s in paths.Split(';', ',')) { var d = HelperFunctions.NormalizeRelativeFilePath(s); if (!d.StartsWith("$(qtdir)\\lib", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(qtDir + "\\lib", StringComparison.OrdinalIgnoreCase)) { if (HelperFunctions.IsAbsoluteFilePath(d)) { d = HelperFunctions.GetRelativePath(project.FullName, d); } if (!HelperFunctions.IsAbsoluteFilePath(d)) { option.List.Add("-L\"" + HelperFunctions.ChangePathFormat(d) + "\""); } } } } if (deps != null) { foreach (var d in deps.Split(' ')) { if (d.Length > 0 && !d.StartsWith("$(qtdir)\\lib", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(qtDir + "\\lib", StringComparison.OrdinalIgnoreCase) && !d.StartsWith("qt", StringComparison.OrdinalIgnoreCase) && !d.StartsWith(".\\qt", StringComparison.OrdinalIgnoreCase) && d != ".") { option.List.Add("-l" + HelperFunctions.ChangePathFormat(d).Replace(".lib", "")); } } } }
public static bool IsInstalled(string moduleName) { var qtVersion = QtVersionManager.The().GetDefaultVersion(); if (qtVersion == null) { throw new QtVSException("Unable to find a Qt build!" + Environment.NewLine + "To solve this problem specify a Qt build."); } var installPath = QtVersionManager.The().GetInstallPath(qtVersion); if (moduleName.StartsWith("Qt", StringComparison.Ordinal)) { moduleName = "Qt5" + moduleName.Substring(2); } var qtVersionInfo = QtVersionManager.The().GetVersionInfo(qtVersion); var libPath = Path.Combine(installPath, "lib", string.Format("{0}{1}.lib", moduleName, qtVersionInfo.LibInfix())); return(File.Exists(libPath)); }
public void ImportProject(FileInfo mainInfo, string qtVersion) { 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.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"); } 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.PaneMessage(dteObject, "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())); } }