get_compile_targets.py 1.9 KB

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