From 3ad7ef479612a8a0c3ca401e692ef47cfeef01fc Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 16 Mar 2020 17:35:15 +0300 Subject: [PATCH] QbsPM: Fix wrong {GCC|Clang} compiler name and prefix handling When the GCC or Clang compiler name ends with the version sub-string (f.e. arm-none-eabi-gcc-8.2.1.exe), this leads to the wrong cCompilerName detection, that causes the project parsing errors and disables the project: The following properties are not set. Set them in your profile or product: cpp.compilerIncludePaths cpp.compilerFrameworkPaths cpp.compilerLibraryPaths Product 'xyz' had errors and was disabled. Now we return a proper prefix (e.g. arm-none-eabi-) and cCompilerName with a version (e.g. 'gcc-8.2.1.exe') Change-Id: I5dd42a343a0982326ed0f23b821e5016b8df39f1 Reviewed-by: Christian Kandeler --- .../defaultpropertyprovider.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index f930d1d7af7..4f373b8ee34 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -65,14 +65,14 @@ static QString extractToolchainPrefix(QString *compilerName) QString prefix; const QStringList candidates = {QLatin1String("g++"), QLatin1String("clang++"), QLatin1String("gcc"), QLatin1String("clang")}; - foreach (const QString &candidate, candidates) { - const QString suffix = Utils::HostOsInfo::withExecutableSuffix(QLatin1Char('-') - + candidate); - if (compilerName->endsWith(suffix)) { - const int idx = compilerName->lastIndexOf(QLatin1Char('-')) + 1; - prefix = compilerName->left(idx); - compilerName->remove(0, idx); - } + for (const QString &candidate : candidates) { + const QString suffix = QLatin1Char('-') + candidate; + const int suffixIndex = compilerName->lastIndexOf(suffix); + if (suffixIndex == -1) + continue; + prefix = compilerName->left(suffixIndex + 1); + compilerName->remove(0, suffixIndex + 1); + break; } return prefix; }