summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-04-16 14:34:46 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-04-19 13:44:24 +0000
commit99bb3be64acae4f9d1bf2af150a503564a79f20b (patch)
treef45af55042d6cfaaae7f7bde461b03ecc956f4f7
parentf092eb3d17dc06e9196c95570a52dc5509b55484 (diff)
downloadqbs-99bb3be64acae4f9d1bf2af150a503564a79f20b.tar.gz
Prevent empty arrays from ending up in the JS artifacts map
We want to guarantee that p.artifacts["xyz"] is undefined if product or module "p" does not have an artifact tagged "xyz". Otherwise, the code on the JS side becomes needlessly complicated. Change-Id: I6bffa2289ce8a021eb856697545a8149f88e616d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/lib/corelib/buildgraph/buildgraph.cpp5
-rw-r--r--tests/auto/blackbox/testdata/dynamic-library-in-module/lib5.cpp1
-rw-r--r--tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs7
3 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp
index f36426075..a0dd7e8d4 100644
--- a/src/lib/corelib/buildgraph/buildgraph.cpp
+++ b/src/lib/corelib/buildgraph/buildgraph.cpp
@@ -146,6 +146,11 @@ template<class ProductOrModule> static QScriptValue js_artifacts(
ctx->callee().setProperty(CachedValueKey, artifactsObj);
const auto &map = artifactsMap(productOrModule);
for (auto it = map.cbegin(); it != map.cend(); ++it) {
+ const auto filter = [productOrModule](const Artifact *a) {
+ return isRelevantArtifact(productOrModule, a);
+ };
+ if (std::none_of(it.value().cbegin(), it.value().cend(), filter))
+ continue;
QScriptValue fileTagFunc = engine->newFunction(&js_artifactsForFileTag<ProductOrModule>,
productOrModule);
const QString fileTag = it.key().toString();
diff --git a/tests/auto/blackbox/testdata/dynamic-library-in-module/lib5.cpp b/tests/auto/blackbox/testdata/dynamic-library-in-module/lib5.cpp
new file mode 100644
index 000000000..49887a957
--- /dev/null
+++ b/tests/auto/blackbox/testdata/dynamic-library-in-module/lib5.cpp
@@ -0,0 +1 @@
+void staticLibFunc() { }
diff --git a/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs b/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs
index cfad43973..6bd0de9ab 100644
--- a/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs
+++ b/tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs
@@ -7,6 +7,7 @@ Project {
Depends { name: "theotherlib" }
Depends { name: "thethirdlib" }
Depends { name: "thefourthlib" }
+ Depends { name: "staticlib" }
files: "main.cpp"
Group {
fileTagsFilter: "dynamiclibrary"
@@ -23,4 +24,10 @@ Project {
cpp.rpaths: [qbs.installRoot]
}
}
+ StaticLibrary {
+ name: "staticlib"
+ Depends { name: "cpp" }
+ Depends { name: "theotherlib" }
+ files: "lib5.cpp"
+ }
}