checkbins.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python3
  2. # Copyright 2015 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. """Launches //tools/checkbins/checkbins.py for trybots.
  6. To run locally on `out/release`, create /tmp/config.json
  7. {
  8. "checkout": "."
  9. }
  10. python3 testing/scripts/checkbins.py \
  11. --paths /tmp/config.json \
  12. --build-config-fs release run \
  13. --output -
  14. """
  15. import json
  16. import os
  17. import sys
  18. # Add src/testing/ into sys.path for importing common without pylint errors.
  19. sys.path.append(
  20. os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
  21. from scripts import common
  22. WIN_PY3_TARGETS = ['python3.exe', 'python3.bat']
  23. def with_python3():
  24. if sys.version_info.major >= 3:
  25. return sys.executable
  26. # `env` should have worked on other platforms.
  27. if sys.platform == 'win32':
  28. # non-exhaustive, we expect depot_tools somewhere.
  29. for d in os.environ['PATH'].split(';'):
  30. for maybe_py3 in WIN_PY3_TARGETS:
  31. if os.path.exists(os.path.join(d, maybe_py3)):
  32. return os.path.join(d, maybe_py3)
  33. raise Exception("Cannot find python3 to launch checkbins.py")
  34. def main_run(args):
  35. print(sys.executable)
  36. with common.temporary_file() as tempfile_path:
  37. rc = common.run_command([
  38. with_python3(),
  39. os.path.join(common.SRC_DIR, 'tools', 'checkbins', 'checkbins.py'),
  40. '--verbose',
  41. '--json', tempfile_path,
  42. os.path.join(args.paths['checkout'], 'out', args.build_config_fs),
  43. ])
  44. with open(tempfile_path) as f:
  45. checkbins_results = json.load(f)
  46. common.record_local_script_results(
  47. 'checkbins', args.output, checkbins_results, True)
  48. return rc
  49. def main_compile_targets(args):
  50. json.dump([], args.output)
  51. if __name__ == '__main__':
  52. funcs = {
  53. 'run': main_run,
  54. 'compile_targets': main_compile_targets,
  55. }
  56. sys.exit(common.run_script(sys.argv[1:], funcs))