From 9c3f0eec68d6f2f5dba4ebf51911dc46d4a34c33 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 8 Jun 2017 10:54:03 +0200 Subject: 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 --- src/app/qbs-setup-qt/setupqt.cpp | 33 +++++++++++++++++++++++++-------- 1 file 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 #include #include +#include #include #include @@ -60,6 +61,7 @@ #include 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; -- cgit v1.2.3