File: run-gcmole.py

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (73 lines) | stat: -rwxr-xr-x 1,831 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import os.path
import signal
import subprocess
import sys

GCMOLE_PATH = os.path.dirname(os.path.abspath(__file__))
CLANG_BIN = os.path.join(GCMOLE_PATH, 'gcmole-tools', 'bin')
CLANG_PLUGINS = os.path.join(GCMOLE_PATH, 'gcmole-tools')
GCMOLE_PY = os.path.join(GCMOLE_PATH, 'gcmole.py')
V8_ROOT_DIR = os.path.dirname(os.path.dirname(GCMOLE_PATH))


def print_help():
  print(
      """Usage: ./run-gcmole.py [MODE] V8_TARGET_CPU [gcmole.py OPTION]...

Helper script to run gcmole.py on the bots.""")

args = sys.argv[1:]
if "--help" in args:
  print_help()
  exit(0)


# Different modes of running gcmole. Optional to stay backwards-compatible.
mode = 'full'
if args and args[0] in ['check', 'collect', 'full', 'merge']:
  mode = args[0]
  args = args[1:]


if not args:
  print("Missing arguments!")
  print_help()
  exit(1)


if not os.path.isfile("out/build/gen/torque-generated/builtin-definitions.h"):
  print("Expected generated headers in out/build/gen.")
  print("Either build v8 in out/build or change the 'out/build/gen' location in gcmole.py")
  sys.exit(-1)

gcmole_py_options = args[1:]
proc = subprocess.Popen(
    [
        sys.executable,
        GCMOLE_PY,
        mode,
        "--v8-build-dir=%s" % os.path.join(V8_ROOT_DIR, 'out', 'build'),
        "--v8-target-cpu=%s" % args[0],
        "--clang-plugins-dir=%s" % CLANG_PLUGINS,
        "--clang-bin-dir=%s" % CLANG_BIN,
        "--is-bot",
    ] + gcmole_py_options,
    cwd=V8_ROOT_DIR,
)

def handle_sigterm(*args):
  try:
    proc.kill()
  except OSError:
    pass

signal.signal(signal.SIGTERM, handle_sigterm)

proc.communicate()
sys.exit(proc.returncode)