2022-04-19 09:00:36 +02:00
|
|
|
#!/usr/bin/env python3
|
2016-04-07 14:06:55 -07:00
|
|
|
# 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
|
2018-07-25 19:30:07 +02:00
|
|
|
import os.path
|
2017-06-06 10:28:14 +02:00
|
|
|
import signal
|
2016-04-07 14:06:55 -07:00
|
|
|
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')
|
2022-09-21 13:28:42 +02:00
|
|
|
GCMOLE_PY = os.path.join(GCMOLE_PATH, 'gcmole.py')
|
|
|
|
V8_ROOT_DIR = os.path.dirname(os.path.dirname(GCMOLE_PATH))
|
2016-04-07 14:06:55 -07:00
|
|
|
|
2022-09-21 13:28:42 +02:00
|
|
|
|
|
|
|
def print_help():
|
|
|
|
print(
|
2023-03-30 12:11:08 +02:00
|
|
|
"""Usage: ./run-gcmole.py [MODE] V8_TARGET_CPU [gcmole.py OPTION]...
|
2022-09-21 13:28:42 +02:00
|
|
|
|
|
|
|
Helper script to run gcmole.py on the bots.""")
|
|
|
|
|
2023-03-30 12:11:08 +02:00
|
|
|
args = sys.argv[1:]
|
|
|
|
if "--help" in args:
|
|
|
|
print_help()
|
|
|
|
exit(0)
|
|
|
|
|
2022-09-21 13:28:42 +02:00
|
|
|
|
2023-03-30 12:11:08 +02:00
|
|
|
# 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:]
|
2022-09-21 13:28:42 +02:00
|
|
|
|
2023-03-30 12:11:08 +02:00
|
|
|
|
|
|
|
if not args:
|
2022-09-21 13:28:42 +02:00
|
|
|
print("Missing arguments!")
|
|
|
|
print_help()
|
|
|
|
exit(1)
|
2016-04-07 14:06:55 -07:00
|
|
|
|
2023-03-30 12:11:08 +02:00
|
|
|
|
2020-11-13 12:51:53 +01:00
|
|
|
if not os.path.isfile("out/build/gen/torque-generated/builtin-definitions.h"):
|
2020-10-15 20:17:08 +02:00
|
|
|
print("Expected generated headers in out/build/gen.")
|
2021-02-24 14:47:06 +01:00
|
|
|
print("Either build v8 in out/build or change the 'out/build/gen' location in gcmole.py")
|
2018-07-25 19:30:07 +02:00
|
|
|
sys.exit(-1)
|
|
|
|
|
2023-03-30 12:11:08 +02:00
|
|
|
gcmole_py_options = args[1:]
|
2017-06-06 10:28:14 +02:00
|
|
|
proc = subprocess.Popen(
|
2022-09-21 13:28:42 +02:00
|
|
|
[
|
|
|
|
sys.executable,
|
|
|
|
GCMOLE_PY,
|
2023-03-30 12:11:08 +02:00
|
|
|
mode,
|
2022-09-21 13:28:42 +02:00
|
|
|
"--v8-build-dir=%s" % os.path.join(V8_ROOT_DIR, 'out', 'build'),
|
2023-03-30 12:11:08 +02:00
|
|
|
"--v8-target-cpu=%s" % args[0],
|
2022-09-21 13:28:42 +02:00
|
|
|
"--clang-plugins-dir=%s" % CLANG_PLUGINS,
|
|
|
|
"--clang-bin-dir=%s" % CLANG_BIN,
|
|
|
|
"--is-bot",
|
|
|
|
] + gcmole_py_options,
|
|
|
|
cwd=V8_ROOT_DIR,
|
2017-06-06 10:28:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def handle_sigterm(*args):
|
|
|
|
try:
|
|
|
|
proc.kill()
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
signal.signal(signal.SIGTERM, handle_sigterm)
|
|
|
|
|
|
|
|
proc.communicate()
|
|
|
|
sys.exit(proc.returncode)
|