Bug 1162851 - Keep the template name in TemplateContext instances. r=gps

This commit is contained in:
Mike Hommey 2015-02-23 15:55:32 +09:00
parent 4f30f70ed8
commit 6280543bb0
3 changed files with 10 additions and 4 deletions

View File

@ -268,6 +268,10 @@ class Context(KeyedDefaultDict):
class TemplateContext(Context):
def __init__(self, template=None, allowed_variables={}, config=None):
self.template = template
super(TemplateContext, self).__init__(allowed_variables, config)
def _validate(self, key, value):
return Context._validate(self, key, value, True)

View File

@ -61,8 +61,8 @@ class GypContext(TemplateContext):
"""
def __init__(self, config, relobjdir):
self._relobjdir = relobjdir
TemplateContext.__init__(self, allowed_variables=self.VARIABLES(),
config=config)
TemplateContext.__init__(self, template='Gyp',
allowed_variables=self.VARIABLES(), config=config)
@classmethod
@memoize

View File

@ -410,8 +410,10 @@ class MozbuildSandbox(Sandbox):
func, code, path = template
def template_function(*args, **kwargs):
context = TemplateContext(self._context._allowed_variables,
self._context.config)
context = TemplateContext(
template=func.func_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)