diff options
author | Eike Ziller <eike.ziller@qt.io> | 2016-11-21 17:01:15 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2016-11-21 17:01:15 +0100 |
commit | 0596699dbd0e36c1aa5d75939fd2fad2d55eec37 (patch) | |
tree | 310d65e389a5d763813c59403e48b393a8716985 /src | |
parent | 584a8c2afea8436ae8c66f21636565e17195ef4d (diff) | |
parent | bc6f90cb2a811269d3559c948ad4e7dce7757c63 (diff) | |
download | qt-creator-0596699dbd0e36c1aa5d75939fd2fad2d55eec37.tar.gz |
Merge remote-tracking branch 'origin/4.1' into 4.2
Conflicts:
src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp
src/plugins/qbsprojectmanager/qbsconstants.h
Change-Id: I3800e580faaccdc1dd08da851956ba677d33df51
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp | 80 | ||||
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h | 5 |
2 files changed, 60 insertions, 25 deletions
diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index 703f41305b..0b5ce6d1c1 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -45,6 +45,7 @@ #include <QDir> #include <QFileInfo> +#include <QRegularExpression> #include <QSettings> namespace QbsProjectManager { @@ -158,6 +159,20 @@ QVariantMap DefaultPropertyProvider::properties(const ProjectExplorer::Kit *k, return data; } +static void filterCompilerLinkerFlags(const ProjectExplorer::Abi &targetAbi, QStringList &flags) +{ + for (int i = 0; i < flags.size(); ) { + if (targetAbi.architecture() != ProjectExplorer::Abi::UnknownArchitecture + && flags[i] == QStringLiteral("-arch") + && i + 1 < flags.size()) { + flags.removeAt(i); + flags.removeAt(i); + } else { + ++i; + } + } +} + QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplorer::Kit *k, const QVariantMap &defaultData) const { @@ -208,26 +223,6 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor data.insert(QLatin1String(QBS_TARGETOS), targetOS); QStringList toolchain = toolchainList(mainTc); - if (!toolchain.isEmpty()) - data.insert(QLatin1String(QBS_TOOLCHAIN), toolchain); - - if (targetAbi.os() == ProjectExplorer::Abi::DarwinOS) { - // Set Xcode SDK name and version - required by Qbs if a sysroot is present - // Ideally this would be done in a better way... - const QRegExp sdkNameRe(QLatin1String("(macosx|iphoneos|iphonesimulator)([0-9]+\\.[0-9]+)")); - const QRegExp sdkVersionRe(QLatin1String("([0-9]+\\.[0-9]+)")); - QDir sysrootdir(sysroot); - const QSettings sdkSettings(sysrootdir.absoluteFilePath(QLatin1String("SDKSettings.plist")), QSettings::NativeFormat); - const QString sdkName(sdkSettings.value(QLatin1String("CanonicalName")).toString()); - const QString sdkVersion(sdkSettings.value(QLatin1String("Version")).toString()); - if (sdkNameRe.exactMatch(sdkName) && sdkVersionRe.exactMatch(sdkVersion)) { - for (int i = 3; i > 0; --i) - sysrootdir.cdUp(); - data.insert(QLatin1String(CPP_PLATFORMPATH), sysrootdir.absolutePath()); - data.insert(QLatin1String(CPP_XCODESDKNAME), sdkName); - data.insert(QLatin1String(CPP_XCODESDKVERSION), sdkVersion); - } - } Utils::FileName cCompilerPath; if (tcC) @@ -276,10 +271,51 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor data.insert(QLatin1String(CPP_TOOLCHAINPATH), mainFileInfo.absolutePath()); if (ProjectExplorer::GccToolChain *gcc = dynamic_cast<ProjectExplorer::GccToolChain *>(mainTc)) { - data.insert(QLatin1String(CPP_PLATFORMCOMMONCOMPILERFLAGS), gcc->platformCodeGenFlags()); - data.insert(QLatin1String(CPP_PLATFORMLINKERFLAGS), gcc->platformLinkerFlags()); + QStringList compilerFlags = gcc->platformCodeGenFlags(); + filterCompilerLinkerFlags(targetAbi, compilerFlags); + data.insert(QLatin1String(CPP_PLATFORMCOMMONCOMPILERFLAGS), compilerFlags); + + QStringList linkerFlags = gcc->platformLinkerFlags(); + filterCompilerLinkerFlags(targetAbi, linkerFlags); + data.insert(QLatin1String(CPP_PLATFORMLINKERFLAGS), linkerFlags); + } + + if (targetAbi.os() == ProjectExplorer::Abi::DarwinOS) { + // 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), QString(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; } diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h b/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h index 36fd3cfb28..8952a1d194 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h +++ b/src/plugins/qbsprojectmanager/qbsprojectmanagerconstants.h @@ -76,9 +76,8 @@ const char CPP_COMPILERNAME[] = "cpp.compilerName"; const char CPP_CXXCOMPILERNAME[] = "cpp.cxxCompilerName"; const char CPP_PLATFORMCOMMONCOMPILERFLAGS[] = "cpp.platformCommonCompilerFlags"; const char CPP_PLATFORMLINKERFLAGS[] = "cpp.platformLinkerFlags"; -const char CPP_PLATFORMPATH[] = "cpp.platformPath"; -const char CPP_XCODESDKNAME[] = "cpp.xcodeSdkName"; -const char CPP_XCODESDKVERSION[] = "cpp.xcodeSdkVersion"; +const char XCODE_DEVELOPERPATH[] = "xcode.developerPath"; +const char XCODE_SDK[] = "xcode.sdk"; // Settings page const char QBS_SETTINGS_CATEGORY[] = "YM.qbs"; |