Maintain a reference to the main mozbuild path within templates. draft
authorChris Manchester <cmanchester@mozilla.com>
Thu, 17 Aug 2017 15:16:53 -0700
changeset 648538 81b929c65f4781595bb025d08968631c0c42d6f9
parent 648537 6e34771bd709975ba69500cd09e13699dfe75f55
child 648539 d5747aba778d41e6f327bdee9d4e635f2f055e8b
push id74784
push userbmo:cmanchester@mozilla.com
push dateThu, 17 Aug 2017 22:39:21 +0000
milestone57.0a1
Maintain a reference to the main mozbuild path within templates. Currently, when a template is invoked in an included mozbuild file that template's context sees the including file as its 'main_path'. This patch changes the set up of a template's context to reflect the main moz.build file as its 'main_path'. MozReview-Commit-ID: 2as9B9BqXOr
python/mozbuild/mozbuild/frontend/reader.py
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -366,19 +366,19 @@ class MozbuildSandbox(Sandbox):
         After the template is executed, the data from its execution is merged
         with the context of the calling sandbox.
         """
         def template_wrapper(*args, **kwargs):
             context = TemplateContext(
                 template=template.name,
                 allowed_variables=self._context._allowed_variables,
                 config=self._context.config)
-            context.add_source(self._context.current_path)
-            for p in self._context.all_paths:
-                context.add_source(p)
+
+            for p in self._context.source_stack:
+                context.push_source(p)
 
             sandbox = MozbuildSandbox(context, metadata={
                 # We should arguably set these defaults to something else.
                 # Templates, for example, should arguably come from the state
                 # 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', {}),