2020-03-11 14:27:42 +00:00
|
|
|
#!/usr/bin/env python2
|
2017-02-22 15:09:28 +00:00
|
|
|
# Copyright 2017 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.
|
|
|
|
"""\
|
|
|
|
Convenience wrapper for compiling V8 with gn/ninja and running tests.
|
|
|
|
Sets up build output directories if they don't exist.
|
|
|
|
Produces simulator builds for non-Intel target architectures.
|
|
|
|
Uses Goma by default if it is detected (at output directory setup time).
|
|
|
|
Expects to be run from the root of a V8 checkout.
|
|
|
|
|
|
|
|
Usage:
|
2020-06-18 16:39:52 +00:00
|
|
|
gm.py [<arch>].[<mode>[-<suffix>]].[<target>] [testname...] [--flag]
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
All arguments are optional. Most combinations should work, e.g.:
|
2018-11-07 19:13:15 +00:00
|
|
|
gm.py ia32.debug x64.release x64.release-my-custom-opts d8
|
2020-06-18 16:39:52 +00:00
|
|
|
gm.py android_arm.release.check --progress=verbose
|
2017-02-22 15:09:28 +00:00
|
|
|
gm.py x64 mjsunit/foo cctest/test-bar/*
|
2020-06-18 16:39:52 +00:00
|
|
|
|
|
|
|
Flags are passed unchanged to the test runner. They must start with -- and must
|
|
|
|
not contain spaces.
|
2017-02-22 15:09:28 +00:00
|
|
|
"""
|
|
|
|
# See HELP below for additional documentation.
|
2020-03-11 14:27:42 +00:00
|
|
|
# Note on Python3 compatibility: gm.py itself is Python3 compatible, but
|
|
|
|
# run-tests.py, which will be executed by the same binary, is not; hence
|
|
|
|
# the hashbang line at the top of this file explicitly requires Python2.
|
2017-02-22 15:09:28 +00:00
|
|
|
|
2017-06-01 09:20:31 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
import errno
|
2017-02-22 15:09:28 +00:00
|
|
|
import os
|
2017-09-02 01:20:40 +00:00
|
|
|
import re
|
2017-02-22 15:09:28 +00:00
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2018-12-18 16:21:34 +00:00
|
|
|
USE_PTY = "linux" in sys.platform
|
|
|
|
if USE_PTY:
|
|
|
|
import pty
|
|
|
|
|
2021-06-02 16:21:31 +00:00
|
|
|
BUILD_TARGETS_TEST = ["d8", "bigint_shell", "cctest", "inspector-test",
|
|
|
|
"unittests", "wasm_api_tests"]
|
2017-02-22 15:09:28 +00:00
|
|
|
BUILD_TARGETS_ALL = ["all"]
|
|
|
|
|
|
|
|
# All arches that this script understands.
|
|
|
|
ARCHES = ["ia32", "x64", "arm", "arm64", "mipsel", "mips64el", "ppc", "ppc64",
|
2021-02-09 16:11:55 +00:00
|
|
|
"riscv64", "s390", "s390x", "android_arm", "android_arm64"]
|
2017-02-22 15:09:28 +00:00
|
|
|
# Arches that get built/run when you don't specify any.
|
|
|
|
DEFAULT_ARCHES = ["ia32", "x64", "arm", "arm64"]
|
|
|
|
# Modes that this script understands.
|
|
|
|
MODES = ["release", "debug", "optdebug"]
|
|
|
|
# Modes that get built/run when you don't specify any.
|
|
|
|
DEFAULT_MODES = ["release", "debug"]
|
|
|
|
# Build targets that can be manually specified.
|
2019-05-28 09:15:48 +00:00
|
|
|
TARGETS = ["d8", "cctest", "unittests", "v8_fuzzers", "wasm_api_tests", "wee8",
|
2021-06-02 16:21:31 +00:00
|
|
|
"mkgrokdump", "generate-bytecode-expectations", "inspector-test",
|
|
|
|
"bigint_shell"]
|
2017-02-22 15:09:28 +00:00
|
|
|
# Build targets that get built when you don't specify any (and specified tests
|
|
|
|
# don't imply any other targets).
|
|
|
|
DEFAULT_TARGETS = ["d8"]
|
|
|
|
# Tests that run-tests.py would run by default that can be run with
|
|
|
|
# BUILD_TARGETS_TESTS.
|
|
|
|
DEFAULT_TESTS = ["cctest", "debugger", "intl", "message", "mjsunit",
|
2019-11-20 07:55:40 +00:00
|
|
|
"unittests"]
|
2017-02-22 15:09:28 +00:00
|
|
|
# These can be suffixed to any <arch>.<mode> combo, or used standalone,
|
|
|
|
# or used as global modifiers (affecting all <arch>.<mode> combos).
|
|
|
|
ACTIONS = {
|
2021-06-16 10:39:59 +00:00
|
|
|
"all": {
|
|
|
|
"targets": BUILD_TARGETS_ALL,
|
|
|
|
"tests": [],
|
|
|
|
"clean": False
|
|
|
|
},
|
|
|
|
"tests": {
|
|
|
|
"targets": BUILD_TARGETS_TEST,
|
|
|
|
"tests": [],
|
|
|
|
"clean": False
|
|
|
|
},
|
|
|
|
"check": {
|
|
|
|
"targets": BUILD_TARGETS_TEST,
|
|
|
|
"tests": DEFAULT_TESTS,
|
|
|
|
"clean": False
|
|
|
|
},
|
|
|
|
"checkall": {
|
|
|
|
"targets": BUILD_TARGETS_ALL,
|
|
|
|
"tests": ["ALL"],
|
|
|
|
"clean": False
|
|
|
|
},
|
|
|
|
"clean": {
|
|
|
|
"targets": [],
|
|
|
|
"tests": [],
|
|
|
|
"clean": True
|
|
|
|
},
|
2017-02-22 15:09:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HELP = """<arch> can be any of: %(arches)s
|
|
|
|
<mode> can be any of: %(modes)s
|
|
|
|
<target> can be any of:
|
2019-05-28 09:15:48 +00:00
|
|
|
- %(targets)s (build respective binary)
|
2017-02-22 15:09:28 +00:00
|
|
|
- all (build all binaries)
|
|
|
|
- tests (build test binaries)
|
|
|
|
- check (build test binaries, run most tests)
|
|
|
|
- checkall (build all binaries, run more tests)
|
|
|
|
""" % {"arches": " ".join(ARCHES),
|
2019-05-28 09:15:48 +00:00
|
|
|
"modes": " ".join(MODES),
|
|
|
|
"targets": ", ".join(TARGETS)}
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
TESTSUITES_TARGETS = {"benchmarks": "d8",
|
2021-06-02 16:21:31 +00:00
|
|
|
"bigint": "bigint_shell",
|
2017-02-22 15:09:28 +00:00
|
|
|
"cctest": "cctest",
|
|
|
|
"debugger": "d8",
|
|
|
|
"fuzzer": "v8_fuzzers",
|
2017-11-28 13:10:44 +00:00
|
|
|
"inspector": "inspector-test",
|
2017-02-22 15:09:28 +00:00
|
|
|
"intl": "d8",
|
|
|
|
"message": "d8",
|
|
|
|
"mjsunit": "d8",
|
|
|
|
"mozilla": "d8",
|
|
|
|
"test262": "d8",
|
|
|
|
"unittests": "unittests",
|
2019-05-28 09:15:48 +00:00
|
|
|
"wasm-api-tests": "wasm_api_tests",
|
2019-11-08 09:55:15 +00:00
|
|
|
"wasm-js": "d8",
|
|
|
|
"wasm-spec-tests": "d8",
|
2017-02-22 15:09:28 +00:00
|
|
|
"webkit": "d8"}
|
|
|
|
|
|
|
|
OUTDIR = "out"
|
|
|
|
|
2021-03-04 15:19:50 +00:00
|
|
|
def _Which(cmd):
|
|
|
|
for path in os.environ["PATH"].split(os.pathsep):
|
|
|
|
if os.path.exists(os.path.join(path, cmd)):
|
|
|
|
return os.path.join(path, cmd)
|
|
|
|
return None
|
|
|
|
|
2017-03-17 14:10:23 +00:00
|
|
|
def DetectGoma():
|
2017-06-07 09:08:37 +00:00
|
|
|
if os.environ.get("GOMA_DIR"):
|
|
|
|
return os.environ.get("GOMA_DIR")
|
2017-03-17 14:10:23 +00:00
|
|
|
if os.environ.get("GOMADIR"):
|
|
|
|
return os.environ.get("GOMADIR")
|
2021-03-04 15:19:50 +00:00
|
|
|
# There is a copy of goma in depot_tools, but it might not be in use on
|
|
|
|
# this machine.
|
|
|
|
goma = _Which("goma_ctl")
|
|
|
|
if goma is None: return None
|
|
|
|
cipd_bin = os.path.join(os.path.dirname(goma), ".cipd_bin")
|
|
|
|
if not os.path.exists(cipd_bin): return None
|
|
|
|
goma_auth = os.path.expanduser("~/.goma_client_oauth2_config")
|
|
|
|
if not os.path.exists(goma_auth): return None
|
|
|
|
return cipd_bin
|
2017-03-17 14:10:23 +00:00
|
|
|
|
|
|
|
GOMADIR = DetectGoma()
|
|
|
|
IS_GOMA_MACHINE = GOMADIR is not None
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
USE_GOMA = "true" if IS_GOMA_MACHINE else "false"
|
|
|
|
|
|
|
|
RELEASE_ARGS_TEMPLATE = """\
|
|
|
|
is_component_build = false
|
|
|
|
is_debug = false
|
|
|
|
%s
|
|
|
|
use_goma = {GOMA}
|
|
|
|
v8_enable_backtrace = true
|
|
|
|
v8_enable_disassembler = true
|
|
|
|
v8_enable_object_print = true
|
|
|
|
v8_enable_verify_heap = true
|
2021-07-23 13:01:40 +00:00
|
|
|
dcheck_always_on = false
|
2021-03-04 15:19:50 +00:00
|
|
|
""".replace("{GOMA}", USE_GOMA)
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
DEBUG_ARGS_TEMPLATE = """\
|
|
|
|
is_component_build = true
|
|
|
|
is_debug = true
|
|
|
|
symbol_level = 2
|
|
|
|
%s
|
|
|
|
use_goma = {GOMA}
|
|
|
|
v8_enable_backtrace = true
|
2018-06-29 07:37:54 +00:00
|
|
|
v8_enable_fast_mksnapshot = true
|
2017-02-22 15:09:28 +00:00
|
|
|
v8_enable_slow_dchecks = true
|
|
|
|
v8_optimized_debug = false
|
2021-03-04 15:19:50 +00:00
|
|
|
""".replace("{GOMA}", USE_GOMA)
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
OPTDEBUG_ARGS_TEMPLATE = """\
|
|
|
|
is_component_build = true
|
|
|
|
is_debug = true
|
|
|
|
symbol_level = 1
|
|
|
|
%s
|
|
|
|
use_goma = {GOMA}
|
|
|
|
v8_enable_backtrace = true
|
2018-06-29 07:37:54 +00:00
|
|
|
v8_enable_fast_mksnapshot = true
|
2017-02-22 15:09:28 +00:00
|
|
|
v8_enable_verify_heap = true
|
|
|
|
v8_optimized_debug = true
|
2021-03-04 15:19:50 +00:00
|
|
|
""".replace("{GOMA}", USE_GOMA)
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
ARGS_TEMPLATES = {
|
|
|
|
"release": RELEASE_ARGS_TEMPLATE,
|
|
|
|
"debug": DEBUG_ARGS_TEMPLATE,
|
|
|
|
"optdebug": OPTDEBUG_ARGS_TEMPLATE
|
|
|
|
}
|
|
|
|
|
|
|
|
def PrintHelpAndExit():
|
|
|
|
print(__doc__)
|
|
|
|
print(HELP)
|
|
|
|
sys.exit(0)
|
|
|
|
|
2021-03-24 16:21:28 +00:00
|
|
|
def PrintCompletionsAndExit():
|
|
|
|
for a in ARCHES:
|
|
|
|
print("%s" % a)
|
|
|
|
for m in MODES:
|
|
|
|
print("%s" % m)
|
|
|
|
print("%s.%s" % (a, m))
|
|
|
|
for t in TARGETS:
|
|
|
|
print("%s" % t)
|
|
|
|
print("%s.%s.%s" % (a, m, t))
|
|
|
|
sys.exit(0)
|
|
|
|
|
2017-02-22 15:09:28 +00:00
|
|
|
def _Call(cmd, silent=False):
|
|
|
|
if not silent: print("# %s" % cmd)
|
|
|
|
return subprocess.call(cmd, shell=True)
|
|
|
|
|
2017-06-30 14:08:27 +00:00
|
|
|
def _CallWithOutputNoTerminal(cmd):
|
|
|
|
return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
|
|
|
|
|
2017-06-01 09:20:31 +00:00
|
|
|
def _CallWithOutput(cmd):
|
|
|
|
print("# %s" % cmd)
|
|
|
|
# The following trickery is required so that the 'cmd' thinks it's running
|
|
|
|
# in a real terminal, while this script gets to intercept its output.
|
2020-06-22 09:17:56 +00:00
|
|
|
parent, child = pty.openpty()
|
|
|
|
p = subprocess.Popen(cmd, shell=True, stdin=child, stdout=child, stderr=child)
|
|
|
|
os.close(child)
|
2017-06-01 09:20:31 +00:00
|
|
|
output = []
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
try:
|
2020-06-22 09:17:56 +00:00
|
|
|
data = os.read(parent, 512).decode('utf-8')
|
2017-06-01 09:20:31 +00:00
|
|
|
except OSError as e:
|
|
|
|
if e.errno != errno.EIO: raise
|
|
|
|
break # EIO means EOF on some systems
|
|
|
|
else:
|
|
|
|
if not data: # EOF
|
|
|
|
break
|
|
|
|
print(data, end="")
|
|
|
|
sys.stdout.flush()
|
|
|
|
output.append(data)
|
|
|
|
finally:
|
2020-06-22 09:17:56 +00:00
|
|
|
os.close(parent)
|
2017-06-01 09:20:31 +00:00
|
|
|
p.wait()
|
|
|
|
return p.returncode, "".join(output)
|
|
|
|
|
2017-02-22 15:09:28 +00:00
|
|
|
def _Write(filename, content):
|
|
|
|
print("# echo > %s << EOF\n%sEOF" % (filename, content))
|
|
|
|
with open(filename, "w") as f:
|
|
|
|
f.write(content)
|
|
|
|
|
2017-04-21 12:15:38 +00:00
|
|
|
def _Notify(summary, body):
|
|
|
|
if _Which('notify-send') is not None:
|
|
|
|
_Call("notify-send '{}' '{}'".format(summary, body), silent=True)
|
|
|
|
else:
|
|
|
|
print("{} - {}".format(summary, body))
|
|
|
|
|
2021-03-11 21:30:37 +00:00
|
|
|
def _GetMachine():
|
|
|
|
# Once we migrate to Python3, this can use os.uname().machine.
|
|
|
|
# The index-based access is compatible with all Python versions.
|
|
|
|
return os.uname()[4]
|
|
|
|
|
2017-02-22 15:09:28 +00:00
|
|
|
def GetPath(arch, mode):
|
|
|
|
subdir = "%s.%s" % (arch, mode)
|
|
|
|
return os.path.join(OUTDIR, subdir)
|
|
|
|
|
2019-01-11 10:24:36 +00:00
|
|
|
def PrepareMksnapshotCmdline(orig_cmdline, path):
|
|
|
|
result = "gdb --args %s/mksnapshot " % path
|
|
|
|
for w in orig_cmdline.split(" "):
|
|
|
|
if w.startswith("gen/") or w.startswith("snapshot_blob"):
|
|
|
|
result += ("%(path)s%(sep)s%(arg)s " %
|
|
|
|
{"path": path, "sep": os.sep, "arg": w})
|
|
|
|
else:
|
|
|
|
result += "%s " % w
|
|
|
|
return result
|
|
|
|
|
2017-02-22 15:09:28 +00:00
|
|
|
class Config(object):
|
2021-06-16 10:39:59 +00:00
|
|
|
def __init__(self,
|
|
|
|
arch,
|
|
|
|
mode,
|
|
|
|
targets,
|
|
|
|
tests=[],
|
|
|
|
clean=False,
|
|
|
|
testrunner_args=[]):
|
2017-02-22 15:09:28 +00:00
|
|
|
self.arch = arch
|
|
|
|
self.mode = mode
|
|
|
|
self.targets = set(targets)
|
|
|
|
self.tests = set(tests)
|
2020-06-18 16:39:52 +00:00
|
|
|
self.testrunner_args = testrunner_args
|
2021-06-16 10:39:59 +00:00
|
|
|
self.clean = clean
|
2017-02-22 15:09:28 +00:00
|
|
|
|
2021-06-16 10:39:59 +00:00
|
|
|
def Extend(self, targets, tests=[], clean=False):
|
2017-02-22 15:09:28 +00:00
|
|
|
self.targets.update(targets)
|
|
|
|
self.tests.update(tests)
|
2021-06-16 10:39:59 +00:00
|
|
|
self.clean |= clean
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
def GetTargetCpu(self):
|
|
|
|
cpu = "x86"
|
2021-03-10 15:30:04 +00:00
|
|
|
if self.arch == "android_arm":
|
|
|
|
cpu = "arm"
|
|
|
|
elif self.arch == "android_arm64":
|
|
|
|
cpu = "arm64"
|
2021-04-16 17:05:27 +00:00
|
|
|
elif self.arch == "arm64" and _GetMachine() in ("aarch64", "arm64"):
|
2021-03-10 15:30:04 +00:00
|
|
|
# arm64 build host:
|
|
|
|
cpu = "arm64"
|
2021-04-16 17:05:27 +00:00
|
|
|
elif self.arch == "arm" and _GetMachine() in ("aarch64", "arm64"):
|
2021-03-10 15:30:04 +00:00
|
|
|
cpu = "arm"
|
|
|
|
elif "64" in self.arch or self.arch == "s390x":
|
|
|
|
# Native x64 or simulator build.
|
2017-02-22 15:09:28 +00:00
|
|
|
cpu = "x64"
|
2021-03-10 15:30:04 +00:00
|
|
|
return ["target_cpu = \"%s\"" % cpu]
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
def GetV8TargetCpu(self):
|
2021-03-10 15:30:04 +00:00
|
|
|
if self.arch == "android_arm":
|
|
|
|
v8_cpu = "arm"
|
|
|
|
elif self.arch == "android_arm64":
|
|
|
|
v8_cpu = "arm64"
|
|
|
|
elif self.arch in ("arm", "arm64", "mipsel", "mips64el", "ppc", "ppc64",
|
|
|
|
"riscv64", "s390", "s390x"):
|
|
|
|
v8_cpu = self.arch
|
|
|
|
else:
|
|
|
|
return []
|
|
|
|
return ["v8_target_cpu = \"%s\"" % v8_cpu]
|
2017-02-22 15:09:28 +00:00
|
|
|
|
2018-10-15 12:42:12 +00:00
|
|
|
def GetTargetOS(self):
|
|
|
|
if self.arch in ("android_arm", "android_arm64"):
|
2021-03-10 15:30:04 +00:00
|
|
|
return ["target_os = \"android\""]
|
|
|
|
return []
|
|
|
|
|
|
|
|
def GetSpecialCompiler(self):
|
2021-03-11 21:30:37 +00:00
|
|
|
if _GetMachine() == "aarch64":
|
2021-04-16 17:05:27 +00:00
|
|
|
# We have no prebuilt Clang for arm64 on Linux, so use the system Clang
|
|
|
|
# instead.
|
2021-03-10 15:30:04 +00:00
|
|
|
return ["clang_base_path = \"/usr\"", "clang_use_chrome_plugins = false"]
|
|
|
|
return []
|
2018-10-15 12:42:12 +00:00
|
|
|
|
2017-02-22 15:09:28 +00:00
|
|
|
def GetGnArgs(self):
|
2018-11-07 19:13:15 +00:00
|
|
|
# Use only substring before first '-' as the actual mode
|
|
|
|
mode = re.match("([^-]+)", self.mode).group(1)
|
|
|
|
template = ARGS_TEMPLATES[mode]
|
2018-10-15 12:42:12 +00:00
|
|
|
arch_specific = (self.GetTargetCpu() + self.GetV8TargetCpu() +
|
2021-03-10 15:30:04 +00:00
|
|
|
self.GetTargetOS() + self.GetSpecialCompiler())
|
|
|
|
return template % "\n".join(arch_specific)
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
def Build(self):
|
|
|
|
path = GetPath(self.arch, self.mode)
|
|
|
|
args_gn = os.path.join(path, "args.gn")
|
2018-10-22 19:16:23 +00:00
|
|
|
build_ninja = os.path.join(path, "build.ninja")
|
2017-02-22 15:09:28 +00:00
|
|
|
if not os.path.exists(path):
|
|
|
|
print("# mkdir -p %s" % path)
|
|
|
|
os.makedirs(path)
|
|
|
|
if not os.path.exists(args_gn):
|
|
|
|
_Write(args_gn, self.GetGnArgs())
|
2018-10-22 19:16:23 +00:00
|
|
|
if not os.path.exists(build_ninja):
|
2017-02-22 15:09:28 +00:00
|
|
|
code = _Call("gn gen %s" % path)
|
|
|
|
if code != 0: return code
|
2021-06-16 10:39:59 +00:00
|
|
|
elif self.clean:
|
|
|
|
code = _Call("gn clean %s" % path)
|
|
|
|
if code != 0: return code
|
2017-02-22 15:09:28 +00:00
|
|
|
targets = " ".join(self.targets)
|
2017-06-01 09:20:31 +00:00
|
|
|
# The implementation of mksnapshot failure detection relies on
|
|
|
|
# the "pty" module and GDB presence, so skip it on non-Linux.
|
2018-12-18 16:21:34 +00:00
|
|
|
if not USE_PTY:
|
2018-01-19 19:28:40 +00:00
|
|
|
return _Call("autoninja -C %s %s" % (path, targets))
|
2017-06-01 09:20:31 +00:00
|
|
|
|
2018-01-19 19:28:40 +00:00
|
|
|
return_code, output = _CallWithOutput("autoninja -C %s %s" %
|
|
|
|
(path, targets))
|
2019-01-11 10:24:36 +00:00
|
|
|
if return_code != 0 and "FAILED:" in output and "snapshot_blob" in output:
|
2018-10-22 19:16:23 +00:00
|
|
|
csa_trap = re.compile("Specify option( --csa-trap-on-node=[^ ]*)")
|
|
|
|
match = csa_trap.search(output)
|
|
|
|
extra_opt = match.group(1) if match else ""
|
2019-01-11 10:24:36 +00:00
|
|
|
cmdline = re.compile("python ../../tools/run.py ./mksnapshot (.*)")
|
2019-02-18 11:58:59 +00:00
|
|
|
orig_cmdline = cmdline.search(output).group(1).strip()
|
|
|
|
cmdline = PrepareMksnapshotCmdline(orig_cmdline, path) + extra_opt
|
2018-10-22 19:16:23 +00:00
|
|
|
_Notify("V8 build requires your attention",
|
|
|
|
"Detected mksnapshot failure, re-running in GDB...")
|
2019-01-11 10:24:36 +00:00
|
|
|
_Call(cmdline)
|
2017-06-01 09:20:31 +00:00
|
|
|
return return_code
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
def RunTests(self):
|
2020-07-24 16:26:43 +00:00
|
|
|
# Special handling for "mkgrokdump": if it was built, run it.
|
|
|
|
if (self.arch == "x64" and self.mode == "release" and
|
|
|
|
"mkgrokdump" in self.targets):
|
|
|
|
_Call("%s/mkgrokdump > tools/v8heapconst.py" %
|
|
|
|
GetPath(self.arch, self.mode))
|
2017-02-22 15:09:28 +00:00
|
|
|
if not self.tests: return 0
|
|
|
|
if "ALL" in self.tests:
|
|
|
|
tests = ""
|
|
|
|
else:
|
|
|
|
tests = " ".join(self.tests)
|
2019-03-03 08:53:48 +00:00
|
|
|
return _Call('"%s" ' % sys.executable +
|
|
|
|
os.path.join("tools", "run-tests.py") +
|
2020-06-18 16:39:52 +00:00
|
|
|
" --outdir=%s %s %s" % (
|
|
|
|
GetPath(self.arch, self.mode), tests,
|
|
|
|
" ".join(self.testrunner_args)))
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
def GetTestBinary(argstring):
|
|
|
|
for suite in TESTSUITES_TARGETS:
|
|
|
|
if argstring.startswith(suite): return TESTSUITES_TARGETS[suite]
|
|
|
|
return None
|
|
|
|
|
|
|
|
class ArgumentParser(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.global_targets = set()
|
|
|
|
self.global_tests = set()
|
|
|
|
self.global_actions = set()
|
|
|
|
self.configs = {}
|
2020-06-18 16:39:52 +00:00
|
|
|
self.testrunner_args = []
|
2017-02-22 15:09:28 +00:00
|
|
|
|
2021-06-16 10:39:59 +00:00
|
|
|
def PopulateConfigs(self, arches, modes, targets, tests, clean):
|
2017-02-22 15:09:28 +00:00
|
|
|
for a in arches:
|
|
|
|
for m in modes:
|
|
|
|
path = GetPath(a, m)
|
|
|
|
if path not in self.configs:
|
2021-06-16 10:39:59 +00:00
|
|
|
self.configs[path] = Config(a, m, targets, tests, clean,
|
2020-06-18 16:39:52 +00:00
|
|
|
self.testrunner_args)
|
2017-02-22 15:09:28 +00:00
|
|
|
else:
|
|
|
|
self.configs[path].Extend(targets, tests)
|
|
|
|
|
|
|
|
def ProcessGlobalActions(self):
|
|
|
|
have_configs = len(self.configs) > 0
|
|
|
|
for action in self.global_actions:
|
|
|
|
impact = ACTIONS[action]
|
|
|
|
if (have_configs):
|
|
|
|
for c in self.configs:
|
|
|
|
self.configs[c].Extend(**impact)
|
|
|
|
else:
|
|
|
|
self.PopulateConfigs(DEFAULT_ARCHES, DEFAULT_MODES, **impact)
|
|
|
|
|
|
|
|
def ParseArg(self, argstring):
|
|
|
|
if argstring in ("-h", "--help", "help"):
|
|
|
|
PrintHelpAndExit()
|
2021-03-24 16:21:28 +00:00
|
|
|
if argstring == "--print-completions":
|
|
|
|
PrintCompletionsAndExit()
|
2017-02-22 15:09:28 +00:00
|
|
|
arches = []
|
|
|
|
modes = []
|
|
|
|
targets = []
|
|
|
|
actions = []
|
|
|
|
tests = []
|
2021-06-16 10:39:59 +00:00
|
|
|
clean = False
|
2020-07-24 16:26:43 +00:00
|
|
|
# Special handling for "mkgrokdump": build it for x64.release.
|
|
|
|
if argstring == "mkgrokdump":
|
2021-06-16 10:39:59 +00:00
|
|
|
self.PopulateConfigs(["x64"], ["release"], ["mkgrokdump"], [], False)
|
2020-07-24 16:26:43 +00:00
|
|
|
return
|
2020-01-09 17:50:43 +00:00
|
|
|
# Specifying a single unit test looks like "unittests/Foo.Bar", test262
|
|
|
|
# tests have names like "S15.4.4.7_A4_T1", don't split these.
|
|
|
|
if argstring.startswith("unittests/") or argstring.startswith("test262/"):
|
2017-04-21 17:31:29 +00:00
|
|
|
words = [argstring]
|
2020-06-18 16:39:52 +00:00
|
|
|
elif argstring.startswith("--"):
|
|
|
|
# Pass all other flags to test runner.
|
|
|
|
self.testrunner_args.append(argstring)
|
|
|
|
return
|
2017-04-21 17:31:29 +00:00
|
|
|
else:
|
2020-01-09 17:50:43 +00:00
|
|
|
# Assume it's a word like "x64.release" -> split at the dot.
|
2017-04-21 17:31:29 +00:00
|
|
|
words = argstring.split('.')
|
2017-02-22 15:09:28 +00:00
|
|
|
if len(words) == 1:
|
|
|
|
word = words[0]
|
|
|
|
if word in ACTIONS:
|
|
|
|
self.global_actions.add(word)
|
|
|
|
return
|
|
|
|
if word in TARGETS:
|
|
|
|
self.global_targets.add(word)
|
|
|
|
return
|
|
|
|
maybe_target = GetTestBinary(word)
|
|
|
|
if maybe_target is not None:
|
|
|
|
self.global_tests.add(word)
|
|
|
|
self.global_targets.add(maybe_target)
|
|
|
|
return
|
|
|
|
for word in words:
|
|
|
|
if word in ARCHES:
|
|
|
|
arches.append(word)
|
|
|
|
elif word in MODES:
|
|
|
|
modes.append(word)
|
|
|
|
elif word in TARGETS:
|
|
|
|
targets.append(word)
|
|
|
|
elif word in ACTIONS:
|
|
|
|
actions.append(word)
|
2018-11-07 19:13:15 +00:00
|
|
|
elif any(map(lambda x: word.startswith(x + "-"), MODES)):
|
|
|
|
modes.append(word)
|
2017-02-22 15:09:28 +00:00
|
|
|
else:
|
|
|
|
print("Didn't understand: %s" % word)
|
|
|
|
sys.exit(1)
|
|
|
|
# Process actions.
|
|
|
|
for action in actions:
|
|
|
|
impact = ACTIONS[action]
|
|
|
|
targets += impact["targets"]
|
|
|
|
tests += impact["tests"]
|
2021-06-16 10:39:59 +00:00
|
|
|
clean |= impact["clean"]
|
2017-02-22 15:09:28 +00:00
|
|
|
# Fill in defaults for things that weren't specified.
|
|
|
|
arches = arches or DEFAULT_ARCHES
|
|
|
|
modes = modes or DEFAULT_MODES
|
|
|
|
targets = targets or DEFAULT_TARGETS
|
|
|
|
# Produce configs.
|
2021-06-16 10:39:59 +00:00
|
|
|
self.PopulateConfigs(arches, modes, targets, tests, clean)
|
2017-02-22 15:09:28 +00:00
|
|
|
|
|
|
|
def ParseArguments(self, argv):
|
|
|
|
if len(argv) == 0:
|
|
|
|
PrintHelpAndExit()
|
|
|
|
for argstring in argv:
|
|
|
|
self.ParseArg(argstring)
|
|
|
|
self.ProcessGlobalActions()
|
|
|
|
for c in self.configs:
|
|
|
|
self.configs[c].Extend(self.global_targets, self.global_tests)
|
|
|
|
return self.configs
|
|
|
|
|
|
|
|
def Main(argv):
|
|
|
|
parser = ArgumentParser()
|
|
|
|
configs = parser.ParseArguments(argv[1:])
|
|
|
|
return_code = 0
|
2017-03-17 14:10:23 +00:00
|
|
|
# If we have Goma but it is not running, start it.
|
2021-03-04 15:19:50 +00:00
|
|
|
if (IS_GOMA_MACHINE and
|
2017-03-17 14:10:23 +00:00
|
|
|
_Call("ps -e | grep compiler_proxy > /dev/null", silent=True) != 0):
|
|
|
|
_Call("%s/goma_ctl.py ensure_start" % GOMADIR)
|
2017-02-22 15:09:28 +00:00
|
|
|
for c in configs:
|
|
|
|
return_code += configs[c].Build()
|
2017-03-07 16:36:51 +00:00
|
|
|
if return_code == 0:
|
|
|
|
for c in configs:
|
|
|
|
return_code += configs[c].RunTests()
|
2017-02-22 15:09:28 +00:00
|
|
|
if return_code == 0:
|
2017-04-21 12:15:38 +00:00
|
|
|
_Notify('Done!', 'V8 compilation finished successfully.')
|
2017-02-22 15:09:28 +00:00
|
|
|
else:
|
2017-04-21 12:15:38 +00:00
|
|
|
_Notify('Error!', 'V8 compilation finished with errors.')
|
2017-02-22 15:09:28 +00:00
|
|
|
return return_code
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(Main(sys.argv))
|