aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-06-08 16:29:41 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-06-09 09:59:02 +0000
commit7ccc08f33153cd3093081567ac653e371759d69a (patch)
treeb9fa6f8caefd4f53ad1e69d95d5dfc6768871cf3
parent9c3f0eec68d6f2f5dba4ebf51911dc46d4a34c33 (diff)
setup-qt: Fix automatic base profile assignment for MSVC Qt's
Read MSVC version from qconfig.pri instead of trying to guess it from the mkspec name. The latter is broken since the introduction of the common win32-msvc mkspec for all MSVC versions. Change-Id: I24bd2d5b4935dbba2e296b15d4e6a553393eca3a Task-number: QBS-1141 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/app/qbs-setup-qt/setupqt.cpp108
-rw-r--r--src/lib/qtprofilesetup/qtenvironment.h2
2 files changed, 64 insertions, 46 deletions
diff --git a/src/app/qbs-setup-qt/setupqt.cpp b/src/app/qbs-setup-qt/setupqt.cpp
index 2f4643b55..481042f8e 100644
--- a/src/app/qbs-setup-qt/setupqt.cpp
+++ b/src/app/qbs-setup-qt/setupqt.cpp
@@ -187,6 +187,41 @@ static QString pathQueryValue(const QueryMap &queryMap, const QByteArray &key)
return QDir::fromNativeSeparators(QString::fromLocal8Bit(queryMap.value(key)));
}
+static const QString msvcPrefix = QLatin1String("win32-msvc");
+
+static bool isMsvcQt(const QtEnvironment &env)
+{
+ return env.mkspecName.startsWith(msvcPrefix);
+}
+
+static Version msvcCompilerVersionForYear(int year)
+{
+ switch (year)
+ {
+ case 2005:
+ return Version(14);
+ case 2008:
+ return Version(15);
+ case 2010:
+ return Version(16);
+ case 2012:
+ return Version(17);
+ case 2013:
+ return Version(18);
+ case 2015:
+ return Version(19);
+ case 2017:
+ return Version(19, 1);
+ default:
+ return Version();
+ }
+}
+
+static Version msvcCompilerVersionFromMkspecName(const QString &mkspecName)
+{
+ return msvcCompilerVersionForYear(mkspecName.mid(msvcPrefix.size()).toInt());
+}
+
QtEnvironment SetupQt::fetchEnvironment(const QString &qmakePath)
{
QtEnvironment qtEnvironment;
@@ -275,6 +310,26 @@ QtEnvironment SetupQt::fetchEnvironment(const QString &qmakePath)
qtEnvironment.mkspecName.remove(0, idx + 1);
}
+ // determine MSVC version
+ if (isMsvcQt(qtEnvironment)) {
+ bool ok;
+ qtEnvironment.msvcVersion.setMajorVersion(
+ configVariable(qconfigContent,
+ QLatin1String("QT_MSVC_MAJOR_VERSION")).toInt(&ok));
+ if (ok) {
+ qtEnvironment.msvcVersion.setMinorVersion(
+ configVariable(qconfigContent,
+ QLatin1String("QT_MSVC_MINOR_VERSION")).toInt(&ok));
+ }
+ if (ok) {
+ qtEnvironment.msvcVersion.setPatchLevel(
+ configVariable(qconfigContent,
+ QLatin1String("QT_MSVC_PATCH_VERSION")).toInt(&ok));
+ }
+ if (!ok)
+ qtEnvironment.msvcVersion = msvcCompilerVersionFromMkspecName(qtEnvironment.mkspecName);
+ }
+
// determine whether we have a framework build
qtEnvironment.frameworkBuild = qtEnvironment.mkspecPath.contains(QLatin1String("macx"))
&& qtEnvironment.configItems.contains(QLatin1String("qt_framework"));
@@ -402,47 +457,9 @@ static QStringList qbsToolchainFromQtMkspec(const QString &mkspec)
return QStringList();
}
-static const QString msvcPrefix = QLatin1String("win32-msvc");
-
-static bool isMsvcQt(const QtEnvironment &env)
-{
- return env.mkspecName.startsWith(msvcPrefix);
-}
-
-static Version msvcCompilerVersionForYear(int year)
-{
- switch (year)
- {
- case 2005:
- return Version(14);
- case 2008:
- return Version(15);
- case 2010:
- return Version(16);
- case 2012:
- return Version(17);
- case 2013:
- return Version(18);
- case 2015:
- return Version(19);
- case 2017:
- return Version(19, 1);
- default:
- return Version();
- }
-}
-
-static Version msvcCompilerVersionForYear(const QtEnvironment &env)
-{
- return isMsvcQt(env)
- ? msvcCompilerVersionForYear(env.mkspecName.mid(msvcPrefix.size()).toInt())
- : Version();
-}
-
enum Match { MatchFull, MatchPartial, MatchNone };
-static Match compatibility(const QtEnvironment &env, const Profile &toolchainProfile,
- const Version &msvcCompilerVersion)
+static Match compatibility(const QtEnvironment &env, const Profile &toolchainProfile)
{
Match match = MatchFull;
@@ -472,15 +489,15 @@ static Match compatibility(const QtEnvironment &env, const Profile &toolchainPro
canonicalArchitecture(toolchainArchitecture)))
return MatchNone;
- if (msvcCompilerVersion.isValid()) {
+ if (env.msvcVersion.isValid()) {
// We want to know for sure that MSVC compiler versions match,
// because it's especially important for this toolchain
- const Version fullCompilerVersion = Version::fromString(
+ const Version compilerVersion = Version::fromString(
toolchainProfile.value(QLatin1String("cpp.compilerVersion")).toString());
- const Version shortCompilerVersion = Version(fullCompilerVersion.majorVersion(),
- fullCompilerVersion.minorVersion());
- if (msvcCompilerVersion != shortCompilerVersion)
+ if (env.msvcVersion.majorVersion() != compilerVersion.majorVersion()
+ || env.msvcVersion.minorVersion() != compilerVersion.minorVersion()) {
return MatchNone;
+ }
}
return match;
@@ -538,7 +555,6 @@ void SetupQt::saveToQbsSettings(const QString &qtVersionName, const QtEnvironmen
QStringList fullMatches;
QStringList partialMatches;
- const Version msvcCompilerVersion = msvcCompilerVersionForYear(qtEnvironment);
foreach (const QString &profileName, settings->profiles()) {
const Profile otherProfile(profileName, settings);
if (profileName == profile.name()
@@ -546,7 +562,7 @@ void SetupQt::saveToQbsSettings(const QString &qtVersionName, const QtEnvironmen
|| isQtProfile(otherProfile))
continue;
- switch (compatibility(qtEnvironment, otherProfile, msvcCompilerVersion)) {
+ switch (compatibility(qtEnvironment, otherProfile)) {
case MatchFull:
fullMatches << profileName;
break;
diff --git a/src/lib/qtprofilesetup/qtenvironment.h b/src/lib/qtprofilesetup/qtenvironment.h
index f78a8f359..b3450086f 100644
--- a/src/lib/qtprofilesetup/qtenvironment.h
+++ b/src/lib/qtprofilesetup/qtenvironment.h
@@ -40,6 +40,7 @@
#define QBS_QTENVIRONMENT_H
#include <tools/qbs_export.h>
+#include <tools/version.h>
#include <QtCore/qstringlist.h>
@@ -71,6 +72,7 @@ public:
int qtMajorVersion;
int qtMinorVersion;
int qtPatchVersion;
+ Internal::Version msvcVersion;
bool staticBuild = false;
bool frameworkBuild = false;
};