forked from qt-creator/qt-creator
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 <christian.kandeler@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user