mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1063437 - Use SourcePath smart type for sandbox includes. r=gps
This commit is contained in:
parent
7f48daf1bf
commit
6ba5b139b2
@ -339,6 +339,16 @@ class SourcePath(ContextDerivedValue, UserString):
|
||||
ret = mozpath.join(self.context.objdir, self.value)
|
||||
return mozpath.normpath(ret)
|
||||
|
||||
def join(self, *p):
|
||||
"""Lazy mozpath.join(self, *p), returning a new SourcePath instance.
|
||||
|
||||
In an ideal world, this wouldn't be required, but with the
|
||||
external_source_dir business, and the fact that comm-central and
|
||||
mozilla-central have directories in common, resolving a SourcePath
|
||||
before doing mozpath.join doesn't work out properly.
|
||||
"""
|
||||
return SourcePath(self.context, mozpath.join(self.value, *p))
|
||||
|
||||
|
||||
@memoize
|
||||
def ContextDerivedTypedList(type, base_class=List):
|
||||
@ -1157,7 +1167,7 @@ for name in TEMPLATE_VARIABLES:
|
||||
# The first element is an attribute on Sandbox that should be a function type.
|
||||
#
|
||||
FUNCTIONS = {
|
||||
'include': (lambda self: self._include, (str,),
|
||||
'include': (lambda self: self._include, (SourcePath,),
|
||||
"""Include another mozbuild file in the context of this one.
|
||||
|
||||
This is similar to a ``#include`` in C languages. The filename passed to
|
||||
|
@ -278,8 +278,8 @@ class MozbuildSandbox(Sandbox):
|
||||
def _include(self, path):
|
||||
"""Include and exec another file within the context of this one."""
|
||||
|
||||
# exec_file() handles normalization and verification of the path.
|
||||
self.exec_file(path)
|
||||
# path is a SourcePath, and needs to be coerced to unicode.
|
||||
self.exec_file(unicode(path), filesystem_absolute=True)
|
||||
|
||||
def _warning(self, message):
|
||||
# FUTURE consider capturing warnings in a variable instead of printing.
|
||||
@ -978,7 +978,7 @@ class BuildReader(object):
|
||||
recurse_info[d]['exports'] = dict(sandbox.metadata['exports'])
|
||||
|
||||
for path, child_metadata in recurse_info.items():
|
||||
child_path = mozpath.join(path, 'moz.build')
|
||||
child_path = path.join('moz.build')
|
||||
|
||||
# Ensure we don't break out of the topsrcdir. We don't do realpath
|
||||
# because it isn't necessary. If there are symlinks in the srcdir,
|
||||
|
@ -233,7 +233,8 @@ class TestMozbuildSandbox(unittest.TestCase):
|
||||
with self.assertRaises(SandboxLoadError) as se:
|
||||
sandbox.exec_file('relative.build')
|
||||
|
||||
self.assertEqual(se.exception.illegal_path, '../moz.build')
|
||||
self.assertEqual(se.exception.illegal_path,
|
||||
sandbox.normalize_path('../moz.build'))
|
||||
|
||||
def test_include_error_stack(self):
|
||||
# Ensure the path stack is reported properly in exceptions.
|
||||
|
Loading…
Reference in New Issue
Block a user