diff options
-rw-r--r-- | doc/reference/items/language/rule.qdoc | 6 | ||||
-rw-r--r-- | share/qbs/modules/bundle/BundleModule.qbs | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/executor.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/projectbuilddata.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rulegraph.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rulenode.cpp | 5 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rulesapplicator.cpp | 10 | ||||
-rw-r--r-- | src/lib/corelib/language/builtindeclarations.cpp | 9 | ||||
-rw-r--r-- | src/lib/corelib/language/language.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/language/language.h | 4 | ||||
-rw-r--r-- | src/lib/corelib/language/projectresolver.cpp | 8 | ||||
-rw-r--r-- | src/lib/corelib/tools/stringconstants.h | 1 | ||||
-rw-r--r-- | src/lib/qtprofilesetup/templates/core.qbs | 2 | ||||
-rw-r--r-- | tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs | 114 | ||||
-rw-r--r-- | tests/auto/api/tst_api.cpp | 46 | ||||
-rw-r--r-- | tests/auto/api/tst_api.h | 1 |
16 files changed, 198 insertions, 20 deletions
diff --git a/doc/reference/items/language/rule.qdoc b/doc/reference/items/language/rule.qdoc index e048ee6c0..200bd94c0 100644 --- a/doc/reference/items/language/rule.qdoc +++ b/doc/reference/items/language/rule.qdoc @@ -222,13 +222,13 @@ */ /*! - \qmlproperty stringList Rule::excludedAuxiliaryInputs + \qmlproperty stringList Rule::excludedInputs A list of file tags. Connections to rules that produce these file tags are - prevented. This property has no effect on the content of the \c inputs - variable in the \l{prepare} script. + prevented. \nodefaultvalue + \since Qbs 1.12 */ /*! diff --git a/share/qbs/modules/bundle/BundleModule.qbs b/share/qbs/modules/bundle/BundleModule.qbs index 16ce21d69..8dcbff19f 100644 --- a/share/qbs/modules/bundle/BundleModule.qbs +++ b/share/qbs/modules/bundle/BundleModule.qbs @@ -505,7 +505,7 @@ Module { // Make sure the inputs of this rule are only those rules which produce outputs compatible // with the type of the bundle being produced. - excludedAuxiliaryInputs: Bundle.excludedAuxiliaryInputs(project, product) + excludedInputs: Bundle.excludedAuxiliaryInputs(project, product) outputFileTags: [ "bundle.content", diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index 11e375064..6ec73deba 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -1224,12 +1224,12 @@ void Executor::setupForBuildingSelectedFiles(const BuildGraphNode *node) const Rule * const rule = ruleNode->rule().get(); if (rule->inputs.intersects(m_tagsOfFilesToConsider)) { FileTags otherInputs = rule->auxiliaryInputs; - otherInputs.unite(rule->explicitlyDependsOn).subtract(rule->excludedAuxiliaryInputs); + otherInputs.unite(rule->explicitlyDependsOn).subtract(rule->excludedInputs); m_tagsNeededForFilesToConsider.unite(otherInputs); } else if (rule->collectedOutputFileTags().intersects(m_tagsNeededForFilesToConsider)) { FileTags allInputs = rule->inputs; allInputs.unite(rule->auxiliaryInputs).unite(rule->explicitlyDependsOn) - .subtract(rule->excludedAuxiliaryInputs); + .subtract(rule->excludedInputs); m_tagsNeededForFilesToConsider.unite(allInputs); } } diff --git a/src/lib/corelib/buildgraph/projectbuilddata.cpp b/src/lib/corelib/buildgraph/projectbuilddata.cpp index b382ed092..2db534217 100644 --- a/src/lib/corelib/buildgraph/projectbuilddata.cpp +++ b/src/lib/corelib/buildgraph/projectbuilddata.cpp @@ -376,7 +376,7 @@ static bool areRulesCompatible(const RuleNode *ruleNode, const RuleNode *depende if (ruleNode->rule()->explicitlyDependsOn.intersects(outTags)) return true; return ruleNode->rule()->auxiliaryInputs.intersects(outTags) - && !ruleNode->rule()->excludedAuxiliaryInputs.intersects(outTags); + && !ruleNode->rule()->excludedInputs.intersects(outTags); } void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &product) diff --git a/src/lib/corelib/buildgraph/rulegraph.cpp b/src/lib/corelib/buildgraph/rulegraph.cpp index 24749767e..9bd3279cd 100644 --- a/src/lib/corelib/buildgraph/rulegraph.cpp +++ b/src/lib/corelib/buildgraph/rulegraph.cpp @@ -71,7 +71,7 @@ void RuleGraph::build(const QList<RulePtr> &rules, const FileTags &productFileTa inputFileTagToRule[fileTag].push_back(rule.get()); for (const Rule * const producingRule : m_outputFileTagToRule.value(fileTag)) { if (!producingRule->collectedOutputFileTags().intersects( - rule->excludedAuxiliaryInputs)) { + rule->excludedInputs)) { connect(rule.get(), producingRule); } } diff --git a/src/lib/corelib/buildgraph/rulenode.cpp b/src/lib/corelib/buildgraph/rulenode.cpp index d4ed5484a..f06ae2c43 100644 --- a/src/lib/corelib/buildgraph/rulenode.cpp +++ b/src/lib/corelib/buildgraph/rulenode.cpp @@ -194,6 +194,8 @@ ArtifactSet RuleNode::currentInputArtifacts() const continue; if (artifact->transformer && artifact->transformer->rule == m_rule) continue; + if (artifact->fileTags().intersects(m_rule->excludedInputs)) + continue; s += artifact; } } @@ -202,7 +204,8 @@ ArtifactSet RuleNode::currentInputArtifacts() const if (!dep->buildData) continue; for (Artifact * const a : filterByType<Artifact>(dep->buildData->allNodes())) { - if (a->fileTags().intersects(m_rule->inputsFromDependencies)) + if (a->fileTags().intersects(m_rule->inputsFromDependencies) + && !a->fileTags().intersects(m_rule->excludedInputs)) s += a; } } diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp index 3ad01a008..e1ccde0d5 100644 --- a/src/lib/corelib/buildgraph/rulesapplicator.cpp +++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp @@ -295,12 +295,16 @@ ArtifactSet RulesApplicator::collectExplicitlyDependsOn() { ArtifactSet artifacts; for (const FileTag &fileTag : qAsConst(m_rule->explicitlyDependsOn)) { - for (Artifact *dependency : m_product->lookupArtifactsByFileTag(fileTag)) - artifacts << dependency; + for (Artifact *dependency : m_product->lookupArtifactsByFileTag(fileTag)) { + if (!dependency->fileTags().intersects(m_rule->excludedInputs)) + artifacts << dependency; + } for (const ResolvedProductConstPtr &depProduct : qAsConst(m_product->dependencies)) { for (Artifact * const ta : depProduct->targetArtifacts()) { - if (ta->fileTags().contains(fileTag)) + if (ta->fileTags().contains(fileTag) + && !ta->fileTags().intersects(m_rule->excludedInputs)) { artifacts << ta; + } } } } diff --git a/src/lib/corelib/language/builtindeclarations.cpp b/src/lib/corelib/language/builtindeclarations.cpp index e3f4199e3..09828bbcf 100644 --- a/src/lib/corelib/language/builtindeclarations.cpp +++ b/src/lib/corelib/language/builtindeclarations.cpp @@ -500,8 +500,13 @@ void BuiltinDeclarations::addRuleItem() PropertyDeclaration::StringList); item << PropertyDeclaration(StringConstants::auxiliaryInputsProperty(), PropertyDeclaration::StringList); - item << PropertyDeclaration(StringConstants::excludedAuxiliaryInputsProperty(), - PropertyDeclaration::StringList); + PropertyDeclaration excludedAuxInputs(StringConstants::excludedAuxiliaryInputsProperty(), + PropertyDeclaration::StringList); + excludedAuxInputs.setDeprecationInfo(DeprecationInfo(Version(1, 14), + Tr::tr("Use 'excludedInputs' instead"))); + item << excludedAuxInputs; + item << PropertyDeclaration(StringConstants::excludedInputsProperty(), + PropertyDeclaration::StringList); item << PropertyDeclaration(StringConstants::explicitlyDependsOnProperty(), PropertyDeclaration::StringList); item << prepareScriptProperty(); diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index cc0da3d8a..8a17ed266 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -892,7 +892,7 @@ bool operator==(const Rule &r1, const Rule &r2) && r1.inputs == r2.inputs && r1.outputFileTags == r2.outputFileTags && r1.auxiliaryInputs == r2.auxiliaryInputs - && r1.excludedAuxiliaryInputs == r2.excludedAuxiliaryInputs + && r1.excludedInputs == r2.excludedInputs && r1.inputsFromDependencies == r2.inputsFromDependencies && r1.explicitlyDependsOn == r2.explicitlyDependsOn && r1.multiplex == r2.multiplex diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h index 2ec152221..e956f63b2 100644 --- a/src/lib/corelib/language/language.h +++ b/src/lib/corelib/language/language.h @@ -411,7 +411,7 @@ public: PrivateScriptFunction outputArtifactsScript; // unused, if artifacts is non-empty FileTags inputs; FileTags auxiliaryInputs; - FileTags excludedAuxiliaryInputs; + FileTags excludedInputs; FileTags inputsFromDependencies; FileTags explicitlyDependsOn; bool multiplex; @@ -435,7 +435,7 @@ public: template<PersistentPool::OpType opType> void completeSerializationOp(PersistentPool &pool) { pool.serializationOp<opType>(name, prepareScript, outputArtifactsScript, module, inputs, - outputFileTags, auxiliaryInputs, excludedAuxiliaryInputs, + outputFileTags, auxiliaryInputs, excludedInputs, inputsFromDependencies, explicitlyDependsOn, multiplex, requiresInputs, alwaysRun, artifacts); } diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp index bbc7b544f..1137cb38b 100644 --- a/src/lib/corelib/language/projectresolver.cpp +++ b/src/lib/corelib/language/projectresolver.cpp @@ -1173,8 +1173,12 @@ void ProjectResolver::resolveRule(Item *item, ProjectContext *projectContext) rule->requiresInputs = rule->declaresInputs(); rule->auxiliaryInputs = m_evaluator->fileTagsValue(item, StringConstants::auxiliaryInputsProperty()); - rule->excludedAuxiliaryInputs - = m_evaluator->fileTagsValue(item, StringConstants::excludedAuxiliaryInputsProperty()); + rule->excludedInputs + = m_evaluator->fileTagsValue(item, StringConstants::excludedInputsProperty()); + if (rule->excludedInputs.empty()) { + rule->excludedInputs = m_evaluator->fileTagsValue( + item, StringConstants::excludedAuxiliaryInputsProperty()); + } rule->explicitlyDependsOn = m_evaluator->fileTagsValue(item, StringConstants::explicitlyDependsOnProperty()); rule->module = m_moduleContext ? m_moduleContext->module : projectContext->dummyModule; diff --git a/src/lib/corelib/tools/stringconstants.h b/src/lib/corelib/tools/stringconstants.h index 544f0a79e..fa0836d2e 100644 --- a/src/lib/corelib/tools/stringconstants.h +++ b/src/lib/corelib/tools/stringconstants.h @@ -81,6 +81,7 @@ public: QBS_STRING_CONSTANT(destinationDirProperty, "destinationDirectory") QBS_STRING_CONSTANT(excludeFilesProperty, "excludeFiles") QBS_STRING_CONSTANT(excludedAuxiliaryInputsProperty, "excludedAuxiliaryInputs") + QBS_STRING_CONSTANT(excludedInputsProperty, "excludedInputs") static const QString &explicitlyDependsOnProperty() { return explicitlyDependsOn(); } static const QString &fileNameProperty() { return fileName(); } static const QString &filePathProperty() { return filePath(); } diff --git a/src/lib/qtprofilesetup/templates/core.qbs b/src/lib/qtprofilesetup/templates/core.qbs index 968f3efa0..fddd5c0e5 100644 --- a/src/lib/qtprofilesetup/templates/core.qbs +++ b/src/lib/qtprofilesetup/templates/core.qbs @@ -257,7 +257,7 @@ Module { name: "QtCoreMocRule" inputs: ["objcpp", "cpp", "hpp"] auxiliaryInputs: ["qt_plugin_metadata"] - excludedAuxiliaryInputs: ["unmocable"] + excludedInputs: ["unmocable"] outputFileTags: ["hpp", "cpp", "moc_cpp", "unmocable"] outputArtifacts: { if (input.fileTags.contains("unmocable")) diff --git a/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs b/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs new file mode 100644 index 000000000..37c4261f4 --- /dev/null +++ b/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs @@ -0,0 +1,114 @@ +import qbs +import qbs.File +import qbs.TextFile + +Project { + Product { + name: "dep" + type: "the_tag" + Rule { + multiplex: true + Artifact { + filePath: "file1.txt" + fileTags: "the_tag" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.writeLine("the_content"); + f.close(); + }; + return cmd; + } + } + Rule { + inputs: "the_tag" + excludedInputs: "the_other_tag" + Artifact { + filePath: "file2.txt" + fileTags: "the_other_tag" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.sourceCode = function() { + File.copy(input.filePath, output.filePath); + var f = new TextFile(output.filePath, TextFile.Append); + f.writeLine("the_other_content"); + f.close(); + }; + return cmd; + } + } + Group { + fileTagsFilter: "the_other_tag" + fileTags: "the_tag" + } + } + Product { + name: "p" + type: "p_type" + Depends { name: "dep" } + Rule { + multiplex: true + inputsFromDependencies: "the_tag" + Artifact { + filePath: "dummy1.txt" + fileTags: "p_type" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName;; + if (!inputs["the_tag"] || inputs["the_tag"].length != 2) + throw "Huch?"; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.close(); + }; + return cmd; + } + } + Rule { + multiplex: true + inputsFromDependencies: "the_tag" + excludedInputs: "the_other_tag" + Artifact { + filePath: "dummy2.txt" + fileTags: "p_type" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName;; + if (!inputs["the_tag"] || inputs["the_tag"].length != 1) + throw "Huch?"; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.close(); + }; + return cmd; + } + } + Rule { + multiplex: true + explicitlyDependsOn: "the_tag" + excludedAuxiliaryInputs: "the_other_tag" + Artifact { + filePath: "dummy3.txt" + fileTags: "p_type" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + if (!explicitlyDependsOn["the_tag"] || explicitlyDependsOn["the_tag"].length != 1) + throw "Huch?"; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.close(); + }; + return cmd; + } + } + } +} diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 750ac988f..4fb2d8a3a 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -1039,6 +1039,52 @@ void TestApi::errorInSetupRunEnvironment() QVERIFY(!exceptionCaught); } +void TestApi::excludedInputs() +{ + qbs::SetupProjectParameters setupParams = defaultSetupParameters("excluded-inputs"); + std::unique_ptr<qbs::SetupProjectJob> job(qbs::Project().setupProject(setupParams, + m_logSink, 0)); + waitForFinished(job.get()); + QVERIFY2(!job->error().hasError(), qPrintable(job->error().toString())); + const qbs::Project project = job->project(); + std::unique_ptr<qbs::BuildJob> buildJob(project.buildAllProducts(qbs::BuildOptions())); + waitForFinished(buildJob.get()); + QVERIFY2(!buildJob->error().hasError(), qPrintable(job->error().toString())); + QVERIFY(project.isValid()); + QCOMPARE(project.projectData().products().size(), 2); + qbs::ProductData depProduct; + qbs::ProductData pProduct; + for (qbs::ProductData &p : project.projectData().products()) { + if (p.name() == "dep") + depProduct = p; + else if (p.name() == "p") + pProduct = p; + } + QVERIFY(depProduct.isValid()); + QVERIFY(pProduct.isValid()); + int theTagCount = 0; + for (const qbs::ArtifactData &artifact : depProduct.targetArtifacts()) { + if (!artifact.fileTags().contains("the_tag")) + continue; + ++theTagCount; + QFile f(artifact.filePath()); + QVERIFY2(f.open(QIODevice::ReadOnly), qPrintable(f.errorString())); + const QByteArray content = f.readAll(); + QVERIFY2(content.contains("the_content"), content.constData()); + QCOMPARE(artifact.fileTags().contains("the_other_tag"), + content.contains("the_other_content")); + } + QCOMPARE(theTagCount, 2); + int dummyCount = 0; + for (const qbs::ArtifactData &artifact : pProduct.targetArtifacts()) { + QFileInfo fi(artifact.filePath()); + QVERIFY2(fi.exists(), qPrintable(fi.filePath())); + if (fi.fileName().startsWith("dummy")) + ++dummyCount; + } + QCOMPARE(dummyCount, 3); +} + static qbs::ErrorInfo forceRuleEvaluation(const qbs::Project project) { qbs::BuildOptions buildOptions; diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h index c8852acdf..3f5b88715 100644 --- a/tests/auto/api/tst_api.h +++ b/tests/auto/api/tst_api.h @@ -84,6 +84,7 @@ private slots: void emptySubmodulesList(); void enableAndDisableProduct(); void errorInSetupRunEnvironment(); + void excludedInputs(); void explicitlyDependsOn(); void exportSimple(); void exportWithRecursiveDepends(); |