diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-04-29 14:05:49 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-05-03 13:34:11 +0000 |
commit | 11c2b638fbc3ae5ea682c97ec009e81adb2f6c95 (patch) | |
tree | f9adbf0d5c1df30aa3162af3e3b2051628bb9c2b | |
parent | 5c9171ca2ef5bc538967c29246d5f35bf01cfea7 (diff) |
Add an "importingProduct" variable to the Export item.
It was an oversight that we did not have this before.
Change-Id: I6347be273273da301ca1ee3e23ff2ddda0a1553a
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r-- | doc/reference/items/export.qdoc | 3 | ||||
-rw-r--r-- | src/lib/corelib/language/moduleloader.cpp | 6 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/importing-product/header.h.in | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/importing-product/importing-product.qbs | 39 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/importing-product/main.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 6 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
7 files changed, 56 insertions, 1 deletions
diff --git a/doc/reference/items/export.qdoc b/doc/reference/items/export.qdoc index d41739496..31d177916 100644 --- a/doc/reference/items/export.qdoc +++ b/doc/reference/items/export.qdoc @@ -66,5 +66,6 @@ get the include paths and preprocessor macros via A's Export item. In contrast to Module items, \c{product} within Export items refers to the product which defines - the Export item. + the Export item. Use the \c{importingProduct} variable to refer to the product that + pulls in the resulting module. */ diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index f99328f92..8596c6199 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -1469,7 +1469,13 @@ void ModuleLoader::instantiateModule(ProductContext *productContext, Item *expor Item *exportScope = Item::create(moduleInstance->pool()); exportScope->setFile(instanceScope->file()); exportScope->setScope(instanceScope); + + // TODO: For consistency with modules, it should be the other way around, i.e. + // "exportingProduct" and just "product". exportScope->setProperty(QLatin1String("product"), ItemValue::create(exportingProduct)); + exportScope->setProperty(QLatin1String("importingProduct"), + ItemValue::create(productContext->item)); + exportScope->setProperty(QLatin1String("project"), ItemValue::create(exportingProduct->parent())); diff --git a/tests/auto/blackbox/testdata/importing-product/header.h.in b/tests/auto/blackbox/testdata/importing-product/header.h.in new file mode 100644 index 000000000..237c8ce18 --- /dev/null +++ b/tests/auto/blackbox/testdata/importing-product/header.h.in @@ -0,0 +1 @@ +int main() {} diff --git a/tests/auto/blackbox/testdata/importing-product/importing-product.qbs b/tests/auto/blackbox/testdata/importing-product/importing-product.qbs new file mode 100644 index 000000000..e54e8cdbd --- /dev/null +++ b/tests/auto/blackbox/testdata/importing-product/importing-product.qbs @@ -0,0 +1,39 @@ +import qbs +import qbs.File + +Project { +Product { + name: "dep" + + Export { + Depends { name: "cpp" } + cpp.includePaths: [importingProduct.buildDirectory + "/random_dir"] + + Rule { + inputs: ["hpp_in"] + Artifact { + filePath: product.buildDirectory + "/random_dir/" + input.completeBaseName + fileTags: ["hpp"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "Copying file"; + cmd.sourceCode = function() { + File.copy(input.filePath, output.filePath); + } + return [cmd]; + } + } + } +} + +CppApplication { + name: "theProduct" + Depends { name: "dep" } + Group { + files: ["header.h.in"] + fileTags: ["hpp_in"] + } + files: ["main.cpp"] +} +} diff --git a/tests/auto/blackbox/testdata/importing-product/main.cpp b/tests/auto/blackbox/testdata/importing-product/main.cpp new file mode 100644 index 000000000..901face2d --- /dev/null +++ b/tests/auto/blackbox/testdata/importing-product/main.cpp @@ -0,0 +1 @@ +#include <header.h> diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 3ae49dd8c..8fe5f4922 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -3542,6 +3542,12 @@ void TestBlackbox::iconsetApp() QVERIFY(regularFileExists(relativeProductBuildDir("iconsetapp") + "/iconsetapp.app/Contents/Resources/white.icns")); } +void TestBlackbox::importingProduct() +{ + QDir::setCurrent(testDataDir + "/importing-product"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::infoPlist() { if (!HostOsInfo::isOsxHost()) diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index a91bd7dbc..e1f9456ca 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -135,6 +135,7 @@ private slots: void groupsInModules(); void iconset(); void iconsetApp(); + void importingProduct(); void infoPlist(); void inputsFromDependencies(); void installable(); |