forked from qt-creator/qt-creator
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 d121fefaa9
Change-Id: I73cf1a50acd6b99a9fc3b6003bcc6dc23c2a04ab
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user