From e86375117120f8c7b06afa573d9772d3c783f737 Mon Sep 17 00:00:00 2001 From: Richard Weickelt Date: Mon, 23 Sep 2019 20:30:04 +0200 Subject: Evaluate probes before Profile items Profile items can reference project properties, but accessing properties of project-level probes failed. This patch ensures that probes are executed before Profile items are evaluated. Fixes: QBS-1490 Change-Id: I5c215b91ded51ac895e433faa2e6fcfbc3d3e212 Reviewed-by: Christian Kandeler --- src/lib/corelib/language/moduleloader.cpp | 6 +++--- .../project-with-probe-and-profile-item.qbs | 19 +++++++++++++++++++ tests/auto/api/tst_api.cpp | 6 ++++++ tests/auto/api/tst_api.h | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/auto/api/testdata/project-with-probe-and-profile-item/project-with-probe-and-profile-item.qbs diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 67d60e05d..9c8f9da1d 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -688,6 +688,9 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, m_qbsVersion.toString())); } + resolveProbes(&dummyProductContext, projectItem); + projectContext.topLevelProject->probes << dummyProductContext.info.probes; + handleProfileItems(projectItem, &projectContext); QList multiplexedProducts; @@ -699,9 +702,6 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, for (Item * const additionalProductItem : qAsConst(multiplexedProducts)) Item::addChild(projectItem, additionalProductItem); - resolveProbes(&dummyProductContext, projectItem); - projectContext.topLevelProject->probes << dummyProductContext.info.probes; - const QList originalChildren = projectItem->children(); for (Item * const child : originalChildren) { switch (child->type()) { diff --git a/tests/auto/api/testdata/project-with-probe-and-profile-item/project-with-probe-and-profile-item.qbs b/tests/auto/api/testdata/project-with-probe-and-profile-item/project-with-probe-and-profile-item.qbs new file mode 100644 index 000000000..d7dc02cc2 --- /dev/null +++ b/tests/auto/api/testdata/project-with-probe-and-profile-item/project-with-probe-and-profile-item.qbs @@ -0,0 +1,19 @@ +Project { + + property bool probesEvaluated: probe.found + + Probe { + id: probe + configure: { + found = true; + } + } + + Profile { + name: "the-profile" + cpp.includePaths: { + if (!probesEvaluated) + throw "project-level probes not evaluated"; + } + } +} diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index 05cfc728f..235f2ac04 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -2374,6 +2374,12 @@ void TestApi::projectWithPropertiesItem() VERIFY_NO_ERROR(errorInfo); } +void TestApi::projectWithProbeAndProfileItem() +{ + const qbs::ErrorInfo errorInfo = doBuildProject("project-with-probe-and-profile-item"); + VERIFY_NO_ERROR(errorInfo); +} + void TestApi::propertiesBlocks() { const qbs::ErrorInfo errorInfo = doBuildProject("properties-blocks"); diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h index ce1678133..aa00ddc99 100644 --- a/tests/auto/api/tst_api.h +++ b/tests/auto/api/tst_api.h @@ -122,6 +122,7 @@ private slots: void projectLocking(); void projectPropertiesByName(); void projectWithPropertiesItem(); + void projectWithProbeAndProfileItem(); void propertiesBlocks(); void rc(); void referencedFileErrors(); -- cgit v1.2.3