[build] Add gcov coverage to GN configs

This prepares switching the gcov coverage bot to GN.

We skip instrumenting test executables explicitly in gn configs.
In gyp, we did the same through an extra compiler wrapper script.

NOTRY=true

Bug: chromium:645890
Change-Id: I663fb479347063ae9228598d356bb654ca2a496c
Reviewed-on: https://chromium-review.googlesource.com/548275
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46217}
This commit is contained in:
Michael Achenbach 2017-06-26 13:06:03 +02:00 committed by Commit Bot
parent bdf1b0a84a
commit 1ec6671f32
3 changed files with 34 additions and 1 deletions

View File

@ -21,6 +21,9 @@ declare_args() {
# Print to stdout on Android.
v8_android_log_stdout = false
# Set flags for tracking code coverage with gcov. Requires is_clang=false.
v8_code_coverage = false
# Sets -DV8_ENABLE_FUTURE.
v8_enable_future = false
@ -508,6 +511,27 @@ config("toolchain") {
}
}
# Configs for code coverage with gcov. Separate configs for cflags and ldflags
# to selectively influde cflags in non-test targets only.
config("v8_code_coverage_cflags") {
# Make sure we're using gcc toolchain.
if (v8_code_coverage) {
assert(!is_clang)
cflags = [
"-fprofile-arcs",
"-ftest-coverage",
]
}
}
config("v8_code_coverage_ldflags") {
# Make sure we're using gcc toolchain.
if (v8_code_coverage) {
assert(!is_clang)
ldflags = [ "-fprofile-arcs" ]
}
}
###############################################################################
# Actions
#

View File

@ -68,6 +68,7 @@ v8_remove_configs = []
v8_add_configs = [
v8_path_prefix + ":features",
v8_path_prefix + ":toolchain",
v8_path_prefix + ":v8_code_coverage_ldflags",
]
if (is_debug && !v8_optimized_debug) {
@ -105,6 +106,7 @@ template("v8_source_set") {
configs += invoker.configs
configs -= v8_remove_configs
configs += v8_add_configs
configs += [ v8_path_prefix + ":v8_code_coverage_cflags" ]
}
}
@ -114,6 +116,7 @@ template("v8_header_set") {
configs += invoker.configs
configs -= v8_remove_configs
configs += v8_add_configs
configs += [ v8_path_prefix + ":v8_code_coverage_cflags" ]
}
}
@ -135,6 +138,11 @@ template("v8_executable") {
# For enabling ASLR.
ldflags = [ "-pie" ]
}
if (!defined(testonly) || !testonly) {
# Only add code coverage cflags for non-test files for performance
# reasons.
configs += [ v8_path_prefix + ":v8_code_coverage_cflags" ]
}
}
}
@ -144,5 +152,6 @@ template("v8_component") {
configs += invoker.configs
configs -= v8_remove_configs
configs += v8_add_configs
configs += [ v8_path_prefix + ":v8_code_coverage_cflags" ]
}
}

View File

@ -545,7 +545,7 @@
},
'coverage': {
# TODO(machenbach): Add this to gn.
'gn_args': 'v8_code_coverage=true',
'gyp_defines': 'coverage=1',
},