aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-04-20 12:20:30 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2017-04-21 07:11:29 +0000
commitd50136199ba49ce1a87dffbce2353f8777d592b1 (patch)
treeb966bfbe9765e31babba6195efbe8676df142b5b
parentd5542fa418045d5ff7b8a1af33761ee245407841 (diff)
GCC: Do not mess with the list of external libraries
Consider the following: There are external static libraries libA and libB, with libB having a dependency on libA. Some module pulls in libA, another one pulls in libB and libA. The raw contents of cpp.staticLibraries for the product might end up as ["libA","libB","libA"]. Before this patch, our library collection code "simplified" this list to ["libA","libB"], which leads to a linker error. Since we generally do not know about the dependencies of external libraries, we should not touch these lists. Change-Id: I4a94dfc8505ee9ece2562dc3aa3d66244ec7fdac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--share/qbs/modules/cpp/gcc.js10
-rw-r--r--tests/auto/blackbox/testdata/external-libs/external-libs.qbs62
-rw-r--r--tests/auto/blackbox/testdata/external-libs/lib1.cpp1
-rw-r--r--tests/auto/blackbox/testdata/external-libs/lib2.cpp3
-rw-r--r--tests/auto/blackbox/testdata/external-libs/main.cpp6
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp6
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
7 files changed, 81 insertions, 8 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index 7c6108870..def8d6c76 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -109,14 +109,8 @@ function collectLibraryDependencies(product) {
var externalLibs = [].concat(
ModUtils.sanitizedModuleProperty(obj, "cpp", "staticLibraries"),
ModUtils.sanitizedModuleProperty(obj, "cpp", "dynamicLibraries"));
- for (var i = 0, len = externalLibs.length; i < len; ++i) {
- var filePath = externalLibs[i];
- var existing = objectByFilePath[filePath];
- if (existing)
- existing.direct = true;
- else
- addObject({ direct: true, filePath: filePath }, Array.prototype.push);
- }
+ for (var i = 0, len = externalLibs.length; i < len; ++i)
+ addObject({ direct: true, filePath: externalLibs[i] }, Array.prototype.push);
}
function traverse(dep, isBelowIndirectDynamicLib) {
diff --git a/tests/auto/blackbox/testdata/external-libs/external-libs.qbs b/tests/auto/blackbox/testdata/external-libs/external-libs.qbs
new file mode 100644
index 000000000..9a5bbdd6b
--- /dev/null
+++ b/tests/auto/blackbox/testdata/external-libs/external-libs.qbs
@@ -0,0 +1,62 @@
+import qbs
+import qbs.TextFile
+
+Project {
+ property string libDir: sourceDirectory + "/libs"
+ StaticLibrary {
+ name: "lib1"
+ destinationDirectory: project.libDir
+ Depends { name: "cpp" }
+ files: ["lib1.cpp"]
+ }
+ StaticLibrary {
+ name: "lib2"
+ destinationDirectory: project.libDir
+ Depends { name: "cpp" }
+ Depends { name: "lib1" }
+ files: ["lib2.cpp"]
+ }
+ // TODO: Remove once we have parameterized dependencies
+ Product {
+ name: "barrier"
+ type: ["blubb"]
+ Depends { name: "lib1" }
+ Depends { name: "lib2" }
+ Rule {
+ multiplex: true
+ inputsFromDependencies: ["staticlibrary"]
+ Artifact {
+ filePath: "dummy"
+ fileTags: ["blubb"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.silent = true;
+ cmd.sourceCode = function() { }
+ return [cmd];
+ }
+ }
+ }
+ CppApplication {
+ Depends { name: "barrier" }
+ files: ["main.cpp"]
+ cpp.libraryPaths: [project.libDir]
+ cpp.staticLibraries: ["lib1", "lib2", "lib1"]
+ Rule {
+ inputsFromDependencies: ["blubb"]
+ Artifact {
+ filePath: "dummy.cpp"
+ fileTags: ["cpp"]
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.sourceCode = function() {
+ var f = new TextFile(output.filePath, TextFile.WriteOnly);
+ f.writeLine("void dummy() { }");
+ f.close();
+ };
+ return [cmd];
+ }
+ }
+ }
+}
diff --git a/tests/auto/blackbox/testdata/external-libs/lib1.cpp b/tests/auto/blackbox/testdata/external-libs/lib1.cpp
new file mode 100644
index 000000000..bb69fa422
--- /dev/null
+++ b/tests/auto/blackbox/testdata/external-libs/lib1.cpp
@@ -0,0 +1 @@
+void func_lib1() { }
diff --git a/tests/auto/blackbox/testdata/external-libs/lib2.cpp b/tests/auto/blackbox/testdata/external-libs/lib2.cpp
new file mode 100644
index 000000000..e669a7f6c
--- /dev/null
+++ b/tests/auto/blackbox/testdata/external-libs/lib2.cpp
@@ -0,0 +1,3 @@
+void func_lib1();
+
+void func_lib2() { func_lib1(); }
diff --git a/tests/auto/blackbox/testdata/external-libs/main.cpp b/tests/auto/blackbox/testdata/external-libs/main.cpp
new file mode 100644
index 000000000..9a6eab23e
--- /dev/null
+++ b/tests/auto/blackbox/testdata/external-libs/main.cpp
@@ -0,0 +1,6 @@
+void func_lib2();
+
+int main()
+{
+ func_lib2();
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index fe405a502..444dcfd38 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2791,6 +2791,12 @@ void TestBlackbox::exportToOutsideSearchPath()
"dependencies for product 'theProduct'"), m_qbsStderr.constData());
}
+void TestBlackbox::externalLibs()
+{
+ QDir::setCurrent(testDataDir + "/external-libs");
+ QCOMPARE(runQbs(), 0);
+}
+
void TestBlackbox::fileDependencies()
{
QDir::setCurrent(testDataDir + "/fileDependencies");
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index a11f87343..7a4a0cb67 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -83,6 +83,7 @@ private slots:
void escapedLinkerFlags();
void exportRule();
void exportToOutsideSearchPath();
+ void externalLibs();
void fileDependencies();
void frameworkStructure();
void generatedArtifactAsInputToDynamicRule();