summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-12-22 10:18:52 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-12-23 07:17:33 +0000
commitffca2303fee02c52415aa01cf8ea658c06649ebc (patch)
tree88c0c87444e3f4bdf6a5374eb6504019fcb0a7ba
parent7862e87dc3ed3f7e2e6c8de936d6e15e914a02a4 (diff)
downloadqbs-ffca2303fee02c52415aa01cf8ea658c06649ebc.tar.gz
Fix scopes of dependency parameters
Only the values in Depends items of products had a scope, and that one did not allow to access module instances. Now the scope always is the surrounding item, which should be a sensible one in all contexts. Task-number: QBS-1253 Change-Id: Iedca2d98f82f71887373579f8e4dc91f057eded3 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r--changelogs/changes-1.10.1.md1
-rw-r--r--src/lib/corelib/language/moduleloader.cpp25
-rw-r--r--src/lib/corelib/language/moduleloader.h1
-rw-r--r--tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs14
4 files changed, 17 insertions, 24 deletions
diff --git a/changelogs/changes-1.10.1.md b/changelogs/changes-1.10.1.md
index 21862d533..213251f49 100644
--- a/changelogs/changes-1.10.1.md
+++ b/changelogs/changes-1.10.1.md
@@ -3,5 +3,6 @@
* Fix qtquickcompiler support for qml files in subdirectories (QBS-1261).
* Fix GCC support for "bare metal" systems (QBS-1263, QBS-1265).
* Fix using ids in Depends items (QBS-1264).
+* Fix access to module instances in dependency parameters (QBS-1253).
* Fix race condition when creating Inno Setup, NSIS, or WiX installers.
* Fix release builds for Android with NDK r12 and above (QBS-1256).
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index be3343e3e..4341a9787 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -1530,17 +1530,18 @@ static void mergeParameters(QVariantMap &dst, const QVariantMap &src)
}
}
-static void adjustParametersItemTypes(Item *item)
+static void adjustParametersItemTypesAndScopes(Item *item, Item *scope)
{
if (item->type() == ItemType::ModuleInstance) {
item->setType(ItemType::ModuleParameters);
+ item->setScope(scope);
return;
}
for (auto value : item->properties()) {
if (value->type() != Value::ItemValueType)
continue;
- adjustParametersItemTypes(std::static_pointer_cast<ItemValue>(value)->item());
+ adjustParametersItemTypesAndScopes(std::static_pointer_cast<ItemValue>(value)->item(), scope);
}
}
@@ -1582,7 +1583,7 @@ void ModuleLoader::mergeExportItems(const ProductContext &productContext)
filesWithExportItem += exportItem->file();
for (Item * const child : exportItem->children()) {
if (child->type() == ItemType::Parameters) {
- adjustParametersItemTypes(child);
+ adjustParametersItemTypesAndScopes(child, child);
mergeParameters(pmi.defaultParameters,
m_evaluator->scriptValue(child).toVariant().toMap());
} else {
@@ -1985,7 +1986,7 @@ void ModuleLoader::resolveDependencies(DependsContext *dependsContext, Item *ite
for (Item * const dependsItem : dependsItemPerLoadedModule) {
if (dependsItem == lastDependsItem)
continue;
- adjustParametersItemTypes(dependsItem);
+ adjustParametersItemTypesAndScopes(dependsItem, dependsItem);
forwardParameterDeclarations(dependsItem, loadedModules);
lastDependsItem = dependsItem;
}
@@ -3031,26 +3032,10 @@ void ModuleLoader::setScopeForDescendants(Item *item, Item *scope)
{
for (Item * const child : item->children()) {
child->setScope(scope);
- if (child->type() == ItemType::Depends)
- forwardScopeToItemValues(child, scope);
setScopeForDescendants(child, scope);
}
}
-void ModuleLoader::forwardScopeToItemValues(Item *item, Item *scope)
-{
- const auto &itemProperties = item->properties();
- for (const ValuePtr &v : itemProperties) {
- if (v->type() != Value::ItemValueType)
- continue;
- Item *k = std::static_pointer_cast<ItemValue>(v)->item();
- if (k->type() == ItemType::ModulePrefix)
- forwardScopeToItemValues(k, scope);
- else
- k->setScope(scope);
- }
-}
-
void ModuleLoader::overrideItemProperties(Item *item, const QString &buildConfigKey,
const QVariantMap &buildConfig)
{
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index aa4fe917f..333c2f7dd 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -303,7 +303,6 @@ private:
static QString findExistingModulePath(const QString &searchPath,
const QualifiedId &moduleName);
static void setScopeForDescendants(Item *item, Item *scope);
- static void forwardScopeToItemValues(Item *item, Item *scope);
void overrideItemProperties(Item *item, const QString &buildConfigKey,
const QVariantMap &buildConfig);
void addProductModuleDependencies(ProductContext *ctx, const Item::Module &module);
diff --git a/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs b/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs
index 97d602ced..a12aceccd 100644
--- a/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs
+++ b/tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs
@@ -4,9 +4,16 @@ Project {
CppApplication {
name: "myapp"
files: ["main.cpp"]
- Depends { name: "plugin1"; cpp.link: false } // not to be linked
+ Depends {
+ name: "plugin1" // not to be linked
+ cpp.link: qbs.hostOS === undefined
+ }
Depends { name: "plugin2" } // not to be linked
- Depends { name: "plugin3"; cpp.link: true } // supposed to be linked
+ Depends {
+ name: "plugin3" // supposed to be linked
+ //property bool theCondition: true
+ cpp.link: /*theCondition && */product.name === "myapp" // TODO: Make this work
+ }
Depends { name: "plugin4" } // supposed to be linked
Depends { name: "helper" } // supposed to be linked
}
@@ -41,7 +48,8 @@ Project {
Depends { name: "cpp" }
Export {
Parameters {
- cpp.link: true
+ // property bool theCondition: true
+ cpp.link: true // theCondition TODO: Make this work
}
}
}