forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.2'
Change-Id: I259a402bc896fc2e359cc96b7510453ac9a9a552
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,8 @@
|
||||
#include <QMessageBox>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
@@ -91,7 +93,6 @@ static const char CONFIG_INCLUDEPATHS[] = "includePaths";
|
||||
static const char CONFIG_SYSTEM_INCLUDEPATHS[] = "systemIncludePaths";
|
||||
static const char CONFIG_FRAMEWORKPATHS[] = "frameworkPaths";
|
||||
static const char CONFIG_SYSTEM_FRAMEWORKPATHS[] = "systemFrameworkPaths";
|
||||
static const char CONFIG_PRECOMPILEDHEADER[] = "precompiledHeader";
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// QbsProject:
|
||||
@@ -886,6 +887,27 @@ void QbsProject::updateCppCodeModel()
|
||||
qDeleteAll(m_extraCompilers);
|
||||
m_extraCompilers.clear();
|
||||
foreach (const qbs::ProductData &prd, m_projectData.allProducts()) {
|
||||
QString cPch;
|
||||
QString cxxPch;
|
||||
QString objcPch;
|
||||
QString objcxxPch;
|
||||
const auto &pchFinder = [&cPch, &cxxPch, &objcPch, &objcxxPch](const qbs::ArtifactData &a) {
|
||||
if (a.fileTags().contains("c_pch_src"))
|
||||
cPch = a.filePath();
|
||||
else if (a.fileTags().contains("cpp_pch_src"))
|
||||
cxxPch = a.filePath();
|
||||
else if (a.fileTags().contains("objc_pch_src"))
|
||||
objcPch = a.filePath();
|
||||
else if (a.fileTags().contains("objcpp_pch_src"))
|
||||
objcxxPch = a.filePath();
|
||||
};
|
||||
const QList<qbs::ArtifactData> &generatedArtifacts = prd.generatedArtifacts();
|
||||
std::for_each(generatedArtifacts.cbegin(), generatedArtifacts.cend(), pchFinder);
|
||||
foreach (const qbs::GroupData &grp, prd.groups()) {
|
||||
const QList<qbs::ArtifactData> &sourceArtifacts = grp.allSourceArtifacts();
|
||||
std::for_each(sourceArtifacts.cbegin(), sourceArtifacts.cend(), pchFinder);
|
||||
}
|
||||
|
||||
foreach (const qbs::GroupData &grp, prd.groups()) {
|
||||
const qbs::PropertyMap &props = grp.properties();
|
||||
|
||||
@@ -931,18 +953,26 @@ void QbsProject::updateCppCodeModel()
|
||||
|
||||
ppBuilder.setHeaderPaths(grpHeaderPaths);
|
||||
|
||||
const QString pch = props.getModuleProperty(QLatin1String(CONFIG_CPP_MODULE),
|
||||
QLatin1String(CONFIG_PRECOMPILEDHEADER)).toString();
|
||||
ppBuilder.setPreCompiledHeaders(QStringList() << pch);
|
||||
|
||||
ppBuilder.setDisplayName(grp.name());
|
||||
ppBuilder.setProjectFile(groupLocationToProjectFile(grp.location()));
|
||||
|
||||
QHash<QString, qbs::ArtifactData> filePathToSourceArtifact;
|
||||
bool hasCFiles = false;
|
||||
bool hasCxxFiles = false;
|
||||
bool hasObjcFiles = false;
|
||||
bool hasObjcxxFiles = false;
|
||||
foreach (const qbs::ArtifactData &source, grp.allSourceArtifacts()) {
|
||||
filePathToSourceArtifact.insert(source.filePath(), source);
|
||||
|
||||
foreach (const QString &tag, source.fileTags()) {
|
||||
if (tag == "c")
|
||||
hasCFiles = true;
|
||||
else if (tag == "cpp")
|
||||
hasCxxFiles = true;
|
||||
else if (tag == "objc")
|
||||
hasObjcFiles = true;
|
||||
else if (tag == "objcpp")
|
||||
hasObjcxxFiles = true;
|
||||
for (auto i = factoriesBegin; i != factoriesEnd; ++i) {
|
||||
if ((*i)->sourceTag() != tag)
|
||||
continue;
|
||||
@@ -964,6 +994,31 @@ void QbsProject::updateCppCodeModel()
|
||||
}
|
||||
}
|
||||
|
||||
QStringList pchFiles;
|
||||
if (hasCFiles && props.getModuleProperty("cpp", "useCPrecompiledHeader").toBool()
|
||||
&& !cPch.isEmpty()) {
|
||||
pchFiles << cPch;
|
||||
}
|
||||
if (hasCxxFiles && props.getModuleProperty("cpp", "useCxxPrecompiledHeader").toBool()
|
||||
&& !cxxPch.isEmpty()) {
|
||||
pchFiles << cxxPch;
|
||||
}
|
||||
if (hasObjcFiles && props.getModuleProperty("cpp", "useObjcPrecompiledHeader").toBool()
|
||||
&& !objcPch.isEmpty()) {
|
||||
pchFiles << objcPch;
|
||||
}
|
||||
if (hasObjcxxFiles
|
||||
&& props.getModuleProperty("cpp", "useObjcxxPrecompiledHeader").toBool()
|
||||
&& !objcxxPch.isEmpty()) {
|
||||
pchFiles << objcxxPch;
|
||||
}
|
||||
if (pchFiles.count() > 1) {
|
||||
qCWarning(qbsPmLog) << "More than one pch file enabled for source files in group"
|
||||
<< grp.name() << "in product" << prd.name();
|
||||
qCWarning(qbsPmLog) << "Expect problems with code model";
|
||||
}
|
||||
ppBuilder.setPreCompiledHeaders(pchFiles);
|
||||
|
||||
const QList<Id> languages = ppBuilder.createProjectPartsForFiles(
|
||||
grp.allFilePaths(),
|
||||
[filePathToSourceArtifact](const QString &filePath) {
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user