forked from qt-creator/qt-creator
QbsProjectManager: Refactor raw project part creation
No functional changes. Preparation for bugfix. Change-Id: Ib391a597b2ba615250b1219451f7dc537476f8af Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -847,49 +847,26 @@ static void getExpandedCompilerFlags(QStringList &cFlags, QStringList &cxxFlags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RawProjectParts generateProjectParts(
|
static RawProjectPart generateProjectPart(
|
||||||
const QJsonObject &projectData,
|
const QJsonObject &product,
|
||||||
|
const QJsonObject &group,
|
||||||
const std::shared_ptr<const ToolChain> &cToolChain,
|
const std::shared_ptr<const ToolChain> &cToolChain,
|
||||||
const std::shared_ptr<const ToolChain> &cxxToolChain,
|
const std::shared_ptr<const ToolChain> &cxxToolChain,
|
||||||
QtMajorVersion qtVersion
|
QtMajorVersion qtVersion,
|
||||||
|
QString cPch,
|
||||||
|
QString cxxPch,
|
||||||
|
QString objcPch,
|
||||||
|
QString objcxxPch
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
RawProjectParts rpps;
|
const QString productName = product.value("full-display-name").toString();
|
||||||
forAllProducts(projectData, [&](const QJsonObject &prd) {
|
const QString groupName = group.value("name").toString();
|
||||||
const QString productName = prd.value("full-display-name").toString();
|
|
||||||
QString cPch;
|
|
||||||
QString cxxPch;
|
|
||||||
QString objcPch;
|
|
||||||
QString objcxxPch;
|
|
||||||
const auto &pchFinder = [&cPch, &cxxPch, &objcPch, &objcxxPch](const QJsonObject &artifact) {
|
|
||||||
const QJsonArray fileTags = artifact.value("file-tags").toArray();
|
|
||||||
if (fileTags.contains("c_pch_src"))
|
|
||||||
cPch = artifact.value("file-path").toString();
|
|
||||||
if (fileTags.contains("cpp_pch_src"))
|
|
||||||
cxxPch = artifact.value("file-path").toString();
|
|
||||||
if (fileTags.contains("objc_pch_src"))
|
|
||||||
objcPch = artifact.value("file-path").toString();
|
|
||||||
if (fileTags.contains("objcpp_pch_src"))
|
|
||||||
objcxxPch = artifact.value("file-path").toString();
|
|
||||||
};
|
|
||||||
forAllArtifacts(prd, ArtifactType::All, pchFinder);
|
|
||||||
|
|
||||||
const Utils::QtMajorVersion qtVersionForPart
|
|
||||||
= prd.value("module-properties").toObject().value("Qt.core.version").isUndefined()
|
|
||||||
? Utils::QtMajorVersion::None
|
|
||||||
: qtVersion;
|
|
||||||
|
|
||||||
const QJsonArray groups = prd.value("groups").toArray();
|
|
||||||
for (const QJsonValue &g : groups) {
|
|
||||||
const QJsonObject grp = g.toObject();
|
|
||||||
const QString groupName = grp.value("name").toString();
|
|
||||||
|
|
||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setQtVersion(qtVersionForPart);
|
rpp.setQtVersion(qtVersion);
|
||||||
QJsonObject props = grp.value("module-properties").toObject();
|
QJsonObject props = group.value("module-properties").toObject();
|
||||||
if (props.isEmpty())
|
if (props.isEmpty())
|
||||||
props = prd.value("module-properties").toObject();
|
props = product.value("module-properties").toObject();
|
||||||
rpp.setCallGroupId(groupLocationToCallGroupId(grp.value("location").toObject()));
|
rpp.setCallGroupId(groupLocationToCallGroupId(group.value("location").toObject()));
|
||||||
|
|
||||||
QStringList cFlags;
|
QStringList cFlags;
|
||||||
QStringList cxxFlags;
|
QStringList cxxFlags;
|
||||||
@@ -919,15 +896,15 @@ static RawProjectParts generateProjectParts(
|
|||||||
grpHeaderPaths += HeaderPath::makeFramework(FilePath::fromUserInput(p));
|
grpHeaderPaths += HeaderPath::makeFramework(FilePath::fromUserInput(p));
|
||||||
rpp.setHeaderPaths(grpHeaderPaths);
|
rpp.setHeaderPaths(grpHeaderPaths);
|
||||||
rpp.setDisplayName(groupName);
|
rpp.setDisplayName(groupName);
|
||||||
const QJsonObject location = grp.value("location").toObject();
|
const QJsonObject location = group.value("location").toObject();
|
||||||
rpp.setProjectFileLocation(location.value("file-path").toString(),
|
rpp.setProjectFileLocation(location.value("file-path").toString(),
|
||||||
location.value("line").toInt(),
|
location.value("line").toInt(),
|
||||||
location.value("column").toInt());
|
location.value("column").toInt());
|
||||||
rpp.setBuildSystemTarget(QbsProductNode::getBuildKey(prd));
|
rpp.setBuildSystemTarget(QbsProductNode::getBuildKey(product));
|
||||||
if (prd.value("is-runnable").toBool()) {
|
if (product.value("is-runnable").toBool()) {
|
||||||
rpp.setBuildTargetType(BuildTargetType::Executable);
|
rpp.setBuildTargetType(BuildTargetType::Executable);
|
||||||
} else {
|
} else {
|
||||||
const QJsonArray pType = prd.value("type").toArray();
|
const QJsonArray pType = product.value("type").toArray();
|
||||||
if (pType.contains("staticlibrary") || pType.contains("dynamiclibrary")
|
if (pType.contains("staticlibrary") || pType.contains("dynamiclibrary")
|
||||||
|| pType.contains("loadablemodule")) {
|
|| pType.contains("loadablemodule")) {
|
||||||
rpp.setBuildTargetType(BuildTargetType::Library);
|
rpp.setBuildTargetType(BuildTargetType::Library);
|
||||||
@@ -935,7 +912,7 @@ static RawProjectParts generateProjectParts(
|
|||||||
rpp.setBuildTargetType(BuildTargetType::Unknown);
|
rpp.setBuildTargetType(BuildTargetType::Unknown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rpp.setSelectedForBuilding(grp.value("is-enabled").toBool());
|
rpp.setSelectedForBuilding(group.value("is-enabled").toBool());
|
||||||
|
|
||||||
QHash<QString, QJsonObject> filePathToSourceArtifact;
|
QHash<QString, QJsonObject> filePathToSourceArtifact;
|
||||||
bool hasCFiles = false;
|
bool hasCFiles = false;
|
||||||
@@ -956,7 +933,7 @@ static RawProjectParts generateProjectParts(
|
|||||||
hasObjcxxFiles = true;
|
hasObjcxxFiles = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
forAllArtifacts(grp, artifactWorker);
|
forAllArtifacts(group, artifactWorker);
|
||||||
|
|
||||||
QSet<QString> pchFiles;
|
QSet<QString> pchFiles;
|
||||||
if (hasCFiles && props.value("cpp.useCPrecompiledHeader").toBool()
|
if (hasCFiles && props.value("cpp.useCPrecompiledHeader").toBool()
|
||||||
@@ -988,7 +965,42 @@ static RawProjectParts generateProjectParts(
|
|||||||
// Keep this lambda thread-safe!
|
// Keep this lambda thread-safe!
|
||||||
return getMimeType(filePathToSourceArtifact.value(filePath));
|
return getMimeType(filePathToSourceArtifact.value(filePath));
|
||||||
});
|
});
|
||||||
rpps.append(rpp);
|
return rpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static RawProjectParts generateProjectParts(
|
||||||
|
const QJsonObject &projectData,
|
||||||
|
const std::shared_ptr<const ToolChain> &cToolChain,
|
||||||
|
const std::shared_ptr<const ToolChain> &cxxToolChain,
|
||||||
|
QtMajorVersion qtVersion
|
||||||
|
)
|
||||||
|
{
|
||||||
|
RawProjectParts rpps;
|
||||||
|
forAllProducts(projectData, [&](const QJsonObject &prd) {
|
||||||
|
QString cPch;
|
||||||
|
QString cxxPch;
|
||||||
|
QString objcPch;
|
||||||
|
QString objcxxPch;
|
||||||
|
const auto &pchFinder = [&cPch, &cxxPch, &objcPch, &objcxxPch](const QJsonObject &artifact) {
|
||||||
|
const QJsonArray fileTags = artifact.value("file-tags").toArray();
|
||||||
|
if (fileTags.contains("c_pch_src"))
|
||||||
|
cPch = artifact.value("file-path").toString();
|
||||||
|
if (fileTags.contains("cpp_pch_src"))
|
||||||
|
cxxPch = artifact.value("file-path").toString();
|
||||||
|
if (fileTags.contains("objc_pch_src"))
|
||||||
|
objcPch = artifact.value("file-path").toString();
|
||||||
|
if (fileTags.contains("objcpp_pch_src"))
|
||||||
|
objcxxPch = artifact.value("file-path").toString();
|
||||||
|
};
|
||||||
|
forAllArtifacts(prd, ArtifactType::All, pchFinder);
|
||||||
|
const Utils::QtMajorVersion qtVersionForPart
|
||||||
|
= prd.value("module-properties").toObject().value("Qt.core.version").isUndefined()
|
||||||
|
? Utils::QtMajorVersion::None
|
||||||
|
: qtVersion;
|
||||||
|
const QJsonArray groups = prd.value("groups").toArray();
|
||||||
|
for (const QJsonValue &g : groups) {
|
||||||
|
rpps.append(generateProjectPart(prd, g.toObject(), cToolChain, cxxToolChain,
|
||||||
|
qtVersionForPart, cPch, cxxPch, objcPch, objcxxPch));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return rpps;
|
return rpps;
|
||||||
|
Reference in New Issue
Block a user