diff options
-rw-r--r-- | share/qbs/modules/cpp/GenericGCC.qbs | 6 | ||||
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 17 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/a1.cpp | 7 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/a2.cpp | 7 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/b.cpp | 7 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/c.cpp | 7 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/d.cpp | 9 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/dep.qbs | 68 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/e.cpp | 7 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/staticLibDeps/main.cpp | 10 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 3 |
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() |