summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp56
1 files changed, 36 insertions, 20 deletions
diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp
index 6488b81d6f..93371294fa 100644
--- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp
+++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp
@@ -216,26 +216,6 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
data.insert(QLatin1String(QBS_TARGETOS), targetOS);
QStringList toolchain = toolchainList(tc);
- if (!toolchain.isEmpty())
- data.insert(QLatin1String(QBS_TOOLCHAIN), toolchain);
-
- if (targetAbi.os() == ProjectExplorer::Abi::MacOS) {
- // Reverse engineer Xcode developer path and canonical SDK name from sysroot
- QDir sysrootdir(QDir::cleanPath(sysroot));
- const QSettings sdkSettings(sysrootdir.absoluteFilePath(QLatin1String("SDKSettings.plist")), QSettings::NativeFormat);
- const QString sdkCanonicalName(sdkSettings.value(QLatin1String("CanonicalName")).toString());
- if (!sdkCanonicalName.isEmpty()) {
- const QRegularExpression re(QStringLiteral("^(?<developerpath>.*)/Platforms/(?<platform>MacOSX|(?:(?:iPhone|AppleTV|Watch)(?:OS|Simulator)))\\.platform/Developer/SDKs/(?<sdkplatform>MacOSX|(?:(?:iPhone|AppleTV|Watch)(?:OS|Simulator)))(?:[0-9]+\\.[0-9]+)\\.sdk/?$"));
- const QRegularExpressionMatch match = re.match(sysrootdir.absolutePath());
- if (match.hasMatch() &&
- match.captured(QStringLiteral("platform")) ==
- match.captured(QStringLiteral("sdkplatform"))) {
- data.insert(QLatin1String(XCODE_DEVELOPERPATH),
- match.captured(QStringLiteral("developerpath")));
- data.insert(QLatin1String(XCODE_SDK), sdkCanonicalName);
- }
- }
- }
Utils::FileName cxx = tc->compilerCommand();
const QFileInfo cxxFileInfo = cxx.toFileInfo();
@@ -262,6 +242,42 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor
data.insert(QLatin1String(CPP_PLATFORMLINKERFLAGS), gcc->platformLinkerFlags());
}
+ if (targetAbi.os() == ProjectExplorer::Abi::MacOS) {
+ // Reverse engineer the Xcode developer path from the compiler path
+ const QRegularExpression compilerRe(
+ QStringLiteral("^(?<developerpath>.*)/Toolchains/(?:.+)\\.xctoolchain/usr/bin$"));
+ const QRegularExpressionMatch compilerReMatch = compilerRe.match(cxxFileInfo.absolutePath());
+ if (compilerReMatch.hasMatch()) {
+ const QString developerPath = compilerReMatch.captured(QStringLiteral("developerpath"));
+ data.insert(QLatin1String(XCODE_DEVELOPERPATH), developerPath);
+ toolchain.insert(0, QStringLiteral("xcode"));
+
+ // If the sysroot is part of this developer path, set the canonical SDK name
+ const QDir sysrootdir(QDir::cleanPath(sysroot));
+ const QString sysrootAbs = sysrootdir.absolutePath();
+ const QSettings sdkSettings(
+ sysrootdir.absoluteFilePath(QStringLiteral("SDKSettings.plist")),
+ QSettings::NativeFormat);
+ const QString version(
+ sdkSettings.value(QStringLiteral("Version")).toString());
+ QString canonicalName(
+ sdkSettings.value(QStringLiteral("CanonicalName")).toString());
+ canonicalName.chop(version.size());
+ if (!canonicalName.isEmpty() && !version.isEmpty()
+ && sysrootAbs.startsWith(developerPath)) {
+ if (sysrootAbs.toLower().endsWith(QStringLiteral("/%1.sdk")
+ .arg(canonicalName + version)))
+ data.insert(QLatin1String(XCODE_SDK), canonicalName + version);
+ if (sysrootAbs.toLower().endsWith(QStringLiteral("/%1.sdk")
+ .arg(canonicalName)))
+ data.insert(QLatin1String(XCODE_SDK), canonicalName);
+ }
+ }
+ }
+
+ if (!toolchain.isEmpty())
+ data.insert(QLatin1String(QBS_TOOLCHAIN), toolchain);
+
return data;
}