mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[build] Use separate out directories for each sanitizer.
Bug: https://github.com/dart-lang/sdk/issues/39611 Change-Id: Ie0aeaff758234220c2f0267b462d14f4c076bdf6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127821 Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
0704761f15
commit
3678a3bd42
|
@ -213,11 +213,13 @@ class Configuration {
|
|||
var runtime = enumOption("runtime", Runtime.names, Runtime.find);
|
||||
var system = enumOption("system", System.names, System.find);
|
||||
var nnbdMode = enumOption("nnbd", NnbdMode.names, NnbdMode.find);
|
||||
var sanitizer = enumOption("sanitizer", Sanitizer.names, Sanitizer.find);
|
||||
|
||||
// Fill in any missing values using defaults when possible.
|
||||
architecture ??= Architecture.x64;
|
||||
system ??= System.host;
|
||||
nnbdMode ??= NnbdMode.legacy;
|
||||
sanitizer ??= Sanitizer.none;
|
||||
|
||||
// Infer from compiler from runtime or vice versa.
|
||||
if (compiler == null) {
|
||||
|
@ -242,6 +244,7 @@ class Configuration {
|
|||
var configuration = Configuration(
|
||||
name, architecture, compiler, mode, runtime, system,
|
||||
nnbdMode: nnbdMode,
|
||||
sanitizer: sanitizer,
|
||||
babel: stringOption("babel"),
|
||||
builderTag: stringOption("builder-tag"),
|
||||
genKernelOptions: stringListOption("gen-kernel-options"),
|
||||
|
@ -285,6 +288,8 @@ class Configuration {
|
|||
/// Which NNBD mode to run the test files under.
|
||||
final NnbdMode nnbdMode;
|
||||
|
||||
final Sanitizer sanitizer;
|
||||
|
||||
final String babel;
|
||||
|
||||
final String builderTag;
|
||||
|
@ -336,6 +341,7 @@ class Configuration {
|
|||
Configuration(this.name, this.architecture, this.compiler, this.mode,
|
||||
this.runtime, this.system,
|
||||
{NnbdMode nnbdMode,
|
||||
Sanitizer sanitizer,
|
||||
String babel,
|
||||
String builderTag,
|
||||
List<String> genKernelOptions,
|
||||
|
@ -356,6 +362,7 @@ class Configuration {
|
|||
bool useHotReloadRollback,
|
||||
bool useSdk})
|
||||
: nnbdMode = nnbdMode ?? NnbdMode.legacy,
|
||||
sanitizer = sanitizer ?? Sanitizer.none,
|
||||
babel = babel ?? "",
|
||||
builderTag = builderTag ?? "",
|
||||
genKernelOptions = genKernelOptions ?? <String>[],
|
||||
|
@ -385,6 +392,7 @@ class Configuration {
|
|||
runtime == other.runtime &&
|
||||
system == other.system &&
|
||||
nnbdMode == other.nnbdMode &&
|
||||
sanitizer == other.sanitizer &&
|
||||
babel == other.babel &&
|
||||
builderTag == other.builderTag &&
|
||||
_listsEqual(genKernelOptions, other.genKernelOptions) &&
|
||||
|
@ -528,6 +536,7 @@ class Configuration {
|
|||
}
|
||||
|
||||
fields.add("nnbd: $nnbdMode ${other.nnbdMode}");
|
||||
fields.add("sanitizer: $sanitizer ${other.sanitizer}");
|
||||
stringField("babel", babel, other.babel);
|
||||
stringField("builder-tag", builderTag, other.builderTag);
|
||||
stringListField(
|
||||
|
@ -752,6 +761,30 @@ class Mode extends NamedEnum {
|
|||
bool get isDebug => this == debug;
|
||||
}
|
||||
|
||||
class Sanitizer extends NamedEnum {
|
||||
static const none = Sanitizer._('none');
|
||||
static const asan = Sanitizer._('asan');
|
||||
static const lsan = Sanitizer._('lsan');
|
||||
static const msan = Sanitizer._('msan');
|
||||
static const tsan = Sanitizer._('tsan');
|
||||
static const ubsan = Sanitizer._('ubsan');
|
||||
|
||||
static final List<String> names = _all.keys.toList();
|
||||
|
||||
static final _all = Map<String, Sanitizer>.fromIterable(
|
||||
[none, asan, lsan, msan, tsan, ubsan],
|
||||
key: (mode) => (mode as Sanitizer).name);
|
||||
|
||||
static Sanitizer find(String name) {
|
||||
var mode = _all[name];
|
||||
if (mode != null) return mode;
|
||||
|
||||
throw ArgumentError('Unknown sanitizer "$name".');
|
||||
}
|
||||
|
||||
const Sanitizer._(String name) : super(name);
|
||||
}
|
||||
|
||||
class Runtime extends NamedEnum {
|
||||
static const vm = Runtime._('vm');
|
||||
static const flutter = Runtime._('flutter');
|
||||
|
|
|
@ -397,6 +397,7 @@ architecture: ia32 x64
|
|||
runtime: chrome d8
|
||||
system: android fuchsia
|
||||
nnbd: legacy strong
|
||||
sanitizer: none none
|
||||
builder-tag: a tag b tag
|
||||
vm-options: [vm a1, vm a2] [vm b1, vm b2]
|
||||
dart2js-options: [dart2js a1, dart2js a2] [dart2js b1, dart2js b2]
|
||||
|
@ -427,6 +428,7 @@ architecture: ia32 ia32
|
|||
runtime: chrome chrome
|
||||
system: android android
|
||||
nnbd: legacy legacy
|
||||
sanitizer: none none
|
||||
builder-tag: a tag a tag
|
||||
vm-options: [vm a1, vm a2] [vm a1, vm a2]
|
||||
dart2js-options: [dart2js a1, dart2js a2] [dart2js a1, dart2js a2]
|
||||
|
|
|
@ -104,6 +104,7 @@ class TestConfiguration {
|
|||
Runtime get runtime => configuration.runtime;
|
||||
System get system => configuration.system;
|
||||
NnbdMode get nnbdMode => configuration.nnbdMode;
|
||||
Sanitizer get sanitizer => configuration.sanitizer;
|
||||
|
||||
// Boolean getters
|
||||
bool get hotReload => configuration.useHotReload;
|
||||
|
@ -462,6 +463,10 @@ class TestConfiguration {
|
|||
|
||||
if (system == System.android) result += "Android";
|
||||
|
||||
if (sanitizer != Sanitizer.none) {
|
||||
result += sanitizer.name.toUpperCase();
|
||||
}
|
||||
|
||||
var arch = architecture.name.toUpperCase();
|
||||
var normal = '$result$arch';
|
||||
var cross = '${result}X$arch';
|
||||
|
|
|
@ -92,6 +92,9 @@ class OptionsParser {
|
|||
static final List<_Option> _options = [
|
||||
_Option('mode', 'Mode in which to run the tests.',
|
||||
abbr: 'm', values: ['all']..addAll(Mode.names)),
|
||||
_Option('sanitizer', 'Sanitizer in which to run the tests.',
|
||||
defaultsTo: Sanitizer.none.name,
|
||||
values: ['all']..addAll(Sanitizer.names)),
|
||||
_Option(
|
||||
'compiler',
|
||||
'''How the Dart code should be compiled or statically processed.
|
||||
|
@ -776,29 +779,37 @@ compiler.''',
|
|||
if (modes == "all") modes = "debug,release,product";
|
||||
for (var modeName in modes.split(",")) {
|
||||
var mode = Mode.find(modeName);
|
||||
var system = System.find(data["system"] as String);
|
||||
var configuration = Configuration("custom configuration",
|
||||
architecture, compiler, mode, runtime, system,
|
||||
nnbdMode: nnbdMode,
|
||||
timeout: data["timeout"] as int,
|
||||
enableAsserts: data["enable_asserts"] as bool,
|
||||
useAnalyzerCfe: data["use_cfe"] as bool,
|
||||
useAnalyzerFastaParser:
|
||||
data["analyzer_use_fasta_parser"] as bool,
|
||||
useBlobs: data["use_blobs"] as bool,
|
||||
useElf: data["use_elf"] as bool,
|
||||
useSdk: data["use_sdk"] as bool,
|
||||
useHotReload: data["hot_reload"] as bool,
|
||||
useHotReloadRollback: data["hot_reload_rollback"] as bool,
|
||||
isHostChecked: data["host_checked"] as bool,
|
||||
isCsp: data["csp"] as bool,
|
||||
isMinified: data["minified"] as bool,
|
||||
vmOptions: vmOptions,
|
||||
dart2jsOptions: dart2jsOptions,
|
||||
experiments: experiments,
|
||||
babel: data['babel'] as String,
|
||||
builderTag: data["builder_tag"] as String);
|
||||
addConfiguration(configuration);
|
||||
// Expand sanitizers.
|
||||
String sanitizers = (data["sanitizer"] as String) ?? "none";
|
||||
if (sanitizers == "all")
|
||||
sanitizers = "none,asan,lsan,msan,tsan,ubsan";
|
||||
for (var sanitizerName in sanitizers.split(",")) {
|
||||
var sanitizer = Sanitizer.find(sanitizerName);
|
||||
var system = System.find(data["system"] as String);
|
||||
var configuration = Configuration("custom configuration",
|
||||
architecture, compiler, mode, runtime, system,
|
||||
nnbdMode: nnbdMode,
|
||||
sanitizer: sanitizer,
|
||||
timeout: data["timeout"] as int,
|
||||
enableAsserts: data["enable_asserts"] as bool,
|
||||
useAnalyzerCfe: data["use_cfe"] as bool,
|
||||
useAnalyzerFastaParser:
|
||||
data["analyzer_use_fasta_parser"] as bool,
|
||||
useBlobs: data["use_blobs"] as bool,
|
||||
useElf: data["use_elf"] as bool,
|
||||
useSdk: data["use_sdk"] as bool,
|
||||
useHotReload: data["hot_reload"] as bool,
|
||||
useHotReloadRollback: data["hot_reload_rollback"] as bool,
|
||||
isHostChecked: data["host_checked"] as bool,
|
||||
isCsp: data["csp"] as bool,
|
||||
isMinified: data["minified"] as bool,
|
||||
vmOptions: vmOptions,
|
||||
dart2jsOptions: dart2jsOptions,
|
||||
experiments: experiments,
|
||||
babel: data['babel'] as String,
|
||||
builderTag: data["builder_tag"] as String);
|
||||
addConfiguration(configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,12 +100,12 @@ def ProcessOptions(options):
|
|||
return True
|
||||
|
||||
|
||||
def GetBuildRoot(mode, arch):
|
||||
return utils.GetBuildRoot(HOST_OS, mode, arch)
|
||||
def GetBuildRoot(mode, arch, sanitizer):
|
||||
return utils.GetBuildRoot(HOST_OS, mode, arch, sanitizer)
|
||||
|
||||
|
||||
def GetDart(mode, arch):
|
||||
executable = [abspath(join(GetBuildRoot(mode, arch), 'dart'))]
|
||||
def GetDart(mode, arch, sanitizer):
|
||||
executable = [abspath(join(GetBuildRoot(mode, arch, sanitizer), 'dart'))]
|
||||
return executable
|
||||
|
||||
|
||||
|
|
|
@ -140,10 +140,11 @@ def GetBuildConf(mode, arch):
|
|||
return GetBuildMode(mode) + arch.upper()
|
||||
|
||||
|
||||
def GetBuildRoot(host_os, mode=None, arch=None):
|
||||
def GetBuildRoot(host_os, mode=None, arch=None, sanitizer=None):
|
||||
global BUILD_ROOT
|
||||
if mode:
|
||||
return os.path.join(BUILD_ROOT[host_os], GetBuildConf(mode, arch))
|
||||
return os.path.join(BUILD_ROOT[host_os],
|
||||
GetBuildConf(mode, arch, sanitizer))
|
||||
else:
|
||||
return BUILD_ROOT[host_os]
|
||||
|
||||
|
|
|
@ -995,13 +995,16 @@
|
|||
"arguments": [
|
||||
"--mode=${mode}",
|
||||
"--arch=${arch}",
|
||||
"--asan"
|
||||
"--sanitizer=asan"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build dart",
|
||||
"script": "tools/build.py",
|
||||
"arguments": ["runtime"],
|
||||
"arguments": [
|
||||
"--sanitizer=asan",
|
||||
"runtime"
|
||||
],
|
||||
"environment": {
|
||||
"ASAN_OPTIONS": "handle_segv=0:detect_leaks=1:detect_stack_use_after_return=0:disable_coredump=0:abort_on_error=1",
|
||||
"ASAN_SYMBOLIZER_PATH": "buildtools/linux-x64/clang/bin/llvm-symbolizer"
|
||||
|
@ -1032,13 +1035,16 @@
|
|||
"arguments": [
|
||||
"--mode=${mode}",
|
||||
"--arch=${arch}",
|
||||
"--lsan"
|
||||
"--sanitizer=lsan"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build dart",
|
||||
"script": "tools/build.py",
|
||||
"arguments": ["runtime"],
|
||||
"arguments": [
|
||||
"--sanitizer=lsan",
|
||||
"runtime"
|
||||
],
|
||||
"environment": {
|
||||
"ASAN_OPTIONS": "handle_segv=0:detect_leaks=1:detect_stack_use_after_return=0:disable_coredump=0:abort_on_error=1",
|
||||
"ASAN_SYMBOLIZER_PATH": "buildtools/linux-x64/clang/bin/llvm-symbolizer"
|
||||
|
@ -1069,13 +1075,16 @@
|
|||
"arguments": [
|
||||
"--mode=${mode}",
|
||||
"--arch=${arch}",
|
||||
"--msan"
|
||||
"--sanitizer=msan"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build dart",
|
||||
"script": "tools/build.py",
|
||||
"arguments": ["runtime"],
|
||||
"arguments": [
|
||||
"--sanitizer=msan",
|
||||
"runtime"
|
||||
],
|
||||
"environment": {
|
||||
"MSAN_OPTIONS": "handle_segv=0:detect_leaks=1:detect_stack_use_after_return=0:disable_coredump=0:abort_on_error=1",
|
||||
"MSAN_SYMBOLIZER_PATH": "buildtools/linux-x64/clang/bin/llvm-symbolizer"
|
||||
|
@ -1106,13 +1115,16 @@
|
|||
"arguments": [
|
||||
"--mode=${mode}",
|
||||
"--arch=${arch}",
|
||||
"--tsan"
|
||||
"--sanitizer=tsan"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build dart",
|
||||
"script": "tools/build.py",
|
||||
"arguments": ["runtime"],
|
||||
"arguments": [
|
||||
"--sanitizer=tsan",
|
||||
"runtime"
|
||||
],
|
||||
"environment": {
|
||||
"TSAN_OPTIONS": "handle_segv=0:disable_coredump=0:abort_on_error=1",
|
||||
"TSAN_SYMBOLIZER_PATH": "buildtools/linux-x64/clang/bin/llvm-symbolizer"
|
||||
|
@ -1143,13 +1155,16 @@
|
|||
"arguments": [
|
||||
"--mode=${mode}",
|
||||
"--arch=${arch}",
|
||||
"--ubsan"
|
||||
"--sanitizer=ubsan"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "build dart",
|
||||
"script": "tools/build.py",
|
||||
"arguments": ["runtime"],
|
||||
"arguments": [
|
||||
"--sanitizer=ubsan",
|
||||
"runtime"
|
||||
],
|
||||
"environment": {
|
||||
"UBSAN_OPTIONS": "handle_segv=0:disable_coredump=0:abort_on_error=1"
|
||||
}
|
||||
|
|
|
@ -62,6 +62,12 @@ def BuildOptions():
|
|||
help='Target OSs (comma-separated).',
|
||||
metavar='[all,host,android]',
|
||||
default='host')
|
||||
result.add_option(
|
||||
"--sanitizer",
|
||||
type=str,
|
||||
help='Build variants (comma-separated).',
|
||||
metavar='[all,none,asan,lsan,msan,tsan,ubsan]',
|
||||
default='none')
|
||||
# TODO(38701): Remove this and everything that references it once the
|
||||
# forked NNBD SDK is merged back in.
|
||||
result.add_option(
|
||||
|
@ -91,9 +97,12 @@ def ProcessOptions(options, args):
|
|||
options.mode = 'debug,release,product'
|
||||
if options.os == 'all':
|
||||
options.os = 'host,android'
|
||||
if options.sanitizer == 'all':
|
||||
options.sanitizer = 'none,asan,lsan,msan,tsan,ubsan'
|
||||
options.mode = options.mode.split(',')
|
||||
options.arch = options.arch.split(',')
|
||||
options.os = options.os.split(',')
|
||||
options.sanitizer = options.sanitizer.split(',')
|
||||
for mode in options.mode:
|
||||
if not mode in ['debug', 'release', 'product']:
|
||||
print("Unknown mode %s" % mode)
|
||||
|
@ -273,11 +282,12 @@ def EnsureGomaStarted(out_dir):
|
|||
goma_started = True
|
||||
return True
|
||||
|
||||
|
||||
# Returns a tuple (build_config, command to run, whether goma is used)
|
||||
def BuildOneConfig(options, targets, target_os, mode, arch):
|
||||
build_config = utils.GetBuildConf(mode, arch, target_os, options.nnbd)
|
||||
out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os, options.nnbd)
|
||||
def BuildOneConfig(options, targets, target_os, mode, arch, sanitizer):
|
||||
build_config = utils.GetBuildConf(mode, arch, target_os, sanitizer,
|
||||
options.nnbd)
|
||||
out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os, sanitizer,
|
||||
options.nnbd)
|
||||
using_goma = False
|
||||
# TODO(zra): Remove auto-run of gn, replace with prompt for user to run
|
||||
# gn.py manually.
|
||||
|
@ -345,8 +355,10 @@ def Main():
|
|||
for target_os in options.os:
|
||||
for mode in options.mode:
|
||||
for arch in options.arch:
|
||||
configs.append(
|
||||
BuildOneConfig(options, targets, target_os, mode, arch))
|
||||
for sanitizer in options.sanitizer:
|
||||
configs.append(
|
||||
BuildOneConfig(options, targets, target_os, mode, arch,
|
||||
sanitizer))
|
||||
|
||||
# Build regular configs.
|
||||
goma_builds = []
|
||||
|
|
124
tools/gn.py
124
tools/gn.py
|
@ -19,11 +19,6 @@ DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
|
|||
GN = os.path.join(DART_ROOT, 'buildtools', 'gn')
|
||||
|
||||
# Environment variables for default settings.
|
||||
DART_USE_ASAN = "DART_USE_ASAN" # Use instead of --asan
|
||||
DART_USE_LSAN = "DART_USE_LSAN" # Use instead of --lsan
|
||||
DART_USE_MSAN = "DART_USE_MSAN" # Use instead of --msan
|
||||
DART_USE_TSAN = "DART_USE_TSAN" # Use instead of --tsan
|
||||
DART_USE_UBSAN = "DART_USE_UBSAN" # Use instead of --ubsan
|
||||
DART_USE_TOOLCHAIN = "DART_USE_TOOLCHAIN" # Use instread of --toolchain-prefix
|
||||
DART_USE_SYSROOT = "DART_USE_SYSROOT" # Use instead of --target-sysroot
|
||||
DART_USE_CRASHPAD = "DART_USE_CRASHPAD" # Use instead of --use-crashpad
|
||||
|
@ -33,26 +28,6 @@ DART_MAKE_PLATFORM_SDK = "DART_MAKE_PLATFORM_SDK"
|
|||
DART_GN_ARGS = "DART_GN_ARGS"
|
||||
|
||||
|
||||
def UseASAN():
|
||||
return DART_USE_ASAN in os.environ
|
||||
|
||||
|
||||
def UseLSAN():
|
||||
return DART_USE_LSAN in os.environ
|
||||
|
||||
|
||||
def UseMSAN():
|
||||
return DART_USE_MSAN in os.environ
|
||||
|
||||
|
||||
def UseTSAN():
|
||||
return DART_USE_TSAN in os.environ
|
||||
|
||||
|
||||
def UseUBSAN():
|
||||
return DART_USE_UBSAN in os.environ
|
||||
|
||||
|
||||
def ToolchainPrefix(args):
|
||||
if args.toolchain_prefix:
|
||||
return args.toolchain_prefix
|
||||
|
@ -77,8 +52,9 @@ def GetGNArgs(args):
|
|||
|
||||
|
||||
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
|
||||
def GetOutDir(mode, arch, target_os, use_nnbd):
|
||||
return utils.GetBuildRoot(HOST_OS, mode, arch, target_os, use_nnbd)
|
||||
def GetOutDir(mode, arch, target_os, sanitizer, use_nnbd):
|
||||
return utils.GetBuildRoot(HOST_OS, mode, arch, target_os, sanitizer,
|
||||
use_nnbd)
|
||||
|
||||
|
||||
def ToCommandLine(gn_args):
|
||||
|
@ -146,10 +122,6 @@ def ParseStringMap(key, string_map):
|
|||
return None
|
||||
|
||||
|
||||
def UseSanitizer(args):
|
||||
return args.asan or args.lsan or args.msan or args.tsan or args.ubsan
|
||||
|
||||
|
||||
def DontUseClang(args, target_os, host_cpu, target_cpu):
|
||||
# We don't have clang on Windows.
|
||||
return target_os == 'win'
|
||||
|
@ -167,7 +139,7 @@ def UseSysroot(args, gn_args):
|
|||
|
||||
|
||||
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
|
||||
def ToGnArgs(args, mode, arch, target_os, use_nnbd):
|
||||
def ToGnArgs(args, mode, arch, target_os, sanitizer, use_nnbd):
|
||||
gn_args = {}
|
||||
|
||||
host_os = HostOsForGn(HOST_OS)
|
||||
|
@ -203,7 +175,7 @@ def ToGnArgs(args, mode, arch, target_os, use_nnbd):
|
|||
|
||||
# Use tcmalloc only when targeting Linux and when not using ASAN.
|
||||
gn_args['dart_use_tcmalloc'] = ((gn_args['target_os'] == 'linux') and
|
||||
not UseSanitizer(args))
|
||||
sanitizer == 'none')
|
||||
|
||||
if gn_args['target_os'] == 'linux':
|
||||
if gn_args['target_cpu'] == 'arm':
|
||||
|
@ -241,11 +213,11 @@ def ToGnArgs(args, mode, arch, target_os, use_nnbd):
|
|||
enable_code_coverage = args.code_coverage and gn_args['is_clang']
|
||||
gn_args['dart_vm_code_coverage'] = enable_code_coverage
|
||||
|
||||
gn_args['is_asan'] = args.asan
|
||||
gn_args['is_lsan'] = args.lsan
|
||||
gn_args['is_msan'] = args.msan
|
||||
gn_args['is_tsan'] = args.tsan
|
||||
gn_args['is_ubsan'] = args.ubsan
|
||||
gn_args['is_asan'] = sanitizer == 'asan'
|
||||
gn_args['is_lsan'] = sanitizer == 'lsan'
|
||||
gn_args['is_msan'] = sanitizer == 'msan'
|
||||
gn_args['is_tsan'] = sanitizer == 'tsan'
|
||||
gn_args['is_ubsan'] = sanitizer == 'ubsan'
|
||||
gn_args['include_dart2native'] = True
|
||||
gn_args['is_qemu'] = args.use_qemu
|
||||
|
||||
|
@ -306,9 +278,12 @@ def ProcessOptions(args):
|
|||
args.mode = 'debug,release,product'
|
||||
if args.os == 'all':
|
||||
args.os = 'host,android'
|
||||
if args.sanitizer == 'all':
|
||||
args.sanitizer = 'none,asan,lsan,msan,tsan,ubsan'
|
||||
args.mode = args.mode.split(',')
|
||||
args.arch = args.arch.split(',')
|
||||
args.os = args.os.split(',')
|
||||
args.sanitizer = args.sanitizer.split(',')
|
||||
for mode in args.mode:
|
||||
if not mode in ['debug', 'release', 'product']:
|
||||
print("Unknown mode %s" % mode)
|
||||
|
@ -389,6 +364,12 @@ def parse_args(args):
|
|||
help='Target OSs (comma-separated).',
|
||||
metavar='[all,host,android]',
|
||||
default='host')
|
||||
common_group.add_argument(
|
||||
'--sanitizer',
|
||||
type=str,
|
||||
help='Build variants (comma-separated).',
|
||||
metavar='[all,none,asan,lsan,msan,tsan,ubsan]',
|
||||
default='none')
|
||||
# TODO(38701): Remove this once the forked NNBD SDK is merged back in.
|
||||
common_group.add_argument(
|
||||
"--nnbd",
|
||||
|
@ -408,13 +389,6 @@ def parse_args(args):
|
|||
help='The ARM float ABI (soft, softfp, hard)',
|
||||
metavar='[soft,softfp,hard]',
|
||||
default='')
|
||||
other_group.add_argument(
|
||||
'--asan',
|
||||
help='Build with ASAN',
|
||||
default=UseASAN(),
|
||||
action='store_true')
|
||||
other_group.add_argument(
|
||||
'--no-asan', help='Disable ASAN', dest='asan', action='store_false')
|
||||
other_group.add_argument(
|
||||
'--bytecode',
|
||||
'-b',
|
||||
|
@ -456,20 +430,6 @@ def parse_args(args):
|
|||
default=False,
|
||||
dest='exclude_kernel_service',
|
||||
action='store_true')
|
||||
other_group.add_argument(
|
||||
'--lsan',
|
||||
help='Build with LSAN',
|
||||
default=UseLSAN(),
|
||||
action='store_true')
|
||||
other_group.add_argument(
|
||||
'--no-lsan', help='Disable LSAN', dest='lsan', action='store_false')
|
||||
other_group.add_argument(
|
||||
'--msan',
|
||||
help='Build with MSAN',
|
||||
default=UseMSAN(),
|
||||
action='store_true')
|
||||
other_group.add_argument(
|
||||
'--no-msan', help='Disable MSAN', dest='msan', action='store_false')
|
||||
other_group.add_argument(
|
||||
'--gn-args', help='Set extra GN args', dest='gn_args', action='append')
|
||||
other_group.add_argument(
|
||||
|
@ -487,20 +447,6 @@ def parse_args(args):
|
|||
'-t',
|
||||
type=str,
|
||||
help='Comma-separated list of arch=/path/to/toolchain-prefix mappings')
|
||||
other_group.add_argument(
|
||||
'--tsan',
|
||||
help='Build with TSAN',
|
||||
default=UseTSAN(),
|
||||
action='store_true')
|
||||
other_group.add_argument(
|
||||
'--no-tsan', help='Disable TSAN', dest='tsan', action='store_false')
|
||||
other_group.add_argument(
|
||||
'--ubsan',
|
||||
help='Build with UBSAN',
|
||||
default=UseUBSAN(),
|
||||
action='store_true')
|
||||
other_group.add_argument(
|
||||
'--no-ubsan', help='Disable UBSAN', dest='ubsan', action='store_false')
|
||||
other_group.add_argument(
|
||||
'--wheezy',
|
||||
help='This flag is deprecated.',
|
||||
|
@ -547,7 +493,6 @@ def RunCommand(command):
|
|||
return ("Command failed: " + ' '.join(command) + "\n" + "output: " +
|
||||
e.output)
|
||||
|
||||
|
||||
def Main(argv):
|
||||
starttime = time.time()
|
||||
args = parse_args(argv)
|
||||
|
@ -562,20 +507,23 @@ def Main(argv):
|
|||
for target_os in args.os:
|
||||
for mode in args.mode:
|
||||
for arch in args.arch:
|
||||
out_dir = GetOutDir(mode, arch, target_os, args.nnbd)
|
||||
# TODO(infra): Re-enable --check. Many targets fail to use
|
||||
# public_deps to re-expose header files to their dependents.
|
||||
# See dartbug.com/32364
|
||||
command = [gn, 'gen', out_dir]
|
||||
gn_args = ToCommandLine(
|
||||
ToGnArgs(args, mode, arch, target_os, args.nnbd))
|
||||
gn_args += GetGNArgs(args)
|
||||
if args.verbose:
|
||||
print("gn gen --check in %s" % out_dir)
|
||||
if args.ide:
|
||||
command.append(ide_switch(HOST_OS))
|
||||
command.append('--args=%s' % ' '.join(gn_args))
|
||||
commands.append(command)
|
||||
for sanitizer in args.sanitizer:
|
||||
out_dir = GetOutDir(mode, arch, target_os, sanitizer,
|
||||
args.nnbd)
|
||||
# TODO(infra): Re-enable --check. Many targets fail to use
|
||||
# public_deps to re-expose header files to their dependents.
|
||||
# See dartbug.com/32364
|
||||
command = [gn, 'gen', out_dir]
|
||||
gn_args = ToCommandLine(
|
||||
ToGnArgs(args, mode, arch, target_os, sanitizer,
|
||||
args.nnbd))
|
||||
gn_args += GetGNArgs(args)
|
||||
if args.verbose:
|
||||
print("gn gen --check in %s" % out_dir)
|
||||
if args.ide:
|
||||
command.append(ide_switch(HOST_OS))
|
||||
command.append('--args=%s' % ' '.join(gn_args))
|
||||
commands.append(command)
|
||||
|
||||
pool = multiprocessing.Pool(args.workers)
|
||||
results = pool.map(RunCommand, commands, chunksize=1)
|
||||
|
|
|
@ -253,6 +253,17 @@ BUILD_MODES = {
|
|||
'product': 'Product',
|
||||
}
|
||||
|
||||
# Mapping table between build mode and build configuration.
|
||||
BUILD_SANITIZERS = {
|
||||
None: '',
|
||||
'none': '',
|
||||
'asan': 'ASAN',
|
||||
'lsan': 'LSAN',
|
||||
'msan': 'MSAN',
|
||||
'tsan': 'TSAN',
|
||||
'ubsan': 'UBSAN',
|
||||
}
|
||||
|
||||
# Mapping table between OS and build output location.
|
||||
BUILD_ROOT = {
|
||||
'win32': os.path.join('out'),
|
||||
|
@ -290,6 +301,10 @@ def GetBuildMode(mode):
|
|||
return BUILD_MODES[mode]
|
||||
|
||||
|
||||
def GetBuildSanitizer(sanitizer):
|
||||
return BUILD_SANITIZERS[sanitizer]
|
||||
|
||||
|
||||
def GetArchFamily(arch):
|
||||
return ARCH_FAMILY[arch]
|
||||
|
||||
|
@ -299,9 +314,8 @@ def IsCrossBuild(target_os, arch):
|
|||
return ((GetArchFamily(host_arch) != GetArchFamily(arch)) or
|
||||
(target_os != GuessOS()))
|
||||
|
||||
|
||||
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
|
||||
def GetBuildConf(mode, arch, conf_os=None, use_nnbd=False):
|
||||
def GetBuildConf(mode, arch, conf_os=None, sanitizer=None, use_nnbd=False):
|
||||
nnbd = "NNBD" if use_nnbd else ""
|
||||
if conf_os == 'android':
|
||||
return '%s%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper(),
|
||||
|
@ -312,8 +326,8 @@ def GetBuildConf(mode, arch, conf_os=None, use_nnbd=False):
|
|||
cross_build = ''
|
||||
if GetArchFamily(host_arch) != GetArchFamily(arch):
|
||||
cross_build = 'X'
|
||||
return '%s%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper(),
|
||||
nnbd)
|
||||
return '%s%s%s%s%s' % (GetBuildMode(mode), GetBuildSanitizer(sanitizer),
|
||||
cross_build, arch.upper(), nnbd)
|
||||
|
||||
|
||||
def GetBuildDir(host_os):
|
||||
|
@ -321,11 +335,17 @@ def GetBuildDir(host_os):
|
|||
|
||||
|
||||
# TODO(38701): Remove use_nnbd once the forked NNBD SDK is merged back in.
|
||||
def GetBuildRoot(host_os, mode=None, arch=None, target_os=None, use_nnbd=False):
|
||||
def GetBuildRoot(host_os,
|
||||
mode=None,
|
||||
arch=None,
|
||||
target_os=None,
|
||||
sanitizer=None,
|
||||
use_nnbd=False):
|
||||
build_root = GetBuildDir(host_os)
|
||||
if mode:
|
||||
build_root = os.path.join(build_root,
|
||||
GetBuildConf(mode, arch, target_os, use_nnbd))
|
||||
build_root = os.path.join(
|
||||
build_root, GetBuildConf(mode, arch, target_os, sanitizer,
|
||||
use_nnbd))
|
||||
return build_root
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue