diff options
Diffstat (limited to 'src/lib/buildgraph/buildgraphloader.cpp')
| -rw-r--r-- | src/lib/buildgraph/buildgraphloader.cpp | 74 |
1 files changed, 27 insertions, 47 deletions
diff --git a/src/lib/buildgraph/buildgraphloader.cpp b/src/lib/buildgraph/buildgraphloader.cpp index 8c3639104..2c8764742 100644 --- a/src/lib/buildgraph/buildgraphloader.cpp +++ b/src/lib/buildgraph/buildgraphloader.cpp @@ -29,7 +29,7 @@ #include "buildgraphloader.h" #include "artifact.h" -#include "artifactlist.h" +#include "artifactset.h" #include "buildgraph.h" #include "command.h" #include "cycledetector.h" @@ -85,8 +85,10 @@ static void restoreBackPointers(const ResolvedProjectPtr &project) product->project = project; if (!product->buildData) continue; - foreach (Artifact * const a, product->buildData->artifacts) - project->topLevelProject()->buildData->insertIntoLookupTable(a); + foreach (BuildGraphNode * const n, product->buildData->nodes) { + if (Artifact *a = dynamic_cast<Artifact *>(n)) + project->topLevelProject()->buildData->insertIntoLookupTable(a); + } } foreach (const ResolvedProjectPtr &subProject, project->subProjects) { @@ -216,8 +218,8 @@ void BuildGraphLoader::trackProjectChanges(const SetupProjectParameters ¶met // If the product gets temporarily removed, its artifacts will get disconnected // and this structural information will no longer be directly available from them. - foreach (const Artifact * const a, product->buildData->artifacts) - childLists.insert(a, a->children); + foreach (const Artifact * const a, ArtifactSet::fromNodeSet(product->buildData->nodes)) + childLists.insert(a, ArtifactSet::fromNodeSet(a->children)); } } @@ -247,7 +249,7 @@ void BuildGraphLoader::trackProjectChanges(const SetupProjectParameters ¶met } else { if (restoredProduct->enabled) { QBS_CHECK(restoredProduct->buildData); - foreach (Artifact * const a, newlyResolvedProduct->buildData->artifacts) { + foreach (Artifact * const a, ArtifactSet::fromNodeSet(newlyResolvedProduct->buildData->nodes)) { const bool removeFromDisk = a->artifactType == Artifact::Generated; newlyResolvedProduct->topLevelProject()->buildData->removeArtifact(a, m_logger, removeFromDisk, true); @@ -257,8 +259,8 @@ void BuildGraphLoader::trackProjectChanges(const SetupProjectParameters ¶met productsWithChangedFiles.removeOne(restoredProduct); } if (newlyResolvedProduct->buildData) { - foreach (Artifact * const a, newlyResolvedProduct->buildData->artifacts) - a->product = newlyResolvedProduct; + foreach (BuildGraphNode *node, newlyResolvedProduct->buildData->nodes) + node->product = newlyResolvedProduct; } // Keep in list if build data still needs to be resolved. @@ -391,7 +393,7 @@ void BuildGraphLoader::checkAllProductsForChanges(const QList<ResolvedProductPtr if (!newlyResolvedProduct) continue; if (!productsWithChangedFiles.contains(restoredProduct) - && !sourceArtifactListsAreEqual(restoredProduct->allFiles(), + && !sourceArtifactSetsAreEqual(restoredProduct->allFiles(), newlyResolvedProduct->allFiles())) { m_logger.qbsDebug() << "File list of product '" << restoredProduct->name << "' was changed."; @@ -462,7 +464,7 @@ bool BuildGraphLoader::checkForPropertyChanges(const ResolvedProductPtr &restore return true; } QSet<TransformerConstPtr> seenTransformers; - foreach (Artifact * const artifact, restoredProduct->buildData->artifacts) { + foreach (Artifact *artifact, ArtifactSet::fromNodeSet(restoredProduct->buildData->nodes)) { const TransformerConstPtr transformer = artifact->transformer; if (!transformer || seenTransformers.contains(transformer)) continue; @@ -483,7 +485,7 @@ void BuildGraphLoader::onProductRemoved(const ResolvedProductPtr &product, product->project->products.removeOne(product); if (product->buildData) { - foreach (Artifact *artifact, product->buildData->artifacts) + foreach (Artifact *artifact, ArtifactSet::fromNodeSet(product->buildData->nodes)) projectBuildData->removeArtifact(artifact, m_logger, removeArtifactsFromDisk, false); } } @@ -495,9 +497,8 @@ void BuildGraphLoader::onProductFileListChanged(const ResolvedProductPtr &restor QBS_CHECK(newlyResolvedProduct->enabled); - ArtifactsPerFileTagMap artifactsPerFileTag; QList<Artifact *> addedArtifacts; - ArtifactList artifactsToRemove; + ArtifactSet artifactsToRemove; QHash<QString, SourceArtifactConstPtr> oldArtifacts, newArtifacts; const QList<SourceArtifactPtr> restoredProductAllFiles = restoredProduct->allEnabledFiles(); @@ -567,37 +568,29 @@ void BuildGraphLoader::onProductFileListChanged(const ResolvedProductPtr &restor // handle added filetags foreach (const FileTag &addedFileTag, changedArtifact->fileTags - a->fileTags) { artifact->fileTags += addedFileTag; - artifactsPerFileTag[addedFileTag] += artifact; + restoredProduct->buildData->registerAddedFileTag(addedFileTag, artifact); } // handle removed filetags foreach (const FileTag &removedFileTag, a->fileTags - changedArtifact->fileTags) { artifact->fileTags -= removedFileTag; - foreach (Artifact *parent, artifact->parents) { - if (parent->transformer && parent->transformer->rule->inputs.contains(removedFileTag)) { - // this parent has been created because of the removed filetag - newlyResolvedProduct->topLevelProject()->buildData - ->removeArtifactAndExclusiveDependents(parent, m_logger, true, - &artifactsToRemove); - } - } + restoredProduct->buildData->registerRemovedFileTag(removedFileTag, artifact); } } } - // apply rules for new artifacts - foreach (Artifact *artifact, addedArtifacts) - foreach (const FileTag &ft, artifact->fileTags) - artifactsPerFileTag[ft] += artifact; +#if 0 RulesApplicator(newlyResolvedProduct, artifactsPerFileTag, m_logger).applyAllRules(); - addTargetArtifacts(newlyResolvedProduct, artifactsPerFileTag, m_logger); - // parents of removed artifacts must update their transformers - foreach (Artifact *removedArtifact, artifactsToRemove) - foreach (Artifact *parent, removedArtifact->parents) + foreach (Artifact *removedArtifact, artifactsToRemove) { + foreach (BuildGraphNode *parentNode, removedArtifact->parents) { newlyResolvedProduct->topLevelProject()->buildData->artifactsThatMustGetNewTransformers += parent; newlyResolvedProduct->topLevelProject()->buildData->updateNodesThatMustGetNewTransformer(m_logger); + continue; + } + } +#endif // delete all removed artifacts physically from the disk foreach (Artifact *artifact, artifactsToRemove) { @@ -682,7 +675,8 @@ void BuildGraphLoader::replaceFileDependencyWithArtifact(const ResolvedProductPt foreach (const ResolvedProductPtr &product, fileDepProduct->topLevelProject()->allProducts()) { if (!product->buildData) continue; - foreach (Artifact *artifactInProduct, product->buildData->artifacts) { + foreach (BuildGraphNode *nodeInProduct, product->buildData->nodes) { + Artifact *artifactInProduct = dynamic_cast<Artifact *>(nodeInProduct); if (artifactInProduct->fileDependencies.contains(filedep)) { artifactInProduct->fileDependencies.remove(filedep); loggedConnect(artifactInProduct, artifact, m_logger); @@ -721,7 +715,8 @@ void BuildGraphLoader::rescueOldBuildData(const ResolvedProductConstPtr &restore "product '%1'").arg(restoredProduct->name); } - foreach (Artifact *artifact, newlyResolvedProduct->buildData->artifacts) { + foreach (Artifact *artifact, + ArtifactSet::fromNodeSet(newlyResolvedProduct->buildData->nodes)) { if (m_logger.traceEnabled()) { m_logger.qbsTrace() << QString::fromLocal8Bit("[BG] artifact '%1'") .arg(artifact->fileName()); @@ -755,20 +750,5 @@ void BuildGraphLoader::rescueOldBuildData(const ResolvedProductConstPtr &restore } } -void addTargetArtifacts(const ResolvedProductPtr &product, - ArtifactsPerFileTagMap &artifactsPerFileTag, const Logger &logger) -{ - foreach (const FileTag &fileTag, product->fileTags) { - foreach (Artifact * const artifact, artifactsPerFileTag.value(fileTag)) { - if (artifact->artifactType == Artifact::Generated) - product->buildData->targetArtifacts += artifact; - } - } - if (product->buildData->targetArtifacts.isEmpty()) { - const QString msg = QString::fromLocal8Bit("No artifacts generated for product '%1'."); - logger.qbsDebug() << msg.arg(product->name); - } -} - } // namespace Internal } // namespace qbs |
