QbsPM: Avoid QFileInfo for paths that may non-local

Change-Id: I08b0b2c298c8f175e0c0a2d5e87691354afa46e5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Stenger
2022-02-23 12:17:34 +01:00
parent 61351da56a
commit 65a6853aec

View File

@@ -313,22 +313,20 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
if (tcCxx) if (tcCxx)
cxxCompilerPath = tcCxx->compilerCommand(); cxxCompilerPath = tcCxx->compilerCommand();
const QFileInfo cFileInfo = cCompilerPath.toFileInfo(); QString cCompilerName = cCompilerPath.fileName();
const QFileInfo cxxFileInfo = cxxCompilerPath.toFileInfo(); QString cxxCompilerName = cxxCompilerPath.fileName();
QString cCompilerName = cFileInfo.fileName();
QString cxxCompilerName = cxxFileInfo.fileName();
const QString cToolchainPrefix = extractToolchainPrefix(&cCompilerName); const QString cToolchainPrefix = extractToolchainPrefix(&cCompilerName);
const QString cxxToolchainPrefix = extractToolchainPrefix(&cxxCompilerName); const QString cxxToolchainPrefix = extractToolchainPrefix(&cxxCompilerName);
QFileInfo mainFileInfo; Utils::FilePath mainFilePath;
QString mainCompilerName; QString mainCompilerName;
QString mainToolchainPrefix; QString mainToolchainPrefix;
if (tcCxx) { if (tcCxx) {
mainFileInfo = cxxFileInfo; mainFilePath = cxxCompilerPath;
mainCompilerName = cxxCompilerName; mainCompilerName = cxxCompilerName;
mainToolchainPrefix = cxxToolchainPrefix; mainToolchainPrefix = cxxToolchainPrefix;
} else { } else {
mainFileInfo = cFileInfo; mainFilePath = cCompilerPath;
mainCompilerName = cCompilerName; mainCompilerName = cCompilerName;
mainToolchainPrefix = cToolchainPrefix; mainToolchainPrefix = cToolchainPrefix;
} }
@@ -353,11 +351,11 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
} }
if (tcC && tcCxx && !cCompilerPath.isEmpty() && !cxxCompilerPath.isEmpty() if (tcC && tcCxx && !cCompilerPath.isEmpty() && !cxxCompilerPath.isEmpty()
&& cFileInfo.absolutePath() != cxxFileInfo.absolutePath()) { && cCompilerPath.absolutePath() != cxxCompilerPath.absolutePath()) {
Core::MessageManager::writeFlashing( Core::MessageManager::writeFlashing(
tr("C and C++ compiler paths differ. C compiler may not work.")); tr("C and C++ compiler paths differ. C compiler may not work."));
} }
data.insert(QLatin1String(CPP_TOOLCHAINPATH), mainFileInfo.absolutePath()); data.insert(QLatin1String(CPP_TOOLCHAINPATH), mainFilePath.absolutePath().toString());
if (auto gcc = dynamic_cast<ProjectExplorer::GccToolChain *>(mainTc)) { if (auto gcc = dynamic_cast<ProjectExplorer::GccToolChain *>(mainTc)) {
QStringList compilerFlags = gcc->platformCodeGenFlags(); QStringList compilerFlags = gcc->platformCodeGenFlags();
@@ -372,7 +370,7 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
// Reverse engineer the Xcode developer path from the compiler path // Reverse engineer the Xcode developer path from the compiler path
const QRegularExpression compilerRe( const QRegularExpression compilerRe(
QStringLiteral("^(?<developerpath>.*)/Toolchains/(?:.+)\\.xctoolchain/usr/bin$")); QStringLiteral("^(?<developerpath>.*)/Toolchains/(?:.+)\\.xctoolchain/usr/bin$"));
const QRegularExpressionMatch compilerReMatch = compilerRe.match(cxxFileInfo.absolutePath()); const QRegularExpressionMatch compilerReMatch = compilerRe.match(cxxCompilerPath.absolutePath().toString());
if (compilerReMatch.hasMatch()) { if (compilerReMatch.hasMatch()) {
const QString developerPath = compilerReMatch.captured(QStringLiteral("developerpath")); const QString developerPath = compilerReMatch.captured(QStringLiteral("developerpath"));
data.insert(QLatin1String(XCODE_DEVELOPERPATH), developerPath); data.insert(QLatin1String(XCODE_DEVELOPERPATH), developerPath);