diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-03-06 10:46:26 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-03-14 08:53:13 +0000 |
commit | 2acaba8ea211e1ba00c2e2844aa00ca16c7a04f4 (patch) | |
tree | 6be71fac638be27609fb6b196ce73d058780c67f /tests/auto/blackbox/testdata/exports-qbs | |
parent | 149e20aca1e401ba18bbae602df2caa7dc68c493 (diff) |
Add module Exporter.qbs
This module generates qbs modules from products, providing an interface
to them for use by external projects.
[ChangeLog] Added new module "Exporter.qbs" for creating qbs modules
from products.
Task-number: QBS-1231
Change-Id: I9f0cf04b441aaf279cf19a84fd94d97a8cea9de8
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/blackbox/testdata/exports-qbs')
8 files changed, 187 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/exports-qbs/consumer.cpp b/tests/auto/blackbox/testdata/exports-qbs/consumer.cpp new file mode 100644 index 000000000..25338b611 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/consumer.cpp @@ -0,0 +1,6 @@ +void helper(); + +int main() +{ + helper(); +} diff --git a/tests/auto/blackbox/testdata/exports-qbs/consumer.qbs b/tests/auto/blackbox/testdata/exports-qbs/consumer.qbs new file mode 100644 index 000000000..57f2adc15 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/consumer.qbs @@ -0,0 +1,14 @@ +import qbs + +CppApplication { + name: "consumer" + qbsSearchPaths: "default/install-root/usr/qbs" + property string outTag: "cpp" + Depends { name: "MyLib" } + Depends { name: "MyTool" } + files: ["consumer.cpp"] + Group { + files: ["helper.cpp.in"] + fileTags: ["cpp.in"] + } +} diff --git a/tests/auto/blackbox/testdata/exports-qbs/exports-qbs.qbs b/tests/auto/blackbox/testdata/exports-qbs/exports-qbs.qbs new file mode 100644 index 000000000..b84c44b5f --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/exports-qbs.qbs @@ -0,0 +1,120 @@ +import qbs +import qbs.FileInfo + +import "helper.js" as Helper + +Project { + property string installPrefix: "/usr" + Product { + name: "local" + Export { + property bool dummy + Depends { name: "cpp" } + cpp.includePaths: ["/somelocaldir/include"] + } + } + + CppApplication { + name: "MyTool" + consoleApplication: true + property stringList toolTags: ["MyTool.tool"] + Depends { name: "Exporter.qbs" } + Exporter.qbs.artifactTypes: ["installable", "blubb"] + files: ["tool.cpp"] + qbs.installPrefix: project.installPrefix + Group { + files: ["helper.js"] + qbs.install: true + qbs.installDir: "qbs/modules/MyTool" + } + + Group { + fileTagsFilter: ["application"] + qbs.install: true + qbs.installDir: "bin" + fileTags: toolTags + } + Group { + fileTagsFilter: ["Exporter.qbs.module"] + qbs.installDir: "qbs/modules/MyTool" + } + + Export { + property stringList toolTags: product.toolTags + property stringList outTags: [importingProduct.outTag] + Rule { + inputs: Helper.toolInputs() + explicitlyDependsOn: toolTags + + outputFileTags: parent.outTags + outputArtifacts: [{ + filePath: FileInfo.completeBaseName(input.fileName), + fileTags: product.MyTool.outTags + }] + prepare: { + var cmd = new Command(explicitlyDependsOn["MyTool.tool"][0].filePath, + [input.filePath, output.filePath]); + cmd.description = input.fileName + " -> " + output.fileName; + return [cmd]; + } + } + } + } + + DynamicLibrary { + name: "MyLib" + multiplexByQbsProperties: ["buildVariants"] + aggregate: false + qbs.buildVariants: ["debug", "release"] + qbs.installPrefix: project.installPrefix + Depends { name: "cpp" } + Depends { name: "Exporter.qbs" } + Exporter.qbs.fileName: name + "_" + qbs.buildVariant + ".qbs" + Exporter.qbs.excludedDependencies: ["local"] + Exporter.qbs.additionalContent: " condition: qbs.buildVariant === '" + + qbs.buildVariant + "'" + property string headersInstallDir: "include" + cpp.defines: ["MYLIB_BUILD"] + cpp.variantSuffix: qbs.buildVariant === "debug" ? "d" : "" + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + } + files: ["mylib.cpp"] + Group { + name: "API headers" + files: ["mylib.h"] + qbs.install: true + qbs.installDir: headersInstallDir + } + Group { + fileTagsFilter: ["dynamiclibrary", "dynamiclibrary_import"] + qbs.install: true + qbs.installDir: "lib" + } + Group { + fileTagsFilter: ["Exporter.qbs.module"] + qbs.install: true + qbs.installDir: "qbs/modules/MyLib" + } + + Export { + Depends { name: "cpp" } + property string includeDir: product.sourceDirectory + Properties { + condition: true + cpp.includePaths: [includeDir] + cpp.dynamicLibraries: [] + } + cpp.dynamicLibraries: ["nosuchlib"] + Depends { name: "local" } + local.dummy: true + prefixMapping: [{ + prefix: includeDir, + replacement: FileInfo.joinPaths(qbs.installPrefix, product.headersInstallDir) + }] + } + } + + references: ["consumer.qbs"] +} diff --git a/tests/auto/blackbox/testdata/exports-qbs/helper.cpp.in b/tests/auto/blackbox/testdata/exports-qbs/helper.cpp.in new file mode 100644 index 000000000..21c1f8ee6 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/helper.cpp.in @@ -0,0 +1,6 @@ +#include <mylib.h> + +void helper() +{ + MyLib::f(); +} diff --git a/tests/auto/blackbox/testdata/exports-qbs/helper.js b/tests/auto/blackbox/testdata/exports-qbs/helper.js new file mode 100644 index 000000000..17c4e91c0 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/helper.js @@ -0,0 +1 @@ +function toolInputs() { return ["cpp.in"]; } diff --git a/tests/auto/blackbox/testdata/exports-qbs/mylib.cpp b/tests/auto/blackbox/testdata/exports-qbs/mylib.cpp new file mode 100644 index 000000000..f3dc6a435 --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/mylib.cpp @@ -0,0 +1,5 @@ +#include "mylib.h" + +namespace MyLib { +void f() {} +} diff --git a/tests/auto/blackbox/testdata/exports-qbs/mylib.h b/tests/auto/blackbox/testdata/exports-qbs/mylib.h new file mode 100644 index 000000000..9f5f8269e --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/mylib.h @@ -0,0 +1,17 @@ +#if defined(_WIN32) || defined(WIN32) +# define DLL_EXPORT __declspec(dllexport) +# define DLL_IMPORT __declspec(dllimport) +#else +# define DLL_EXPORT __attribute__((visibility("default"))) +# define DLL_IMPORT __attribute__((visibility("default"))) +# endif + +#ifdef MYLIB_BUILD +#define MYLIB_EXPORT DLL_EXPORT +#else +#define MYLIB_EXPORT DLL_IMPORT +#endif + +namespace MyLib { +MYLIB_EXPORT void f(); +} diff --git a/tests/auto/blackbox/testdata/exports-qbs/tool.cpp b/tests/auto/blackbox/testdata/exports-qbs/tool.cpp new file mode 100644 index 000000000..4657033fd --- /dev/null +++ b/tests/auto/blackbox/testdata/exports-qbs/tool.cpp @@ -0,0 +1,18 @@ +#include <cstdlib> +#include <fstream> + +int main(int argc, char *argv[]) +{ + if (argc != 3) + return EXIT_FAILURE; + std::ifstream in(argv[1]); + if (!in) + return EXIT_FAILURE; + std::ofstream out(argv[2]); + if (!out) + return EXIT_FAILURE; + char ch; + while (in.get(ch)) + out.put(ch); + return in.eof() && out ? EXIT_SUCCESS : EXIT_FAILURE; +} |