aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2016-11-10 23:18:05 -0800
committerJake Petroules <jake.petroules@qt.io>2016-11-11 10:28:44 +0000
commita8bb2af30e1b4454ee81518a3b268ee78739ba04 (patch)
tree3a84af5ef6e875306d0d953f3281654f39184204
parent2380757199b616129dc95b78139b6448c9fe6f9a (diff)
Qbs: fix Xcode SDK detection (take 2)
This adds xcode to the toolchain list, which is required to load the Xcode module. It also uses the compiler path as the mechanism to find the developer path, and then extracts the canonical SDK name using the sysroot if it's a valid one for the previously extracted developer path. amends d121fefaa9631fa482bca534cf3d8d0f15b5ffc3 Change-Id: I73cf1a50acd6b99a9fc3b6003bcc6dc23c2a04ab Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-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;
}