mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 17:59:39 +00:00
[ VM / Testing ] Add build flags to enable code coverage
Change-Id: I37e945f842932b1ac1d87444e4fec2eb752f312f Reviewed-on: https://dart-review.googlesource.com/c/79465 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Zach Anderson <zra@google.com> Auto-Submit: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
6066ac83e3
commit
445a43b58d
|
@ -165,13 +165,20 @@ config("dart_config") {
|
|||
"-fno-exceptions",
|
||||
]
|
||||
|
||||
if (dart_debug) {
|
||||
ldflags = []
|
||||
if (is_clang && dart_vm_code_coverage) {
|
||||
cflags += [
|
||||
"-O0",
|
||||
"-fprofile-arcs",
|
||||
"-ftest-coverage",
|
||||
]
|
||||
ldflags += [ "--coverage" ]
|
||||
} else if (dart_debug) {
|
||||
cflags += [ "-O${dart_debug_optimization_level}" ]
|
||||
} else {
|
||||
cflags += [ "-O3" ]
|
||||
}
|
||||
|
||||
ldflags = []
|
||||
if (defined(is_asan) && is_asan) {
|
||||
ldflags += [ "-fsanitize=address" ]
|
||||
}
|
||||
|
|
|
@ -31,9 +31,13 @@ declare_args() {
|
|||
# Available options are: arm, arm64, x64, ia32, and dbc.
|
||||
dart_target_arch = target_cpu
|
||||
|
||||
# The optimization level to use for debug builds.
|
||||
# The optimization level to use for debug builds. Defaults to 0 for builds with
|
||||
# code coverage enabled.
|
||||
dart_debug_optimization_level = "2"
|
||||
|
||||
# Whether to enable code coverage for the standalone VM.
|
||||
dart_vm_code_coverage = false
|
||||
|
||||
# Whether to fall back to built-in root certificates when they cannot be
|
||||
# verified at the operating system level.
|
||||
dart_use_fallback_root_certificates = false
|
||||
|
|
14
tools/gn.py
14
tools/gn.py
|
@ -230,6 +230,9 @@ def ToGnArgs(args, mode, arch, target_os):
|
|||
gn_args['target_cpu'])
|
||||
gn_args['is_clang'] = args.clang and not dont_use_clang
|
||||
|
||||
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 and gn_args['is_clang']
|
||||
gn_args['is_msan'] = args.msan and gn_args['is_clang']
|
||||
gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
|
||||
|
@ -262,7 +265,11 @@ def ToGnArgs(args, mode, arch, target_os):
|
|||
gn_args['use_goma'] = False
|
||||
gn_args['goma_dir'] = None
|
||||
|
||||
if args.debug_opt_level:
|
||||
# Code coverage requires -O0 to be set.
|
||||
if enable_code_coverage:
|
||||
gn_args['dart_debug_optimization_level'] = 0
|
||||
gn_args['debug_optimization_level'] = 0
|
||||
elif args.debug_opt_level:
|
||||
gn_args['dart_debug_optimization_level'] = args.debug_opt_level
|
||||
gn_args['debug_optimization_level'] = args.debug_opt_level
|
||||
|
||||
|
@ -384,6 +391,11 @@ def parse_args(args):
|
|||
help='Disable Clang',
|
||||
dest='clang',
|
||||
action='store_false')
|
||||
other_group.add_argument('--code-coverage',
|
||||
help='Enable code coverage for the standalone VM',
|
||||
default=False,
|
||||
dest="code_coverage",
|
||||
action='store_true')
|
||||
other_group.add_argument('--debug-opt-level',
|
||||
'-d',
|
||||
help='The optimization level to use for debug builds',
|
||||
|
|
Loading…
Reference in a new issue