aboutsummaryrefslogtreecommitdiffstats
path: root/src
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 /src
parent7862e87dc3ed3f7e2e6c8de936d6e15e914a02a4 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/lib/corelib/language/moduleloader.cpp25
-rw-r--r--src/lib/corelib/language/moduleloader.h1
2 files changed, 5 insertions, 21 deletions
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);