2 # Copyright 2012 The Swarming Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 that
4 # can be found in the LICENSE file.
6 """Merges multiple OS-specific gyp dependency lists into one that works on all
9 The logic is relatively simple. Takes the current conditions, add more
10 condition, find the strict subset. Done.
19 from utils import tools
22 def load_isolates(items):
23 """Parses each .isolate file and returns the merged results.
25 It only loads what load_isolate_as_config() can process.
28 files: dict(filename, set(OS where this filename is a dependency))
29 dirs: dict(dirame, set(OS where this dirname is a dependency))
30 oses: set(all the OSes referenced)
32 # pylint: disable=W0212
33 configs = isolate_format.Configs(None, ())
35 item = os.path.abspath(item)
36 logging.debug('loading %s' % item)
38 content = sys.stdin.read()
40 with open(item, 'r') as f:
42 new_config = isolate_format.load_isolate_as_config(
43 os.path.dirname(item),
44 isolate_format.eval_content(content),
45 isolate_format.extract_comment(content))
46 logging.debug('has configs: ' + ','.join(map(repr, new_config._by_config)))
47 configs = configs.union(new_config)
48 logging.debug('Total configs: ' + ','.join(map(repr, configs._by_config)))
53 tools.disable_buffering()
54 parser = tools.OptionParserWithLogging(
55 usage='%prog <options> [file1] [file2] ...')
57 '-o', '--output', help='Output to file instead of stdout')
59 options, args = parser.parse_args(args)
61 configs = load_isolates(args)
62 data = configs.make_isolate_file()
64 with open(options.output, 'wb') as f:
65 isolate_format.print_all(configs.file_comment, data, f)
67 isolate_format.print_all(configs.file_comment, data, sys.stdout)
71 if __name__ == '__main__':