Commit f4dd3231 authored by machenbach's avatar machenbach Committed by Commit bot

[gn] Automatically derive build configs in test runner.

This executes an action as part of the build, writing a json
configuration that includes all build flags relevant to v8
testing.

The test runner will derive all build-dependent flags from
the file if it detects it.

BUG=chromium:474921

Review-Url: https://codereview.chromium.org/2106423002
Cr-Commit-Position: refs/heads/master@{#37446}
parent fa69cbb8
...@@ -626,6 +626,26 @@ action("run_mksnapshot") { ...@@ -626,6 +626,26 @@ action("run_mksnapshot") {
} }
} }
action("v8_dump_build_config") {
script = "tools/testrunner/utils/dump_build_config.py"
outputs = [ "$root_out_dir/v8_build_config.json" ]
args = [
rebase_path("$root_out_dir/v8_build_config.json", root_build_dir),
"dcheck_always_on=$dcheck_always_on",
"is_asan=$is_asan",
"is_cfi=$is_cfi",
"is_component_build=$is_component_build",
"is_debug=$is_debug",
"is_msan=$is_msan",
"is_tsan=$is_tsan",
"target_cpu=\"$target_cpu\"",
"v8_enable_i18n_support=$v8_enable_i18n_support",
"v8_target_cpu=\"$v8_target_cpu\"",
"v8_use_snapshot=$v8_use_snapshot",
]
}
############################################################################### ###############################################################################
# Source Sets (aka static libraries) # Source Sets (aka static libraries)
# #
...@@ -2109,6 +2129,8 @@ if (is_component_build) { ...@@ -2109,6 +2129,8 @@ if (is_component_build) {
"src/v8dll-main.cc", "src/v8dll-main.cc",
] ]
deps = [ ":v8_dump_build_config" ]
public_deps = [ public_deps = [
":v8_base", ":v8_base",
":v8_maybe_snapshot", ":v8_maybe_snapshot",
...@@ -2120,6 +2142,8 @@ if (is_component_build) { ...@@ -2120,6 +2142,8 @@ if (is_component_build) {
} }
} else { } else {
group("v8") { group("v8") {
deps = [ ":v8_dump_build_config" ]
public_deps = [ public_deps = [
":v8_base", ":v8_base",
":v8_maybe_snapshot", ":v8_maybe_snapshot",
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
from collections import OrderedDict from collections import OrderedDict
import itertools import itertools
import json
import multiprocessing import multiprocessing
import optparse import optparse
import os import os
...@@ -434,6 +435,34 @@ def ProcessOptions(options): ...@@ -434,6 +435,34 @@ def ProcessOptions(options):
global EXHAUSTIVE_VARIANTS global EXHAUSTIVE_VARIANTS
global VARIANTS global VARIANTS
# First try to auto-detect configurations based on the build if GN was
# used. This can't be overridden by cmd-line arguments.
options.auto_detect = False
build_config_path = os.path.join(
BASE_DIR, options.outdir, "v8_build_config.json")
if os.path.exists(build_config_path):
try:
with open(build_config_path) as f:
build_config = json.load(f)
except Exception:
print ("%s exists but contains invalid json. Is your build up-to-date?" %
build_config_path)
return False
options.auto_detect = True
options.arch_and_mode = None
options.arch = build_config["v8_target_cpu"]
if options.arch == 'x86':
# TODO(machenbach): Transform all to x86 eventually.
options.arch = 'ia32'
options.asan = build_config["is_asan"]
options.dcheck_always_on = build_config["dcheck_always_on"]
options.mode = 'debug' if build_config["is_debug"] else 'release'
options.msan = build_config["is_msan"]
options.no_i18n = not build_config["v8_enable_i18n_support"]
options.no_snap = not build_config["v8_use_snapshot"]
options.tsan = build_config["is_tsan"]
# Architecture and mode related stuff. # Architecture and mode related stuff.
if options.arch_and_mode: if options.arch_and_mode:
options.arch_and_mode = [arch_and_mode.split(".") options.arch_and_mode = [arch_and_mode.split(".")
...@@ -667,6 +696,10 @@ def Execute(arch, mode, args, options, suites): ...@@ -667,6 +696,10 @@ def Execute(arch, mode, args, options, suites):
# buildbot. Currently this is capitalized Release and Debug. # buildbot. Currently this is capitalized Release and Debug.
shell_dir = os.path.join(BASE_DIR, options.outdir, mode) shell_dir = os.path.join(BASE_DIR, options.outdir, mode)
mode = BuildbotToV8Mode(mode) mode = BuildbotToV8Mode(mode)
elif options.auto_detect:
# If an output dir with a build was passed, test directly in that
# directory.
shell_dir = os.path.join(BASE_DIR, options.outdir)
else: else:
shell_dir = os.path.join( shell_dir = os.path.join(
BASE_DIR, BASE_DIR,
...@@ -712,6 +745,8 @@ def Execute(arch, mode, args, options, suites): ...@@ -712,6 +745,8 @@ def Execute(arch, mode, args, options, suites):
sancov_dir=options.sancov_dir) sancov_dir=options.sancov_dir)
# TODO(all): Combine "simulator" and "simulator_run". # TODO(all): Combine "simulator" and "simulator_run".
# TODO(machenbach): In GN we can derive simulator run from
# target_arch != v8_target_arch in the dumped build config.
simulator_run = not options.dont_skip_simulator_slow_tests and \ simulator_run = not options.dont_skip_simulator_slow_tests and \
arch in ['arm64', 'arm', 'mipsel', 'mips', 'mips64', 'mips64el', \ arch in ['arm64', 'arm', 'mipsel', 'mips', 'mips64', 'mips64el', \
'ppc', 'ppc64'] and \ 'ppc', 'ppc64'] and \
......
# 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.
"""Writes a dictionary to a json file with the passed key-value pairs.
Expected to be called like:
dump_build_config.py path/to/file.json [key1=value1 ...]
The values are expected to be valid json. E.g. true is a boolean and "true" is
the string "true".
"""
import json
import os
import sys
assert len(sys.argv) > 1
def as_json(kv):
assert '=' in kv
k, v = kv.split('=', 1)
return k, json.loads(v)
with open(sys.argv[1], 'w') as f:
json.dump(dict(as_json(kv) for kv in sys.argv[2:]), f)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment