Bug 1386876 - Propagate updates to mozbuild variables that are dictionaries across template invocations.
MozReview-Commit-ID: 9JNEThJvva6
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -381,16 +381,23 @@ class MozbuildSandbox(Sandbox):
# of the sandbox from when the template was declared, not when
# it was instantiated. Bug 1137319.
'functions': self.metadata.get('functions', {}),
'special_variables': self.metadata.get('special_variables', {}),
'subcontexts': self.metadata.get('subcontexts', {}),
'templates': self.metadata.get('templates', {})
}, finder=self._finder)
+ # If a template wants to update a variable that's a dictionary we
+ # need to pass our initial value down to ensure multiple templates
+ # see our updates.
+ for var, val in self._context.items():
+ if var.isupper() and isinstance(val, dict):
+ context[var] = val
+
template.exec_in_sandbox(sandbox, *args, **kwargs)
# This is gross, but allows the merge to happen. Eventually, the
# merging will go away and template contexts emitted independently.
klass = self._context.__class__
self._context.__class__ = TemplateContext
# The sandbox will do all the necessary checks for these merges.
for key, value in context.items():