From abfc4c1b37d18515c8da0678a665886d7cb69af5 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 6 Mar 2018 18:17:04 +0100 Subject: Fix exports from multiplexed products While we did set up the dependencies between multiplexed products correctly, the *module* (i.e. Export item) that we pulled in was always the same one and corresponded to the wrong product variant in most cases. Change-Id: If42cf7e946689259c7433d81fd35d8798919eb15 Reviewed-by: Joerg Bornemann --- .../auto/language/testdata/multiplexed-exports.qbs | 20 +++++++++++ tests/auto/language/tst_language.cpp | 39 +++++++++++++++++++++- tests/auto/language/tst_language.h | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/auto/language/testdata/multiplexed-exports.qbs (limited to 'tests/auto/language') diff --git a/tests/auto/language/testdata/multiplexed-exports.qbs b/tests/auto/language/testdata/multiplexed-exports.qbs new file mode 100644 index 000000000..923ddc2ab --- /dev/null +++ b/tests/auto/language/testdata/multiplexed-exports.qbs @@ -0,0 +1,20 @@ +import qbs + +Project { + Product { + name: "dep" + multiplexByQbsProperties: ["buildVariants"] + qbs.buildVariants: ["debug", "release"] + property string includeDir: qbs.buildVariant === "debug" ? "/d" : "/r" + Export { + Depends { name: "cpp" } + cpp.includePaths: product.includeDir + } + } + Product { + name: "p" + Depends { name: "dep" } + multiplexByQbsProperties: ["buildVariants"] + qbs.buildVariants: ["debug", "release"] + } +} diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index f1e21cc26..bfbb0c525 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -68,6 +68,7 @@ #include #include +#include #include #include @@ -832,7 +833,7 @@ void TestLanguage::erroneousFiles_data() << "original-in-product-property.qbs" ":4:21.*The special value 'original' can only be used with module properties."; QTest::newRow("mismatching-multiplex-dependency") - << "mismatching-multiplex-dependency.qbs:9:5 Dependency from product " + << "mismatching-multiplex-dependency.qbs:9:5.*Dependency from product " "'b \\{\"architecture\":\"mips\"\\}' to product 'a \\{\"architecture\":\"mips\"\\}'" " not fulfilled."; } @@ -1887,6 +1888,42 @@ void TestLanguage::modules() QCOMPARE(product->productProperties.value("foo").toString(), expectedProductProperty); } +void TestLanguage::multiplexedExports() +{ + bool exceptionCaught = false; + try { + SetupProjectParameters params = defaultParameters; + params.setProjectFilePath(testProject("multiplexed-exports.qbs")); + const TopLevelProjectPtr project = loader->loadProject(params); + QVERIFY(!!project); + const auto products = project->allProducts(); + QCOMPARE(products.size(), 4); + std::set pVariants; + for (const auto &product : products) { + if (product->name != "p") + continue; + static const auto buildVariant = [](const ResolvedProductConstPtr &p) { + return p->moduleProperties->qbsPropertyValue("buildVariant").toString(); + }; + static const auto cppIncludePaths = [](const ResolvedProductConstPtr &p) { + return p->moduleProperties->moduleProperty("cpp", "includePaths").toStringList(); + }; + if (buildVariant(product) == "debug") { + pVariants.insert(product); + QCOMPARE(cppIncludePaths(product), QStringList("/d")); + } else if (buildVariant(product) == "release") { + pVariants.insert(product); + QCOMPARE(cppIncludePaths(product), QStringList("/r")); + } + } + QCOMPARE(int(pVariants.size()), 2); + } catch (const ErrorInfo &e) { + exceptionCaught = true; + qDebug() << e.toString(); + } + QCOMPARE(exceptionCaught, false); +} + void TestLanguage::multiplexingByProfile() { QFETCH(QString, projectFileName); diff --git a/tests/auto/language/tst_language.h b/tests/auto/language/tst_language.h index edbebef5e..c80152f28 100644 --- a/tests/auto/language/tst_language.h +++ b/tests/auto/language/tst_language.h @@ -126,6 +126,7 @@ private slots: void moduleScope(); void modules_data(); void modules(); + void multiplexedExports(); void multiplexingByProfile(); void multiplexingByProfile_data(); void nonApplicableModulePropertyInProfile(); -- cgit v1.2.3