• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2014 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import json
8import os
9import sys
10
11import common
12
13
14def main(argv):
15  parser = argparse.ArgumentParser()
16  parser.add_argument('--output', required=True)
17  parser.add_argument('args', nargs=argparse.REMAINDER)
18
19  args = parser.parse_args(argv)
20
21  passthrough_args = args.args
22  if passthrough_args[0] == '--':
23    passthrough_args = passthrough_args[1:]
24
25  results = {}
26
27  for filename in os.listdir(common.SCRIPT_DIR):
28    if not filename.endswith('.py'):
29      continue
30    if filename in ('common.py', 'get_compile_targets.py',
31                    'gpu_integration_test_adapter.py', 'PRESUBMIT.py',
32                    'sizes_common.py', 'variations_seed_access_helper.py',
33                    'run_variations_smoke_tests.py',
34                    'run_performance_tests_unittest.py'):
35      continue
36
37    with common.temporary_file() as tempfile_path:
38      rc = common.run_command(
39          [sys.executable,
40           os.path.join(common.SCRIPT_DIR, filename)] + passthrough_args +
41          ['compile_targets', '--output', tempfile_path])
42      if rc != 0:
43        return rc
44
45      with open(tempfile_path) as f:
46        # json.load() throws a ValueError for empty files
47        try:
48          results[filename] = json.load(f)
49        except ValueError:
50          pass
51
52  with open(args.output, 'w') as f:
53    json.dump(results, f)
54
55  return 0
56
57
58if __name__ == '__main__':
59  sys.exit(main(sys.argv[1:]))
60