Maintain a reference to the main mozbuild path within templates. draft
authorChris Manchester <cmanchester@mozilla.com>
Thu, 17 Aug 2017 16:04:23 -0700
changeset 648549 386477ae2a999f8cccec6040ae5bfb168b427f45
parent 648548 2e53db8610535414f1a9f30e5231a8de817e351c
child 648550 971dcf364cf988563f036b47bf79330a2acb93d9
push id74790
push userbmo:cmanchester@mozilla.com
push dateThu, 17 Aug 2017 23:05:10 +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', {}),