forked from qt-creator/qt-creator
QbsProjectManager: Fix importing Qt projects on macOS
On macOS, qbs always sets the sysroot to the xcode directory, while Qt Creator's kits do not have a sysroot entry for Desktop targets. Fixes: QTCREATORBUG-29829 Change-Id: I3f11c45fdcd94e67be1b6ef6c50cd33834c74f40 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -40,6 +41,7 @@ struct BuildGraphData
|
|||||||
FilePath qtBinPath;
|
FilePath qtBinPath;
|
||||||
FilePath sysroot;
|
FilePath sysroot;
|
||||||
QString buildVariant;
|
QString buildVariant;
|
||||||
|
QStringList targetOS;
|
||||||
};
|
};
|
||||||
static BuildGraphData extractBgData(const QbsSession::BuildGraphInfo &bgInfo)
|
static BuildGraphData extractBgData(const QbsSession::BuildGraphInfo &bgInfo)
|
||||||
{
|
{
|
||||||
@@ -50,7 +52,8 @@ static BuildGraphData extractBgData(const QbsSession::BuildGraphInfo &bgInfo)
|
|||||||
const QVariantMap prjCompilerPathByLanguage
|
const QVariantMap prjCompilerPathByLanguage
|
||||||
= moduleProps.value("cpp.compilerPathByLanguage").toMap();
|
= moduleProps.value("cpp.compilerPathByLanguage").toMap();
|
||||||
const QString prjCompilerPath = moduleProps.value("cpp.compilerPath").toString();
|
const QString prjCompilerPath = moduleProps.value("cpp.compilerPath").toString();
|
||||||
const QStringList prjToolchain = moduleProps.value("qbs.toolchain").toStringList();
|
const QStringList prjToolchain = arrayToStringList(
|
||||||
|
moduleProps.value("qbs.toolchain").toJsonArray());
|
||||||
const bool prjIsMsvc = prjToolchain.contains("msvc");
|
const bool prjIsMsvc = prjToolchain.contains("msvc");
|
||||||
bgData.cCompilerPath = FilePath::fromString(
|
bgData.cCompilerPath = FilePath::fromString(
|
||||||
prjIsMsvc ? prjCompilerPath : prjCompilerPathByLanguage.value("c").toString());
|
prjIsMsvc ? prjCompilerPath : prjCompilerPathByLanguage.value("c").toString());
|
||||||
@@ -59,6 +62,7 @@ static BuildGraphData extractBgData(const QbsSession::BuildGraphInfo &bgInfo)
|
|||||||
bgData.qtBinPath = FilePath::fromString(moduleProps.value("Qt.core.binPath").toString());
|
bgData.qtBinPath = FilePath::fromString(moduleProps.value("Qt.core.binPath").toString());
|
||||||
bgData.sysroot = FilePath::fromString(moduleProps.value("qbs.sysroot").toString());
|
bgData.sysroot = FilePath::fromString(moduleProps.value("qbs.sysroot").toString());
|
||||||
bgData.buildVariant = moduleProps.value("qbs.buildVariant").toString();
|
bgData.buildVariant = moduleProps.value("qbs.buildVariant").toString();
|
||||||
|
bgData.targetOS = arrayToStringList(moduleProps.value("qbs.targetOS").toJsonArray());
|
||||||
return bgData;
|
return bgData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +120,7 @@ QList<void *> QbsProjectImporter::examineDirectory(const FilePath &importPath,
|
|||||||
QList<void *> data;
|
QList<void *> data;
|
||||||
const FilePath bgFilePath = importPath.pathAppended(importPath.fileName() + ".bg");
|
const FilePath bgFilePath = importPath.pathAppended(importPath.fileName() + ".bg");
|
||||||
const QStringList relevantProperties({
|
const QStringList relevantProperties({
|
||||||
"qbs.buildVariant", "qbs.sysroot", "qbs.toolchain",
|
"qbs.buildVariant", "qbs.sysroot", "qbs.targetOS", "qbs.toolchain",
|
||||||
"cpp.compilerPath", "cpp.compilerPathByLanguage",
|
"cpp.compilerPath", "cpp.compilerPathByLanguage",
|
||||||
"Qt.core.binPath"
|
"Qt.core.binPath"
|
||||||
});
|
});
|
||||||
@@ -162,7 +166,7 @@ bool QbsProjectImporter::matchKit(void *directoryData, const Kit *k) const
|
|||||||
if (bgData->qtBinPath != qtVersion->hostBinPath())
|
if (bgData->qtBinPath != qtVersion->hostBinPath())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (bgData->sysroot != SysRootKitAspect::sysRoot(k))
|
if (!bgData->targetOS.contains("macos") && bgData->sysroot != SysRootKitAspect::sysRoot(k))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qCDebug(qbsPmLog) << "Kit matches";
|
qCDebug(qbsPmLog) << "Kit matches";
|
||||||
|
Reference in New Issue
Block a user