QbsProjectManager: Fix setting up extra compilers

There were a couple of typos breaking the functionality.
Also separate updating extra compilers and the code model.

Change-Id: Ie8f7bbf62d4b7817af3a26298401ad99c011b6e5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-02-04 11:18:03 +01:00
parent fd5461b93d
commit faa56b1965
3 changed files with 35 additions and 17 deletions

View File

@@ -460,6 +460,7 @@ void QbsBuildSystem::updateAfterParse()
updateDocuments();
updateBuildTargetData();
updateCppCodeModel();
updateExtraCompilers();
updateQmlJsCodeModel();
emit project()->fileListChanged();
m_envCache.clear();
@@ -637,7 +638,7 @@ void QbsBuildSystem::updateAfterBuild()
m_projectData = projectData;
updateProjectNodes();
updateBuildTargetData();
updateCppCodeModel(); // TODO: Should be updateExtraCompilers().
updateExtraCompilers();
m_envCache.clear();
}
@@ -809,7 +810,6 @@ static void getExpandedCompilerFlags(QStringList &cFlags, QStringList &cxxFlags,
}
}
// TODO: Factor out the part that deals with extra compilers.
void QbsBuildSystem::updateCppCodeModel()
{
OpTimer optimer("updateCppCodeModel");
@@ -817,16 +817,11 @@ void QbsBuildSystem::updateCppCodeModel()
if (projectData.isEmpty())
return;
const QList<ExtraCompilerFactory *> factories =
ExtraCompilerFactory::extraCompilerFactories();
QHash<QString, QStringList> sourcesForGeneratedFiles;
m_sourcesForGeneratedFiles.clear();
const QtSupport::CppKitInfo kitInfo(kit());
QTC_ASSERT(kitInfo.isValid(), return);
RawProjectParts rpps;
forAllProducts(projectData, [&, this](const QJsonObject &prd) {
forAllProducts(projectData, [&](const QJsonObject &prd) {
const QString productName = prd.value("full-display-name").toString();
QString cPch;
QString cxxPch;
@@ -903,7 +898,7 @@ void QbsBuildSystem::updateCppCodeModel()
bool hasCxxFiles = false;
bool hasObjcFiles = false;
bool hasObjcxxFiles = false;
const auto artifactWorker = [&, this](const QJsonObject &source) {
const auto artifactWorker = [&](const QJsonObject &source) {
const QString filePath = source.value("file-path").toString();
filePathToSourceArtifact.insert(filePath, source);
for (const QJsonValue &tag : source.value("file-tags").toArray()) {
@@ -915,12 +910,6 @@ void QbsBuildSystem::updateCppCodeModel()
hasObjcFiles = true;
else if (tag == "objcpp")
hasObjcxxFiles = true;
for (auto i = factories.cbegin(); i != factories.cend(); ++i) {
if ((*i)->sourceTag() == tag.toString()) {
m_sourcesForGeneratedFiles[*i] << filePath;
sourcesForGeneratedFiles[productName] << filePath;
}
}
}
};
forAllArtifacts(grp, artifactWorker);
@@ -959,6 +948,34 @@ void QbsBuildSystem::updateCppCodeModel()
});
m_cppCodeModelUpdater->update({project(), kitInfo, activeParseEnvironment(), rpps});
}
void QbsBuildSystem::updateExtraCompilers()
{
OpTimer optimer("updateExtraCompilers");
const QJsonObject projectData = session()->projectData();
if (projectData.isEmpty())
return;
const QList<ExtraCompilerFactory *> factories = ExtraCompilerFactory::extraCompilerFactories();
QHash<QString, QStringList> sourcesForGeneratedFiles;
m_sourcesForGeneratedFiles.clear();
forAllProducts(projectData, [&, this](const QJsonObject &prd) {
const QString productName = prd.value("full-display-name").toString();
forAllArtifacts(prd, ArtifactType::Source, [&, this](const QJsonObject &source) {
const QString filePath = source.value("file-path").toString();
for (const QJsonValue &tag : source.value("file-tags").toArray()) {
for (auto i = factories.cbegin(); i != factories.cend(); ++i) {
if ((*i)->sourceTag() == tag.toString()) {
m_sourcesForGeneratedFiles[*i] << filePath;
sourcesForGeneratedFiles[productName] << filePath;
}
}
}
});
});
if (!sourcesForGeneratedFiles.isEmpty())
session()->requestFilesGeneratedFrom(sourcesForGeneratedFiles);
}

View File

@@ -134,6 +134,7 @@ private:
void updateDocuments();
void updateCppCodeModel();
void updateQmlJsCodeModel();
void updateExtraCompilers();
void updateApplicationTargets();
void updateDeploymentInfo();
void updateBuildTargetData();

View File

@@ -317,7 +317,7 @@ void QbsSession::requestFilesGeneratedFrom(const QHash<QString, QStringList> &so
QJsonArray products;
for (auto it = sourceFilesPerProduct.cbegin(); it != sourceFilesPerProduct.cend(); ++it) {
QJsonObject product;
product.insert("full-display-name", it->first());
product.insert("full-display-name", it.key());
QJsonArray requests;
for (const QString &sourceFile : it.value())
requests << QJsonObject({qMakePair(QString("source-file"), sourceFile)});
@@ -504,7 +504,7 @@ void QbsSession::handlePacket(const QJsonObject &packet)
emit taskProgress(packet.value("progress").toInt());
} else if (type == "new-max-progress") {
emit maxProgressChanged(packet.value("max-progress").toInt());
} else if (type == "generated-files-for-source") {
} else if (type == "generated-files-for-sources") {
QHash<QString, QStringList> generatedFiles;
for (const QJsonValue &product : packet.value("products").toArray()) {
for (const QJsonValue &r : product.toObject().value("results").toArray()) {