diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-05-23 12:26:46 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2014-05-26 16:16:59 +0200 |
commit | 875f9ba4e7631a3c66e1edfc54f6b4ed6a42b841 (patch) | |
tree | 8ca26ea03d6b85b99f2ba4464850a4f319f81b43 | |
parent | 8917e0cecd80a5d673ac4a6d6586b472aa019d1b (diff) |
run rules on dependency-only products
This enables compound products that do not provide their own source
files but only consist of dependencies.
Task-number: QBS-277
Change-Id: I8e3fc5b5e3a85ca2c6fe4890dcd52d3a55cebfe2
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
-rw-r--r-- | src/lib/corelib/buildgraph/rulenode.cpp | 15 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rulenode.h | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rulesapplicator.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/language/language.cpp | 9 | ||||
-rw-r--r-- | src/lib/corelib/language/language.h | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/appWithoutSources/a.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/appWithoutSources/b.cpp | 10 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/appWithoutSources/project.qbs | 30 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 3 |
9 files changed, 71 insertions, 2 deletions
diff --git a/src/lib/corelib/buildgraph/rulenode.cpp b/src/lib/corelib/buildgraph/rulenode.cpp index 032af9c37..efba23e68 100644 --- a/src/lib/corelib/buildgraph/rulenode.cpp +++ b/src/lib/corelib/buildgraph/rulenode.cpp @@ -67,7 +67,7 @@ void RuleNode::apply(const Logger &logger, const ArtifactSet &changedInputs, { bool hasAddedTags = false; bool hasRemovedTags = false; - result->upToDate = changedInputs.isEmpty(); + result->upToDate = changedInputs.isEmpty() && !usedDependenciesAdded(); ProductBuildData::ArtifactSetByFileTag relevantArtifacts; if (product->isMarkedForReapplication(m_rule)) { @@ -141,5 +141,18 @@ void RuleNode::store(PersistentPool &pool) const pool.store(m_rule); } +bool RuleNode::usedDependenciesAdded() const +{ + foreach (const ResolvedProductConstPtr &dep, product->dependencies) { + if (!dep->buildData || !dep->fileTags.matches(rule()->usings)) + continue; + foreach (Artifact *a, dep->targetArtifacts()) { + if (a->fileTags.matches(rule()->usings) && a->product->isAdded(a)) + return true; + } + } + return false; +} + } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/buildgraph/rulenode.h b/src/lib/corelib/buildgraph/rulenode.h index abf0a8e59..dce9a6381 100644 --- a/src/lib/corelib/buildgraph/rulenode.h +++ b/src/lib/corelib/buildgraph/rulenode.h @@ -65,6 +65,8 @@ protected: void store(PersistentPool &pool) const; private: + bool usedDependenciesAdded() const; + RuleConstPtr m_rule; }; diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp index 497f2d30a..5633916a2 100644 --- a/src/lib/corelib/buildgraph/rulesapplicator.cpp +++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp @@ -94,7 +94,7 @@ void RulesApplicator::applyRule(const RuleConstPtr &rule) } } - if (inputArtifacts.isEmpty()) + if (inputArtifacts.isEmpty() && usingsArtifacts.isEmpty()) return; if (rule->name == QLatin1String("QtCoreMocRule")) { diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index fce173f5f..379f2ea8e 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -746,6 +746,15 @@ const ArtifactSet ResolvedProduct::addedArtifactsByFileTag(const FileTag &tag) c return buildData->addedArtifactsByFileTag.value(tag); } +bool ResolvedProduct::isAdded(Artifact *a) const +{ + foreach (const ArtifactSet &artifacts, buildData->addedArtifactsByFileTag) { + if (artifacts.contains(a)) + return true; + } + return false; +} + const ArtifactSet ResolvedProduct::removedArtifactsByFileTag(const FileTag &tag) const { return buildData->removedArtifactsByFileTag.value(tag); diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h index 70d7fb9ea..fdfb7e44e 100644 --- a/src/lib/corelib/language/language.h +++ b/src/lib/corelib/language/language.h @@ -389,6 +389,7 @@ public: void unregisterArtifactWithChangedInputs(Artifact *artifact); void unmarkForReapplication(const RuleConstPtr &rule); const ArtifactSet addedArtifactsByFileTag(const FileTag &tag) const; + bool isAdded(Artifact *a) const; const ArtifactSet removedArtifactsByFileTag(const FileTag &tag) const; bool isMarkedForReapplication(const RuleConstPtr &rule) const; ArtifactSet lookupArtifactsByFileTag(const FileTag &tag) const; diff --git a/tests/auto/blackbox/testdata/appWithoutSources/a.cpp b/tests/auto/blackbox/testdata/appWithoutSources/a.cpp new file mode 100644 index 000000000..bf7759e11 --- /dev/null +++ b/tests/auto/blackbox/testdata/appWithoutSources/a.cpp @@ -0,0 +1 @@ +int foo() { return 42; } diff --git a/tests/auto/blackbox/testdata/appWithoutSources/b.cpp b/tests/auto/blackbox/testdata/appWithoutSources/b.cpp new file mode 100644 index 000000000..76c93685d --- /dev/null +++ b/tests/auto/blackbox/testdata/appWithoutSources/b.cpp @@ -0,0 +1,10 @@ +#include <cstdio> + +int foo(); // defined in a.cpp + +int main() +{ + printf("The answer is %d.\n", foo()); + return 0; +} + diff --git a/tests/auto/blackbox/testdata/appWithoutSources/project.qbs b/tests/auto/blackbox/testdata/appWithoutSources/project.qbs new file mode 100644 index 000000000..983cc9bab --- /dev/null +++ b/tests/auto/blackbox/testdata/appWithoutSources/project.qbs @@ -0,0 +1,30 @@ +import qbs 1.0 + +Project { + StaticLibrary { + name: "a" + + Depends { name: "cpp" } + + files: [ + "a.cpp", + ] + } + + StaticLibrary { + name: "b" + + Depends { name: "a" } + Depends { name: "cpp" } + + files: [ + "b.cpp", + ] + } + + CppApplication { + name: "appWithoutSources" + Depends { name: "a" } + Depends { name: "b" } + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 2d7d9e5aa..86895c114 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -324,6 +324,9 @@ void TestBlackbox::build_project_data() QTest::newRow("simple probes") << QString("simpleProbe") << executableFilePath("MyApp"); + QTest::newRow("application without sources") + << QString("appWithoutSources") + << executableFilePath("appWithoutSources"); } void TestBlackbox::build_project() |