mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 949906 - Add a callback to modify evaluated moz.build sandboxes, fix Sphinx docs; r=glandium
--HG-- extra : rebase_source : 9ef2219145fb754a9cbe9e7e30b6f2841910f13f
This commit is contained in:
parent
3a6df5c9dc
commit
048490bb08
@ -592,13 +592,20 @@ class BuildReader(object):
|
||||
This is where the build system starts. You give it a tree configuration
|
||||
(the output of configuration) and it executes the moz.build files and
|
||||
collects the data they define.
|
||||
|
||||
The reader can optionally call a callable after each sandbox is evaluated
|
||||
but before its evaluated content is processed. This gives callers the
|
||||
opportunity to modify sandboxes before side-effects occur from their
|
||||
content. This callback receives the ``Sandbox`` that was evaluated. The
|
||||
return value is ignored.
|
||||
"""
|
||||
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, sandbox_post_eval_cb=None):
|
||||
self.config = config
|
||||
self.topsrcdir = config.topsrcdir
|
||||
self.topobjdir = config.topobjdir
|
||||
|
||||
self._sandbox_post_eval_cb = sandbox_post_eval_cb
|
||||
self._log = logging.getLogger(__name__)
|
||||
self._read_files = set()
|
||||
self._execution_stack = []
|
||||
@ -719,6 +726,10 @@ class BuildReader(object):
|
||||
sandbox = MozbuildSandbox(self.config, path, metadata=metadata)
|
||||
sandbox.exec_file(path, filesystem_absolute=filesystem_absolute)
|
||||
sandbox.execution_time = time.time() - time_start
|
||||
|
||||
if self._sandbox_post_eval_cb:
|
||||
self._sandbox_post_eval_cb(sandbox)
|
||||
|
||||
var = metadata.get('var', None)
|
||||
forbidden = {
|
||||
'TOOL_DIRS': ['DIRS', 'PARALLEL_DIRS', 'TEST_DIRS'],
|
||||
@ -770,6 +781,9 @@ class BuildReader(object):
|
||||
# so until the library linking operations are moved out of it, at which
|
||||
# point PARALLEL_DIRS will be irrelevant anyways.
|
||||
for gyp_sandbox in gyp_sandboxes:
|
||||
if self._sandbox_post_eval_cb:
|
||||
self._sandbox_post_eval_cb(gyp_sandbox)
|
||||
|
||||
sandbox['DIRS'].append(mozpath.relpath(gyp_sandbox['OBJDIR'], sandbox['OBJDIR']))
|
||||
|
||||
yield sandbox
|
||||
|
@ -33,13 +33,13 @@ class TestBuildReader(unittest.TestCase):
|
||||
|
||||
return MockConfig(path, **kwargs)
|
||||
|
||||
def reader(self, name, enable_tests=False):
|
||||
def reader(self, name, enable_tests=False, **kwargs):
|
||||
extra = {}
|
||||
if enable_tests:
|
||||
extra['ENABLE_TESTS'] = '1'
|
||||
config = self.config(name, extra_substs=extra)
|
||||
|
||||
return BuildReader(config)
|
||||
return BuildReader(config, **kwargs)
|
||||
|
||||
def file_path(self, name, *args):
|
||||
return mozpath.join(data_path, name, *args)
|
||||
@ -266,5 +266,21 @@ class TestBuildReader(unittest.TestCase):
|
||||
self.assertEqual([sandbox['XPIDL_MODULE'] for sandbox in sandboxes],
|
||||
['foobar', 'foobar', 'foobar', 'foobar'])
|
||||
|
||||
def test_process_eval_callback(self):
|
||||
def strip_dirs(sandbox):
|
||||
sandbox['DIRS'][:] = []
|
||||
count[0] += 1
|
||||
|
||||
reader = self.reader('traversal-simple',
|
||||
sandbox_post_eval_cb=strip_dirs)
|
||||
|
||||
count = [0]
|
||||
|
||||
sandboxes = list(reader.read_topsrcdir())
|
||||
|
||||
self.assertEqual(len(sandboxes), 1)
|
||||
self.assertEqual(len(count), 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -38,7 +38,14 @@ class Documentation(MachCommandBase):
|
||||
manager = SphinxManager(self.topsrcdir, os.path.join(self.topsrcdir,
|
||||
'tools', 'docs'), outdir)
|
||||
|
||||
reader = BuildReader(self.config_environment)
|
||||
# We don't care about GYP projects, so don't process them. This makes
|
||||
# scanning faster and may even prevent an exception.
|
||||
def remove_gyp_dirs(sandbox):
|
||||
sandbox['GYP_DIRS'][:] = []
|
||||
|
||||
reader = BuildReader(self.config_environment,
|
||||
sandbox_post_eval_cb=remove_gyp_dirs)
|
||||
|
||||
for sandbox in reader.walk_topsrcdir():
|
||||
for dest_dir, source_dir in sandbox['SPHINX_TREES'].items():
|
||||
manager.add_tree(os.path.join(sandbox['RELATIVEDIR'],
|
||||
|
Loading…
Reference in New Issue
Block a user