v8/tools/gcmole/run-gcmole.py
Michael Achenbach 506fb93ebe [gcmole] Add subparsers
This will enable running the main gcmole script in different modes
in the future, full run (this CL), later suspect generation only and
analysis only.

Bug: v8:12660
Change-Id: Ica87366fb3c5b6e238f5a1efaf347ebbeb01003a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4026062
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84357}
2022-11-18 13:17:47 +00:00

66 lines
1.6 KiB
Python
Executable File

#!/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 TOOLS_GCMOLE_DIR V8_TARGET_CPU [gcmole.py OPTION]...
Helper script to run gcmole.py on the bots.""")
for arg in sys.argv:
if arg == "--help":
print_help()
exit(0)
if len(sys.argv) < 2:
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 = sys.argv[2:]
proc = subprocess.Popen(
[
sys.executable,
GCMOLE_PY,
"full",
"--v8-build-dir=%s" % os.path.join(V8_ROOT_DIR, 'out', 'build'),
"--v8-target-cpu=%s" % sys.argv[1],
"--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)