3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
6 from __future__
import unicode_literals
7 'Miscellaneous utility functions.' 16 from contextlib
import contextmanager
20 return itertools.chain.from_iterable(
27 'The stdout of most fbcode_builder utilities is meant to be parsed.' 28 logging.debug(
'Running: {0} with {1}'.
format(cmd, kwargs))
29 kwargs[
'stdout'] = sys.stderr
30 subprocess.check_call(cmd, **kwargs)
39 shutil.rmtree(d, ignore_errors=
True)
44 Helper to read a named config file. 45 The grossness with the global is a workaround for this python bug: 46 https://bugs.python.org/issue21591 47 The bug prevents us from defining either a local function or a lambda 48 in the scope of read_fbcode_builder_config below. 51 full_path = os.path.join(_project_dir, path)
61 _project_dir = os.path.dirname(filename)
63 scope = {
'read_fbcode_builder_config': _inner_read_config}
64 with open(filename)
as config_file:
65 code = compile(config_file.read(), filename, mode=
'exec')
67 return scope[
'config']
72 Sets `builder` configuration, and returns all the builder steps 73 necessary to build `spec` and its dependencies. 75 Traverses the dependencies in depth-first order, honoring the sequencing 76 in each 'depends_on' list. 78 if processed_modules
is None:
79 processed_modules =
set()
81 for module
in spec.get(
'depends_on', []):
82 if module
not in processed_modules:
83 processed_modules.add(module)
86 module.fbcode_builder_spec(builder),
89 steps.extend(spec.get(
'steps', []))
94 return lambda builder: builder.build(
def recursively_flatten_list(l)
def _inner_read_config(path)
def steps_for_spec(builder, spec, processed_modules=None)
def run_command(cmd, kwargs)
def build_fbcode_builder_config(config)
def read_fbcode_builder_config(filename)
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)