aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2014-03-14 15:24:09 +0100
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-03-14 16:31:51 +0100
commitae6392f90d7a1de97262d934e0150cc53ea32451 (patch)
tree1bef1e06dd379c2dd425421286fdc22c9e75b227
parentfe1048e5b31504d525482c6fcf0298afdea6bda9 (diff)
fix library dependency order
Autotest from the bug report added. Task-number: QBS-524 Change-Id: I2ef3485db749424339a2ea96900e49fa5d1363d4 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
-rw-r--r--share/qbs/modules/cpp/GenericGCC.qbs6
-rw-r--r--share/qbs/modules/cpp/gcc.js17
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/a1.cpp7
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/a2.cpp7
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/b.cpp7
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/c.cpp7
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/d.cpp9
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/dep.qbs68
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/e.cpp7
-rw-r--r--tests/auto/blackbox/testdata/staticLibDeps/main.cpp10
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp3
11 files changed, 139 insertions, 9 deletions
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs
index ee5904454..342a6b70c 100644
--- a/share/qbs/modules/cpp/GenericGCC.qbs
+++ b/share/qbs/modules/cpp/GenericGCC.qbs
@@ -231,9 +231,9 @@ CppModule {
var result = []
for (var i in inputs.staticlibrary) {
var lib = inputs.staticlibrary[i]
- result.push(lib.filePath)
- var impliedLibs = ModUtils.moduleProperties(lib, 'staticLibraries')
- result = Gcc.concatLibs(result, impliedLibs);
+ result = Gcc.concatLibs(result, [lib.filePath,
+ ModUtils.moduleProperties(lib,
+ 'staticLibraries')]);
}
return result
}
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index ace391b38..6fd5c49de 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -355,14 +355,19 @@ function concatLibs(libs, deplibs)
{
var r = [];
var s = {};
- function f(e)
+
+ function addLibs(lst)
{
- if (!s[e]) {
- s[e] = true;
- r.unshift(e);
+ for (var i = lst.length; --i >= 0;) {
+ var lib = lst[i];
+ if (!s[lib]) {
+ s[lib] = true;
+ r.unshift(lib);
+ }
}
}
- deplibs.forEach(f);
- libs.forEach(f);
+
+ addLibs(deplibs);
+ addLibs(libs);
return r;
}
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/a1.cpp b/tests/auto/blackbox/testdata/staticLibDeps/a1.cpp
new file mode 100644
index 000000000..862d76783
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/a1.cpp
@@ -0,0 +1,7 @@
+#include <iostream>
+
+void a1()
+{
+ std::cout << "a1" << std::endl;
+}
+
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/a2.cpp b/tests/auto/blackbox/testdata/staticLibDeps/a2.cpp
new file mode 100644
index 000000000..d1f41731c
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/a2.cpp
@@ -0,0 +1,7 @@
+#include <iostream>
+
+void a2()
+{
+ std::cout << "a2" << std::endl;
+}
+
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/b.cpp b/tests/auto/blackbox/testdata/staticLibDeps/b.cpp
new file mode 100644
index 000000000..a88cc9d90
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/b.cpp
@@ -0,0 +1,7 @@
+void a1();
+
+void b()
+{
+ a1();
+}
+
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/c.cpp b/tests/auto/blackbox/testdata/staticLibDeps/c.cpp
new file mode 100644
index 000000000..264db582a
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/c.cpp
@@ -0,0 +1,7 @@
+void a2();
+
+void c()
+{
+ a2();
+}
+
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/d.cpp b/tests/auto/blackbox/testdata/staticLibDeps/d.cpp
new file mode 100644
index 000000000..a7a2b9f85
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/d.cpp
@@ -0,0 +1,9 @@
+void b();
+void c();
+
+void d()
+{
+ b();
+ c();
+}
+
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/dep.qbs b/tests/auto/blackbox/testdata/staticLibDeps/dep.qbs
new file mode 100644
index 000000000..06d79a32f
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/dep.qbs
@@ -0,0 +1,68 @@
+import qbs 1.0
+
+Project {
+ StaticLibrary {
+ name: "a"
+
+ Depends { name: "cpp" }
+
+ files: [
+ "a1.cpp",
+ "a2.cpp",
+ ]
+ }
+ StaticLibrary {
+ name: "b"
+
+ Depends { name: "cpp" }
+
+ Depends { name: "a" }
+
+ files: [
+ "b.cpp",
+ ]
+ }
+ StaticLibrary {
+ name: "c"
+
+ Depends { name: "cpp" }
+
+ Depends { name: "a" }
+
+ files: [
+ "c.cpp",
+ ]
+ }
+ StaticLibrary {
+ name: "d"
+
+ Depends { name: "cpp" }
+
+ Depends { name: "b" }
+ Depends { name: "c" }
+
+ files: [
+ "d.cpp",
+ ]
+ }
+ StaticLibrary {
+ name: "e"
+
+ Depends { name: "cpp" }
+
+ Depends { name: "d" }
+
+ files: [
+ "e.cpp",
+ ]
+ }
+ CppApplication {
+ name: "staticLibDeps"
+
+ Depends { name: "e" }
+
+ files: [
+ "main.cpp",
+ ]
+ }
+}
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/e.cpp b/tests/auto/blackbox/testdata/staticLibDeps/e.cpp
new file mode 100644
index 000000000..af7d24682
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/e.cpp
@@ -0,0 +1,7 @@
+void d();
+
+void e()
+{
+ d();
+}
+
diff --git a/tests/auto/blackbox/testdata/staticLibDeps/main.cpp b/tests/auto/blackbox/testdata/staticLibDeps/main.cpp
new file mode 100644
index 000000000..3753dd5cb
--- /dev/null
+++ b/tests/auto/blackbox/testdata/staticLibDeps/main.cpp
@@ -0,0 +1,10 @@
+#include <cstdlib>
+
+void e();
+
+int main()
+{
+ e();
+ return EXIT_SUCCESS;
+}
+
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index db0928e4d..76f9d6b6a 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -302,6 +302,9 @@ void TestBlackbox::build_project_data()
QTest::newRow("source files with the same base name but different extensions")
<< QString("sameBaseName")
<< QString(HostOsInfo::appendExecutableSuffix(buildDir + "/basename"));
+ QTest::newRow("static library dependencies")
+ << QString("staticLibDeps")
+ << QString(HostOsInfo::appendExecutableSuffix(buildDir + "/staticLibDeps"));
}
void TestBlackbox::build_project()