зеркало из https://github.com/mozilla/gecko-dev.git
Bug 991983 - Don't pass template paths to contexts. r=gps
When doing a template call, what's relevant for relative paths is the source path of the caller moz.build, not where the template is defined.
This commit is contained in:
Родитель
65120e7e62
Коммит
fc325a2d7e
|
@ -431,7 +431,7 @@ class MozbuildSandbox(Sandbox):
|
|||
for k, v in inspect.getcallargs(func, *args, **kwargs).items():
|
||||
sandbox[k] = v
|
||||
|
||||
sandbox.exec_source(code, path)
|
||||
sandbox.exec_source(code, path, becomes_current_path=False)
|
||||
|
||||
# This is gross, but allows the merge to happen. Eventually, the
|
||||
# merging will go away and template contexts emitted independently.
|
||||
|
|
|
@ -151,7 +151,7 @@ class Sandbox(dict):
|
|||
|
||||
self.exec_source(source, path)
|
||||
|
||||
def exec_source(self, source, path=''):
|
||||
def exec_source(self, source, path='', becomes_current_path=True):
|
||||
"""Execute Python code within a string.
|
||||
|
||||
The passed string should contain Python code to be executed. The string
|
||||
|
@ -161,7 +161,7 @@ class Sandbox(dict):
|
|||
does not perform extra path normalization. This can cause relative
|
||||
paths to behave weirdly.
|
||||
"""
|
||||
if path:
|
||||
if path and becomes_current_path:
|
||||
self._context.push_source(path)
|
||||
|
||||
old_sandbox = self._context._sandbox
|
||||
|
@ -193,16 +193,24 @@ class Sandbox(dict):
|
|||
|
||||
if self._last_name_error is not None:
|
||||
actual = self._last_name_error
|
||||
|
||||
raise SandboxExecutionError(self._context.source_stack,
|
||||
type(actual), actual, sys.exc_info()[2])
|
||||
source_stack = self._context.source_stack
|
||||
if not becomes_current_path:
|
||||
# Add current file to the stack because it wasn't added before
|
||||
# sandbox execution.
|
||||
source_stack.append(path)
|
||||
raise SandboxExecutionError(source_stack, type(actual), actual,
|
||||
sys.exc_info()[2])
|
||||
|
||||
except Exception as e:
|
||||
# Need to copy the stack otherwise we get a reference and that is
|
||||
# mutated during the finally.
|
||||
exc = sys.exc_info()
|
||||
raise SandboxExecutionError(self._context.source_stack, exc[0],
|
||||
exc[1], exc[2])
|
||||
source_stack = self._context.source_stack
|
||||
if not becomes_current_path:
|
||||
# Add current file to the stack because it wasn't added before
|
||||
# sandbox execution.
|
||||
source_stack.append(path)
|
||||
raise SandboxExecutionError(source_stack, exc[0], exc[1], exc[2])
|
||||
finally:
|
||||
self._context._sandbox = old_sandbox
|
||||
if path:
|
||||
|
|
|
@ -382,7 +382,7 @@ SOURCES += ['hoge.cpp']
|
|||
|
||||
self.assertEqual(sandbox2._context, {
|
||||
'SOURCES': ['qux.cpp', 'bar.cpp', 'foo.cpp', 'hoge.cpp'],
|
||||
'DIRS': [sandbox.normalize_path('foo')],
|
||||
'DIRS': [sandbox2.normalize_path('foo')],
|
||||
})
|
||||
|
||||
sandbox2 = self.sandbox(metadata={'templates': sandbox.templates})
|
||||
|
|
Загрузка…
Ссылка в новой задаче