diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-08-02 13:57:26 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-11-27 11:49:01 +0100 |
commit | 006824f89c4f298f19c45f4f4585b4452cd2d2b9 (patch) | |
tree | 0007c73137e7d167cefa4e5611a01803e69fa5fd /src/lib/buildgraph/projectbuilddata.cpp | |
parent | dbb39fc1fce3686a5161d68e89e96086fc664556 (diff) | |
download | qbs-006824f89c4f298f19c45f4f4585b4452cd2d2b9.tar.gz |
introduce class BuildGraphNodedynablaster
To support different types of nodes in the build graph, we introduce
the base class BuildGraphNode. Artifact now derives from BuildGraphNode.
A - yet unused - RuleNode class is introduced that represents a rule in
the build graph.
Change-Id: Ie1ad5e7a9e65bfd5f99d3e824737516053de0f94
***new artifacts hash in ProductBuildData
Change-Id: I50521ec64f734bfb3662759076fa5e7912ac084e
***automoc fixup
Change-Id: Ie2bb228ae38d63deccc600d67d283bc3beda9fec
slightly nicer rule debug output
Change-Id: I60ddef73cd7f0a67055f2d56e6dbe7fa45ddd450
create RuleNode objects and add them to roots
Change-Id: I51a0f89b98cda524d34888ab758d7bd397d82f00
***execute rule nodes on build
Change-Id: I291c32868cd982e37393d6bc8d696f2b63fbff50
***ArtifactSet::fromNodeSet
Change-Id: I7586bcfbe43406c22b1ee1a1fd826beaa247164f
***update after rebase
Change-Id: I5f73afc80b746b11eeb83aeadf29c2358accbab8
***phonytarget
Change-Id: I587b7e072e54b866e8d5ea37c874e6a8baa550e0
update after rebase
Change-Id: I6017c0cbe9244fea04d513f53e3a2a85092bf962
skip nodes early
We must skip Building and Built nodes.
m_leaves can contain duplicates now.
Change-Id: If275106a47c403a455103f4deeb20049548007f5
debug message
Change-Id: I90e238eef72a8a02fb0a9f2c77715f5f15c1442d
disable phony thingy
Change-Id: I7bb60b850b96b65ab738c11e96c3a84cbe58d2f7
connect each output of a rule to the rule itself
Change-Id: I159d76c4b63094058cc9a07ccc2d0b67c7ce06e6
TagScanner
Change-Id: I4741e48cd674c0ca830ee1b4d05b59a8c542694f
TagScanner deps
Change-Id: If3e43a7ac25616cd151229684a085ac8ee787645
update after rebase
Change-Id: I58d49a5ed1049a17733fc2154588f12c1cda53e6
only root tag scanners in product
Change-Id: Ia94732a5632156a5ec3c5518c9596cd4cefac105
run TagScanners
Change-Id: I869a183f2da23a43957a6df45dc5a1b30b10af92
TagScannerRunner
Change-Id: Id3c5fac73e6fb84e56d6ab1d48a959f3677f7a67
crash fix
Change-Id: Ie3c26dbed41ab4615915a08913c495868c3a8910
more TagScanRunner
Change-Id: I80b79f101c0f4d802fb4f6515c0848e369fed066
handle removal of filetags
Change-Id: Icdd8d05c2e26953f7b12d968aa5dfcc23928b9ba
Qt4 build fix
Change-Id: Ie5fcb64e36ddc5004003183bea7243536bc8ab15
do not waste space with type information
Change-Id: I7b9354e6fceead228ba335723b9addeb701bef56
update nodes that must get new transformers
Change-Id: I06cd7ffe606ae643393350c5959ef6475343929f
update after rebase
Change-Id: If080e664972f2950c12fd800a3e4b521e65dca3a
only run tag scanners on changed sources
And do not call RulesApplicator in bgloader.
Change-Id: I5140c91c79a842dab933ad7b328100bdec13cb10
Conflicts:
src/lib/buildgraph/buildgraphloader.cpp
sketch of moc tagscanners impl
Change-Id: I7736c2da1b1742bc3556ef660c163e6c32cbd4c9
Conflicts:
share/qbs/modules/Qt/core/core.qbs
MocTagScanner
Change-Id: I87199e8f355b8b20cf2387f4d4190a20bddae0db
fix lib.qbs
Change-Id: Ibcb5bc290d3839b04828f8c9b155577634bcc9e4
moctagscanner split
Change-Id: Iace5d48483c02b5d33d9ccd54ac07162bfc09d27
Diffstat (limited to 'src/lib/buildgraph/projectbuilddata.cpp')
-rw-r--r-- | src/lib/buildgraph/projectbuilddata.cpp | 91 |
1 files changed, 75 insertions, 16 deletions
diff --git a/src/lib/buildgraph/projectbuilddata.cpp b/src/lib/buildgraph/projectbuilddata.cpp index 57d7ea6e0..f3d4d84a0 100644 --- a/src/lib/buildgraph/projectbuilddata.cpp +++ b/src/lib/buildgraph/projectbuilddata.cpp @@ -32,6 +32,9 @@ #include "buildgraph.h" #include "productbuilddata.h" #include "command.h" +#include "phonytarget.h" +#include "rulegraph.h" +#include "rulenode.h" #include "rulesapplicator.h" #include "rulesevaluationcontext.h" #include "transformer.h" @@ -110,7 +113,7 @@ static void disconnectArtifactChildren(Artifact *artifact, const Logger &logger) logger.qbsTrace() << QString::fromLocal8Bit("[BG] disconnectChildren: '%1'") .arg(relativeArtifactFileName(artifact)); } - foreach (Artifact * const child, artifact->children) + foreach (BuildGraphNode * const child, artifact->children) child->parents.remove(artifact); artifact->children.clear(); artifact->childrenAddedByScanner.clear(); @@ -123,12 +126,13 @@ static void disconnectArtifactParents(Artifact *artifact, ProjectBuildData *proj logger.qbsTrace() << QString::fromLocal8Bit("[BG] disconnectParents: '%1'") .arg(relativeArtifactFileName(artifact)); } - foreach (Artifact * const parent, artifact->parents) { + foreach (BuildGraphNode * const parent, artifact->parents) { parent->children.remove(artifact); - parent->childrenAddedByScanner.remove(artifact); - if (parent->transformer) { - parent->transformer->inputs.remove(artifact); - projectBuildData->artifactsThatMustGetNewTransformers += parent; + Artifact *parentArtifact = dynamic_cast<Artifact *>(parent); + if (parentArtifact->transformer) { + parentArtifact->childrenAddedByScanner.remove(artifact); + parentArtifact->transformer->inputs.remove(artifact); + projectBuildData->artifactsThatMustGetNewTransformers += parentArtifact; } } @@ -149,11 +153,11 @@ static void disconnectArtifact(Artifact *artifact, ProjectBuildData *projectBuil */ void ProjectBuildData::removeArtifactAndExclusiveDependents(Artifact *artifact, const Logger &logger, bool removeFromProduct, - ArtifactList *removedArtifacts) + ArtifactSet *removedArtifacts) { if (removedArtifacts) removedArtifacts->insert(artifact); - foreach (Artifact *parent, artifact->parents) { + foreach (Artifact *parent, ArtifactSet::fromNodeSet(artifact->parents)) { bool removeParent = false; disconnect(parent, artifact, logger); if (parent->children.isEmpty()) { @@ -182,7 +186,7 @@ void ProjectBuildData::removeArtifact(Artifact *artifact, removeGeneratedArtifactFromDisk(artifact, logger); removeFromLookupTable(artifact); if (removeFromProduct) { - artifact->product->buildData->artifacts.remove(artifact); + artifact->product->buildData->nodes.remove(artifact); artifact->product->buildData->targetArtifacts.remove(artifact); } disconnectArtifact(artifact, this, logger); @@ -208,7 +212,6 @@ void ProjectBuildData::updateNodeThatMustGetNewTransformer(Artifact *artifact, c } removeGeneratedArtifactFromDisk(artifact, logger); - artifact->autoMocTimestamp.clear(); artifact->clearTimestamp(); const RuleConstPtr rule = artifact->transformer->rule; @@ -219,9 +222,10 @@ void ProjectBuildData::updateNodeThatMustGetNewTransformer(Artifact *artifact, c sibling->transformer.clear(); ArtifactsPerFileTagMap artifactsPerFileTag; - foreach (Artifact *input, artifact->children) { - foreach (const FileTag &fileTag, input->fileTags) - artifactsPerFileTag[fileTag] += input; + foreach (BuildGraphNode *input, artifact->children) { + if (Artifact *inputArtifact = dynamic_cast<Artifact *>(input)) + foreach (const FileTag &fileTag, inputArtifact->fileTags) + artifactsPerFileTag[fileTag] += inputArtifact; } RulesApplicator rulesApplier(artifact->product, artifactsPerFileTag, logger); rulesApplier.applyRule(rule); @@ -278,6 +282,40 @@ void BuildDataResolver::resolveProductBuildDataForExistingProject(const TopLevel } } +class CreateRuleNodes : public RuleGraphVisitor +{ +public: + CreateRuleNodes(const ResolvedProductPtr &aProduct, Logger aLogger) + : product(aProduct), logger(aLogger) + { + } + +private: + ResolvedProductPtr product; + Logger logger; + QHash<RuleConstPtr, RuleNode *> nodePerRule; + + void visit(const RuleConstPtr &parentRule, const RuleConstPtr &rule) + { + RuleNode *node = nodePerRule.value(rule); + if (!node) { + node = new RuleNode; + nodePerRule.insert(rule, node); + node->product = product; + node->setRule(rule); + product->buildData->nodes += node; + qDebug() << "CREATE" << node->toString(); + } + if (parentRule) { + RuleNode *parent = nodePerRule.value(parentRule); + QBS_CHECK(parent); + loggedConnect(parent, node, logger); + } else { + product->buildData->roots += node; + } + } +}; + void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &product) { if (product->buildData) @@ -307,6 +345,7 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc } qbsFileArtifact->fileTags.insert("qbs"); artifactsPerFileTag["qbs"].insert(qbsFileArtifact); + product->buildData->registerAddedArtifact(qbsFileArtifact); // read sources foreach (const SourceArtifactConstPtr &sourceArtifact, product->allEnabledFiles()) { @@ -315,6 +354,7 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc continue; // ignore duplicate artifacts Artifact *artifact = createArtifact(product, sourceArtifact, m_logger); + product->buildData->registerAddedArtifact(artifact); foreach (const FileTag &fileTag, artifact->fileTags) artifactsPerFileTag[fileTag].insert(artifact); } @@ -323,7 +363,7 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc typedef QPair<ResolvedTransformerConstPtr, TransformerConstPtr> TrafoPair; QList<TrafoPair> trafos; foreach (const ResolvedTransformerConstPtr &rtrafo, product->transformers) { - ArtifactList inputArtifacts; + ArtifactSet inputArtifacts; foreach (const QString &inputFileName, rtrafo->inputs) { Artifact *artifact = lookupArtifact(product, inputFileName); if (Q_UNLIKELY(!artifact)) @@ -348,6 +388,7 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc safeConnect(outputArtifact, inputArtifact, m_logger); foreach (const FileTag &fileTag, outputArtifact->fileTags) artifactsPerFileTag[fileTag].insert(outputArtifact); + product->buildData->registerAddedArtifact(outputArtifact); RuleArtifactPtr ruleArtifact = RuleArtifact::create(); ruleArtifact->fileName = outputArtifact->filePath(); @@ -382,8 +423,26 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc } } - RulesApplicator(product, artifactsPerFileTag, m_logger).applyAllRules(); - addTargetArtifacts(product, artifactsPerFileTag, m_logger); + RuleGraph ruleGraph; + ruleGraph.build(product->rules, product->fileTags); + CreateRuleNodes crn(product, m_logger); + ruleGraph.accept(&crn); + +// // ### just a test +// PhonyTarget *target = new PhonyTarget(); +// target->product = product; +// TransformerPtr t = Transformer::create(); +// target->setTransformer(t); +// foreach (BuildGraphNode *node, product->buildData->nodes) +// target->connectChild(node); +// product->buildData->nodes.clear(); +// product->buildData->nodes += target; +// // ### END TEST + +// RulesApplicator(product, artifactsPerFileTag, m_logger).applyAllRules(); +// addTargetArtifacts(product, artifactsPerFileTag, m_logger); +// foreach (Artifact *artifact, product->buildData->targetArtifacts) +// product->buildData->roots += artifact; } RulesEvaluationContextPtr BuildDataResolver::evalContext() const |