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