diff options
Diffstat (limited to 'src/lib/buildgraph/rulesapplicator.cpp')
| -rw-r--r-- | src/lib/buildgraph/rulesapplicator.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/lib/buildgraph/rulesapplicator.cpp b/src/lib/buildgraph/rulesapplicator.cpp index 0e3e95374..1eadc7773 100644 --- a/src/lib/buildgraph/rulesapplicator.cpp +++ b/src/lib/buildgraph/rulesapplicator.cpp @@ -64,6 +64,14 @@ void RulesApplicator::applyAllRules() applyRule(rule); } +QVector<BuildGraphNode *> RulesApplicator::applyRuleInEvaluationContext(const RuleConstPtr &rule) +{ + m_createdArtifacts.clear(); + RulesEvaluationContext::Scope s(m_product->topLevelProject()->buildData->evaluationContext.data()); + applyRule(rule); + return m_createdArtifacts; +} + void RulesApplicator::applyRule(const RuleConstPtr &rule) { m_rule = rule; @@ -72,14 +80,14 @@ void RulesApplicator::applyRule(const RuleConstPtr &rule) setupScriptEngineForProduct(engine(), m_product, m_rule, prepareScriptContext, this); m_productObjectId = prepareScriptContext.property(QLatin1String("product")).objectId(); - ArtifactList inputArtifacts; + ArtifactSet inputArtifacts; foreach (const FileTag &fileTag, m_rule->inputs) inputArtifacts.unite(m_artifactsPerFileTag.value(fileTag)); if (m_rule->multiplex) { // apply the rule once for a set of inputs if (!inputArtifacts.isEmpty()) doApply(inputArtifacts, prepareScriptContext); } else { // apply the rule once for each input - ArtifactList lst; + ArtifactSet lst; foreach (Artifact * const inputArtifact, inputArtifacts) { setupScriptEngineForArtifact(inputArtifact); lst += inputArtifact; @@ -94,8 +102,18 @@ static void copyProperty(const QString &name, const QScriptValue &src, QScriptVa dst.setProperty(name, src.property(name)); } -void RulesApplicator::doApply(const ArtifactList &inputArtifacts, - QScriptValue &prepareScriptContext) +static QStringList toStringList(const ArtifactSet &artifacts) +{ + QStringList lst; + foreach (const Artifact *artifact, artifacts) { + const QString str = artifact->filePath() + QLatin1String(" [") + + artifact->fileTags.toStringList().join(QLatin1String(", ")) + QLatin1Char(']'); + lst << str; + } + return lst; +} + +void RulesApplicator::doApply(const ArtifactSet &inputArtifacts, QScriptValue &prepareScriptContext) { evalContext()->checkForCancelation(); @@ -107,12 +125,12 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts, QList<QPair<const RuleArtifact *, Artifact *> > ruleArtifactArtifactMap; QList<Artifact *> outputArtifacts; - ArtifactList usingArtifacts; + ArtifactSet usingArtifacts; if (!m_rule->usings.isEmpty()) { const FileTags usingsFileTags = m_rule->usings; foreach (const ResolvedProductPtr &dep, m_product->dependencies) { QBS_CHECK(dep->buildData); - ArtifactList artifactsToCheck; + ArtifactSet artifactsToCheck; foreach (Artifact *targetArtifact, dep->buildData->targetArtifacts) artifactsToCheck.unite(targetArtifact->transformer->outputs); foreach (Artifact *artifact, artifactsToCheck) { @@ -143,7 +161,7 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts, loggedConnect(outputArtifact, dependency, m_logger); // Transformer setup - for (ArtifactList::const_iterator it = usingArtifacts.constBegin(); + for (ArtifactSet::const_iterator it = usingArtifacts.constBegin(); it != usingArtifacts.constEnd(); ++it) { Artifact *dep = *it; @@ -228,7 +246,7 @@ void RulesApplicator::setupScriptEngineForArtifact(Artifact *artifact) } Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &ruleArtifact, - const ArtifactList &inputArtifacts) + const ArtifactSet &inputArtifacts) { QScriptValue scriptValue = engine()->evaluate(ruleArtifact->fileName); if (Q_UNLIKELY(scriptValue.isError() || engine()->hasUncaughtException())) @@ -280,6 +298,7 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule outputArtifact->alwaysUpdated = ruleArtifact->alwaysUpdated; outputArtifact->properties = m_product->properties; insertArtifact(m_product, outputArtifact, m_logger); + m_createdArtifacts += outputArtifact; } if (outputArtifact->fileTags.isEmpty()) |
