diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2023-07-20 23:58:02 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2023-07-21 12:14:05 +0000 |
commit | 1410d1f12fb99fb8ab82fe3c2969bc18445a1165 (patch) | |
tree | d34814c262d9f8e77f89b958b3139fce66f3aa3d | |
parent | cf6faffcf26cdeb5139d64d976a971770ffdd0ee (diff) |
Loader: Add proper id scope for product-level items
As we do for modules. We can't use the file-level id scope because of
multiplexing.
Change-Id: Ib8a72b4ce06225ad24c78d0de4a7addb749d2469
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
-rw-r--r-- | changelogs/changes-2.1.1.md | 5 | ||||
-rw-r--r-- | src/lib/corelib/loader/productscollector.cpp | 15 | ||||
-rw-r--r-- | tests/auto/language/tst_language.cpp | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/changelogs/changes-2.1.1.md b/changelogs/changes-2.1.1.md new file mode 100644 index 000000000..00a82e466 --- /dev/null +++ b/changelogs/changes-2.1.1.md @@ -0,0 +1,5 @@ +# General +* Fixed Probe lookup in multiplexed products. + +# Contributors +* Christian Kandeler diff --git a/src/lib/corelib/loader/productscollector.cpp b/src/lib/corelib/loader/productscollector.cpp index 95b248c73..340398016 100644 --- a/src/lib/corelib/loader/productscollector.cpp +++ b/src/lib/corelib/loader/productscollector.cpp @@ -343,6 +343,21 @@ void ProductsCollector::Private::prepareProduct(ProjectContext &projectContext, productContext.scope->setFile(productItem->file()); productContext.scope->setScope(productContext.project->scope); + // If there are any child items with an id, set up a scope for them. This is mostly + // relevant for Probe items. While we might get away with using the file's id scope + // in the absence of multiplexing, having a proper per-product scope seems cleaner. + QBS_CHECK(productItem->scope()); + QBS_CHECK(productItem->scope() == productContext.project->scope); + for (Item * const child : productItem->children()) { + if (child->id().isEmpty()) + continue; + if (productItem->scope() == productContext.project->scope) { + productItem->setScope(Item::create(productItem->pool(), ItemType::Scope)); + productItem->scope()->setScope(productContext.project->scope); + } + productItem->scope()->setProperty(child->id(), ItemValue::create(child)); + } + const bool hasExportItems = mergeExportItems(productContext); setScopeForDescendants(productItem, productContext.scope); diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index 4d4d9faa1..c74a6734f 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -2414,8 +2414,6 @@ void TestLanguage::probesAndMultiplexing() const QString arch = product->moduleProperties->moduleProperty("qbs", "architecture") .toString(); QVERIFY2(architectures.removeOne(arch), qPrintable(arch)); - if (arch != "x86") - QEXPECT_FAIL("", "FIXME: Add items for ids as in ModuleInstantiator", Continue); QCOMPARE(product->productProperties.value("archFromProbe").toString(), arch); } } catch (const ErrorInfo &e) { |