aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2012-12-06 10:54:37 +0100
committerJoerg Bornemann <joerg.bornemann@digia.com>2012-12-06 11:13:39 +0100
commitfb09fa02fc5323e931f314f873fea78853b15939 (patch)
tree8a32f3e51c6ad8b78aebc3dc1768d6536e8058f0
parent2be4ff05d017ac5ecd729cf9ad2f1597295b55fe (diff)
Fix renaming files to be installed that are matched by a wildcard.
The problem is that files matched by an "install" rule are currently not added to the target artifacts if a build graph already exists and they are "implicitly added" by adding or renaming a file in a group matched by a wildcard (i.e. the change happens without touching the project file). Task-number: QBS-146 Change-Id: Iec499de8dd88e3ac599b7435ec441aad7689f55a Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--src/lib/buildgraph/buildproject.cpp31
-rw-r--r--tests/auto/blackbox/testdata/wildcard_renaming/pioniere.txt0
-rw-r--r--tests/auto/blackbox/testdata/wildcard_renaming/wildcard_renaming.qbs9
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp11
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
5 files changed, 39 insertions, 13 deletions
diff --git a/src/lib/buildgraph/buildproject.cpp b/src/lib/buildgraph/buildproject.cpp
index 40c3ebe7e..4b7434e29 100644
--- a/src/lib/buildgraph/buildproject.cpp
+++ b/src/lib/buildgraph/buildproject.cpp
@@ -294,6 +294,21 @@ BuildProjectPtr BuildProjectResolver::resolveProject(const ResolvedProjectPtr &r
return m_project;
}
+static void addTargetArtifacts(const BuildProductPtr &product,
+ ArtifactsPerFileTagMap &artifactsPerFileTag)
+{
+ foreach (const QString &fileTag, product->rProduct->fileTags) {
+ foreach (Artifact * const artifact, artifactsPerFileTag.value(fileTag)) {
+ if (artifact->artifactType == Artifact::Generated)
+ product->targetArtifacts += artifact;
+ }
+ }
+ if (product->targetArtifacts.isEmpty()) {
+ QString msg = Tr::tr("No artifacts generated for product '%1'.");
+ throw Error(msg.arg(product->rProduct->name));
+ }
+}
+
BuildProductPtr BuildProjectResolver::resolveProduct(const ResolvedProductPtr &rProduct)
{
BuildProductPtr product = m_productCache.value(rProduct);
@@ -384,19 +399,7 @@ BuildProductPtr BuildProjectResolver::resolveProduct(const ResolvedProductPtr &r
}
RulesApplicator(product.data(), artifactsPerFileTag).applyAllRules();
-
- QSet<Artifact *> productArtifactCandidates;
- for (int i = 0; i < product->rProduct->fileTags.count(); ++i)
- foreach (Artifact *artifact, artifactsPerFileTag.value(product->rProduct->fileTags.at(i)))
- if (artifact->artifactType == Artifact::Generated)
- productArtifactCandidates += artifact;
-
- if (productArtifactCandidates.isEmpty()) {
- QString msg = QLatin1String("No artifacts generated for product '%1'.");
- throw Error(msg.arg(product->rProduct->name));
- }
-
- product->targetArtifacts += productArtifactCandidates;
+ addTargetArtifacts(product, artifactsPerFileTag);
m_project->addBuildProduct(product);
return product;
}
@@ -628,6 +631,8 @@ void BuildProjectLoader::onProductChanged(const BuildProductPtr &product,
artifactsPerFileTag[ft] += artifact;
RulesApplicator(product.data(), artifactsPerFileTag).applyAllRules();
+ addTargetArtifacts(product, artifactsPerFileTag);
+
// parents of removed artifacts must update their transformers
foreach (Artifact *removedArtifact, artifactsToRemove)
foreach (Artifact *parent, removedArtifact->parents)
diff --git a/tests/auto/blackbox/testdata/wildcard_renaming/pioniere.txt b/tests/auto/blackbox/testdata/wildcard_renaming/pioniere.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/blackbox/testdata/wildcard_renaming/pioniere.txt
diff --git a/tests/auto/blackbox/testdata/wildcard_renaming/wildcard_renaming.qbs b/tests/auto/blackbox/testdata/wildcard_renaming/wildcard_renaming.qbs
new file mode 100644
index 000000000..fafe77ae5
--- /dev/null
+++ b/tests/auto/blackbox/testdata/wildcard_renaming/wildcard_renaming.qbs
@@ -0,0 +1,9 @@
+import qbs.base 1.0
+
+Product {
+ type: "installed_content"
+ Group {
+ fileTags: "install"
+ files: "*"
+ }
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index ec2a95fa9..05f28e55c 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -449,4 +449,15 @@ void TestBlackbox::trackAddMocInclude()
QCOMPARE(runQbs(), 0);
}
+void TestBlackbox::wildcardRenaming()
+{
+ QDir::setCurrent(testDataDir + "/wildcard_renaming");
+ QCOMPARE(runQbs(QStringList()), 0);
+ QVERIFY(QFileInfo(buildDir + "/pioniere.txt").exists());
+ QFile::rename(QDir::currentPath() + "/pioniere.txt", QDir::currentPath() + "/fdj.txt");
+ QCOMPARE(runQbs(QStringList()), 0);
+ QVERIFY(!QFileInfo(buildDir + "/pioniere.txt").exists());
+ QVERIFY(QFileInfo(buildDir + "/fdj.txt").exists());
+}
+
QTEST_MAIN(TestBlackbox)
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 5b91dcd62..8671ef302 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -71,6 +71,7 @@ private slots:
void trackAddFileTag();
void trackRemoveFileTag();
void trackAddMocInclude();
+ void wildcardRenaming();
};
#endif // TST_BLACKBOX_H