Bug 1386876 - Propagate updates to mozbuild variables that are dictionaries across template invocations. draft
authorChris Manchester <cmanchester@mozilla.com>
Thu, 17 Aug 2017 15:16:01 -0700
changeset 648532 8f216bef14a6b82ca4888717431d5caded642a6f
parent 643173 4c5fbf49376351679dcc49f4cff26c3c2e055ccc
child 648533 95dc956abafa2856f8834e0859e4b8c2343be8ae
push id74784
push userbmo:cmanchester@mozilla.com
push dateThu, 17 Aug 2017 22:39:21 +0000
bugs1386876
milestone57.0a1
Bug 1386876 - Propagate updates to mozbuild variables that are dictionaries across template invocations. MozReview-Commit-ID: 9JNEThJvva6
python/mozbuild/mozbuild/frontend/reader.py
--- 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():