diff options
author | Miguel Costa <miguel.costa@qt.io> | 2018-03-07 14:54:37 +0100 |
---|---|---|
committer | Miguel Costa <miguel.costa@qt.io> | 2018-03-09 11:11:39 +0000 |
commit | c10dab01fd66a67e2943b654017522373affc6ec (patch) | |
tree | dd99a5a78db21c65a736efad4e0b5dea97c066af | |
parent | 09616abf657596c5a725ad2f075744adda2f1cd5 (diff) |
Fix not using Qt installation if built with -qtlibinfix
Checks if a Qt installation was built with -qtlibinfix and, if so, uses
the infix to obtain the correct file names of DLL's and library files.
Previously, the infix was not taken into account, which meant that the
additional libraries information was incorrectly generated and, in
v2.2.0, Qt versions built with -qtlibinfix were not usable.
Task-number: QTVSADDINBUG-506
Change-Id: I9540bb8e43d8bf97ac303d212f90e8349b9532d7
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r-- | src/qtprojectlib/QtConfig.cs | 39 | ||||
-rw-r--r-- | src/qtprojectlib/QtModuleInfo.cs | 11 | ||||
-rw-r--r-- | src/qtprojectlib/VersionInformation.cs | 10 | ||||
-rw-r--r-- | src/qtvstools/FormProjectQtSettings.cs | 7 |
4 files changed, 48 insertions, 19 deletions
diff --git a/src/qtprojectlib/QtConfig.cs b/src/qtprojectlib/QtConfig.cs index f737159b..5431bf99 100644 --- a/src/qtprojectlib/QtConfig.cs +++ b/src/qtprojectlib/QtConfig.cs @@ -28,6 +28,7 @@ using System; using System.IO; +using System.Text.RegularExpressions; namespace QtProjectLib { @@ -38,36 +39,48 @@ namespace QtProjectLib } /// <summary> - /// A very simple reader for the qconfig.pri file. At the moment this is only to determine - /// whether we have a static or shared Qt build. + /// A very simple reader for the qconfig.pri file. /// </summary> class QtConfig { public BuildType BuildType { get; private set; } + public string LibInfix { get; private set; } + public QtConfig(string qtdir) { + LibInfix = string.Empty; + var fi = new FileInfo(qtdir + "\\mkspecs\\qconfig.pri"); if (!fi.Exists) return; + var variableDef = new Regex(@"^\s*(\w+)\s*([\+\-]?\=)(.*)"); try { using (var reader = new StreamReader(fi.FullName)) { string line; while ((line = reader.ReadLine()) != null) { - line = line.Trim(); - if (!line.StartsWith("CONFIG", StringComparison.Ordinal)) + var match = variableDef.Match(line); + if (!match.Success || match.Groups.Count < 4) continue; - var values = line.Substring(6).Split(' ', '\t'); - foreach (var value in values) { - switch (value) { - case "static": - BuildType = BuildType.Static; - return; - case "shared": - BuildType = BuildType.Shared; - return; + + var name = match.Groups[1].Value; + var oper = match.Groups[2].Value; + var data = match.Groups[3].Value; + if (name == "CONFIG") { + var values = data.Split(new char[] { ' ', '\t' }, + StringSplitOptions.RemoveEmptyEntries); + foreach (var value in values) { + if (value == "static") { + BuildType = BuildType.Static; + break; + } else if (value == "shared") { + BuildType = BuildType.Shared; + break; + } } + } else if (name == "QT_LIBINFIX") { + LibInfix = data.Trim(); } } } diff --git a/src/qtprojectlib/QtModuleInfo.cs b/src/qtprojectlib/QtModuleInfo.cs index 886252ba..10b7d4a3 100644 --- a/src/qtprojectlib/QtModuleInfo.cs +++ b/src/qtprojectlib/QtModuleInfo.cs @@ -64,16 +64,17 @@ namespace QtProjectLib public List<string> GetLibs(bool isDebugCfg, VersionInformation vi) { - return GetLibs(isDebugCfg, vi.IsStaticBuild()); + return GetLibs(isDebugCfg, vi.IsStaticBuild(), vi.LibInfix()); } - public List<string> GetLibs(bool isDebugCfg, bool isStaticBuild) + public List<string> GetLibs(bool isDebugCfg, bool isStaticBuild, string libInfix) { // TODO: isStaticBuild is never used. var libs = new List<string>(); var libName = LibraryPrefix; if (libName.StartsWith("Qt", StringComparison.Ordinal)) libName = "Qt5" + libName.Substring(2); + libName += libInfix; if (isDebugCfg) libName += "d"; libName += ".lib"; @@ -101,7 +102,11 @@ namespace QtProjectLib if (moduleName.StartsWith("Qt", StringComparison.Ordinal)) moduleName = "Qt5" + moduleName.Substring(2); - return new FileInfo(Path.Combine(installPath, "lib", moduleName + ".lib")).Exists; + var qtVersionInfo = QtVersionManager.The().GetVersionInfo(qtVersion); + var libPath = Path.Combine(installPath, "lib", + string.Format("{0}{1}.lib", moduleName, qtVersionInfo.LibInfix())); + + return File.Exists(libPath); } } } diff --git a/src/qtprojectlib/VersionInformation.cs b/src/qtprojectlib/VersionInformation.cs index 64f6aeee..4e06c547 100644 --- a/src/qtprojectlib/VersionInformation.cs +++ b/src/qtprojectlib/VersionInformation.cs @@ -133,6 +133,13 @@ namespace QtProjectLib return qtConfig.BuildType == BuildType.Static; } + public string LibInfix() + { + if (qtConfig == null) + qtConfig = new QtConfig(qtDir); + return qtConfig.LibInfix; + } + public string GetQMakeConfEntry(string entryName) { if (qmakeConf == null) @@ -201,7 +208,8 @@ namespace QtProjectLib public bool is64Bit() { - var fileToCheck = qtDir + "\\bin\\Qt5Core.dll"; + var fileToCheck = Path.Combine(qtDir, + "bin", string.Format("Qt5Core{0}.dll", LibInfix())); if (!File.Exists(fileToCheck)) throw new QtVSException("Can't find " + fileToCheck); diff --git a/src/qtvstools/FormProjectQtSettings.cs b/src/qtvstools/FormProjectQtSettings.cs index 43f7f92b..d164b471 100644 --- a/src/qtvstools/FormProjectQtSettings.cs +++ b/src/qtvstools/FormProjectQtSettings.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using System.IO; namespace QtVsTools { @@ -140,11 +141,13 @@ namespace QtVsTools // Disable if module not installed var info = QtModules.Instance.ModuleInformation(item.moduleId); - if (info != null) { + var versionInfo = versionManager.GetVersionInfo(qtVersion); + if (info != null && versionInfo != null) { var libraryPrefix = info.LibraryPrefix; if (libraryPrefix.StartsWith("Qt", StringComparison.Ordinal)) libraryPrefix = "Qt5" + libraryPrefix.Substring(2); - var full_path = install_path + "\\lib\\" + libraryPrefix + ".lib"; + var full_path = Path.Combine(install_path, "lib", + string.Format("{0}{1}.lib", libraryPrefix, versionInfo.LibInfix())); var fi = new System.IO.FileInfo(full_path); item.checkbox.Enabled = fi.Exists; if (fi.Exists == false) { |