diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2020-08-03 23:03:54 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2020-08-04 16:38:50 +0000 |
commit | 1428a3f8f08759239d30fc92337d83c7b0b94305 (patch) | |
tree | 0df3c3bf44f7d2618a2348f5ee33d02ae8049b92 | |
parent | ec3181bb83f223b18b029d5776f427a3019f2381 (diff) | |
download | qbs-1428a3f8f08759239d30fc92337d83c7b0b94305.tar.gz |
baremetal: Add new 'external-static-libraries' test
This test checks the cpp.libraryPaths and the cpp.staticLibraries
properties.
This test excluded for the KEIL C51/C251/C166 toolchains,
because this toolchains has not the options to specify the
library search paths:
* https://www.keil.com/support/docs/1298.htm
Change-Id: I17b5dc64ae3baacb32621b359863ba42c908d416
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
7 files changed, 81 insertions, 0 deletions
diff --git a/share/qbs/modules/cpp/keil.qbs b/share/qbs/modules/cpp/keil.qbs index 9898ecc77..7a994d7ea 100644 --- a/share/qbs/modules/cpp/keil.qbs +++ b/share/qbs/modules/cpp/keil.qbs @@ -126,6 +126,7 @@ CppModule { id: applicationLinker multiplex: true inputs: ["obj", "linkerscript"] + inputsFromDependencies: ["staticlibrary"] outputFileTags: ["application", "mem_map"] outputArtifacts: KEIL.applicationLinkerOutputArtifacts(product) prepare: KEIL.prepareLinker.apply(KEIL, arguments) diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs new file mode 100644 index 000000000..6fbbb8647 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs @@ -0,0 +1,48 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication +import "../BareMetalStaticLibrary.qbs" as BareMetalStaticLibrary + +Project { + condition: { + // The KEIL C51/C251/C166 toolchains support only a + // full paths to the external libraries. + if (qbs.toolchainType === "keil") { + if (qbs.architecture === "mcs51" + || qbs.architecture === "mcs251" + || qbs.architecture === "c166") { + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + } + return true; + } + property string outputLibrariesDirectory: sourceDirectory + "/libs" + BareMetalStaticLibrary { + name: "lib-a" + destinationDirectory: project.outputLibrariesDirectory + Depends { name: "cpp" } + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + } + files: ["lib-a.c"] + } + BareMetalStaticLibrary { + name: "lib-b" + destinationDirectory: project.outputLibrariesDirectory + Depends { name: "cpp" } + Depends { name: "lib-a" } + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + } + files: ["lib-b.c"] + } + BareMetalApplication { + Depends { name: "lib-a"; cpp.link: false } + Depends { name: "lib-b"; cpp.link: false } + files: ["main.c"] + cpp.libraryPaths: [project.outputLibrariesDirectory] + cpp.staticLibraries: ["lib-b", "lib-a"] + } +} diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-a.c b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-a.c new file mode 100644 index 000000000..13401861f --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-a.c @@ -0,0 +1,4 @@ +int a(void) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-b.c b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-b.c new file mode 100644 index 000000000..5d45b8175 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-b.c @@ -0,0 +1,6 @@ +extern int a(void); + +int b(void) +{ + return a(); +} diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/main.c b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/main.c new file mode 100644 index 000000000..84ef5e51e --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/main.c @@ -0,0 +1,6 @@ +extern int b(); + +int main(void) +{ + return b(); +} diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp index ba71ae954..99b86b930 100644 --- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp +++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp @@ -107,6 +107,21 @@ void TestBlackboxBareMetal::staticLibraryDependencies() QVERIFY(output.contains("lib-e")); } +void TestBlackboxBareMetal::externalStaticLibraries() +{ + QDir::setCurrent(testDataDir + "/external-static-libraries"); + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (!m_qbsStdout.contains("unsupported toolset:")) { + QCOMPARE(runQbs(), 0); + } else { + QByteArray toolchain; + QByteArray architecture; + extractUnsupportedToolset(m_qbsStdout, toolchain, architecture); + QSKIP("Unsupported toolchain '" + toolchain + + "' for architecture '" + architecture + "'"); + } +} + void TestBlackboxBareMetal::userIncludePaths() { QDir::setCurrent(testDataDir + "/user-include-paths"); diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.h b/tests/auto/blackbox/tst_blackboxbaremetal.h index f3376b0ba..0bfe3f18c 100644 --- a/tests/auto/blackbox/tst_blackboxbaremetal.h +++ b/tests/auto/blackbox/tst_blackboxbaremetal.h @@ -47,6 +47,7 @@ private slots: void application(); void staticLibraryDependencies(); + void externalStaticLibraries(); void userIncludePaths(); void systemIncludePaths(); |