diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-06-08 10:54:03 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2017-06-09 09:58:58 +0000 |
commit | 9c3f0eec68d6f2f5dba4ebf51911dc46d4a34c33 (patch) | |
tree | 7316c1890712affc154ac065564cb56df9dd61fd | |
parent | 298e119ae4c4fe6c8687083b03a60a451600d482 (diff) |
setup-qt: compress MSVC profiles even when Qt's MSVC version is unknown
"Compressing" MSVC profiles means that if MSVC2017-x64 and
MSVC2017-x86_x64 fully match, then we drop MSVC2017-x86_x64 and connect
the Qt profile to the former.
This compression took place only if there was a valid Qt version. Do the
compression always now, and take care that we throw out the right
cross-compiler toolchains.
While this patch does not fully fix QBS-1141, it alleviates the symptoms
if only one MSVC is installed, which is usually the case.
Task-number: QBS-1141
Change-Id: Ied766b6051074fbb92037185f2a357bcdbc55b68
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r-- | src/app/qbs-setup-qt/setupqt.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/app/qbs-setup-qt/setupqt.cpp b/src/app/qbs-setup-qt/setupqt.cpp index 0abbaaa67..2f4643b55 100644 --- a/src/app/qbs-setup-qt/setupqt.cpp +++ b/src/app/qbs-setup-qt/setupqt.cpp @@ -47,6 +47,7 @@ #include <tools/profile.h> #include <tools/set.h> #include <tools/settings.h> +#include <tools/stlutils.h> #include <tools/version.h> #include <QtCore/qbytearraymatcher.h> @@ -60,6 +61,7 @@ #include <algorithm> namespace qbs { +using Internal::contains; using Internal::HostOsInfo; using Internal::Tr; using Internal::Version; @@ -484,18 +486,33 @@ static Match compatibility(const QtEnvironment &env, const Profile &toolchainPro return match; } -static bool isMsvcCrossCompilerProfile(const QString &profileName) +QString profileNameWithoutHostArch(const QString &profileName) { - return profileName.contains(QLatin1Char('_')); + QString result; + int i = profileName.indexOf(QLatin1Char('-')); + if (i == -1) + return result; + ++i; + int j = profileName.indexOf(QLatin1Char('_'), i); + if (j == -1) + return result; + result = profileName.mid(0, i) + profileName.mid(j + 1); + return result; } +// "Compressing" MSVC profiles means that if MSVC2017-x64 and MSVC2017-x86_x64 fully match, +// then we drop the crosscompiling toolchain MSVC2017-x86_x64. static void compressMsvcProfiles(QStringList &profiles) { - if (std::all_of(profiles.constBegin(), profiles.constEnd(), isMsvcCrossCompilerProfile)) - return; - - profiles.erase(std::remove_if(profiles.begin(), profiles.end(), isMsvcCrossCompilerProfile), - profiles.end()); + auto it = std::remove_if(profiles.begin(), profiles.end(), + [&profiles] (const QString &profileName) { + int idx = profileName.indexOf(QLatin1Char('_')); + if (idx == -1) + return false; + return contains(profiles, profileNameWithoutHostArch(profileName)); + }); + if (it != profiles.end()) + profiles.erase(it, profiles.end()); } void SetupQt::saveToQbsSettings(const QString &qtVersionName, const QtEnvironment &qtEnvironment, @@ -541,7 +558,7 @@ void SetupQt::saveToQbsSettings(const QString &qtVersionName, const QtEnvironmen } } - if (msvcCompilerVersion.isValid() && fullMatches.size() > 1) + if (fullMatches.size() > 1) compressMsvcProfiles(fullMatches); QString bestMatch; |