xref: /aosp_15_r20/external/angle/build/config/coverage/coverage.gni (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2017 The Chromium Authors
2*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
3*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file.
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard Workerimport("//build/toolchain/toolchain.gni")
6*8975f5c5SAndroid Build Coastguard Workerif (is_fuchsia) {
7*8975f5c5SAndroid Build Coastguard Worker  import("//third_party/fuchsia-gn-sdk/src/component.gni")
8*8975f5c5SAndroid Build Coastguard Worker}
9*8975f5c5SAndroid Build Coastguard Worker
10*8975f5c5SAndroid Build Coastguard Worker# There are two ways to enable code coverage instrumentation:
11*8975f5c5SAndroid Build Coastguard Worker# 1. When |use_clang_coverage| or |use_jacoco_coverage| is true and
12*8975f5c5SAndroid Build Coastguard Worker#    |coverage_instrumentation_input_file| is empty, all source files or
13*8975f5c5SAndroid Build Coastguard Worker#    Java class files are instrumented.
14*8975f5c5SAndroid Build Coastguard Worker# 2. When |use_clang_coverage| or |use_jacoco_coverage| is true and
15*8975f5c5SAndroid Build Coastguard Worker#    |coverage_instrumentation_input_file| is NOT empty and points to
16*8975f5c5SAndroid Build Coastguard Worker#    a text file on the file system, ONLY source files specified in the
17*8975f5c5SAndroid Build Coastguard Worker#    input file or Java class files related to source files are instrumented.
18*8975f5c5SAndroid Build Coastguard Workerdeclare_args() {
19*8975f5c5SAndroid Build Coastguard Worker  # Enable Clang's Source-based Code Coverage.
20*8975f5c5SAndroid Build Coastguard Worker  if (is_fuchsia) {
21*8975f5c5SAndroid Build Coastguard Worker    use_clang_coverage = fuchsia_code_coverage
22*8975f5c5SAndroid Build Coastguard Worker  } else {
23*8975f5c5SAndroid Build Coastguard Worker    use_clang_coverage = false
24*8975f5c5SAndroid Build Coastguard Worker  }
25*8975f5c5SAndroid Build Coastguard Worker
26*8975f5c5SAndroid Build Coastguard Worker  # Enables JaCoCo Java code coverage.
27*8975f5c5SAndroid Build Coastguard Worker  use_jacoco_coverage = false
28*8975f5c5SAndroid Build Coastguard Worker
29*8975f5c5SAndroid Build Coastguard Worker  # The path to the coverage instrumentation input file should be a source root
30*8975f5c5SAndroid Build Coastguard Worker  # absolute path (e.g. //out/Release/coverage_instrumentation_input.txt), and
31*8975f5c5SAndroid Build Coastguard Worker  # the file consists of multiple lines where each line represents a path to a
32*8975f5c5SAndroid Build Coastguard Worker  # source file, and the paths must be relative to the root build directory.
33*8975f5c5SAndroid Build Coastguard Worker  # e.g. ../../base/task/post_task.cc for build directory 'out/Release'.
34*8975f5c5SAndroid Build Coastguard Worker  #
35*8975f5c5SAndroid Build Coastguard Worker  # NOTE that this arg will be non-op if use_clang_coverage is false.
36*8975f5c5SAndroid Build Coastguard Worker  coverage_instrumentation_input_file = ""
37*8975f5c5SAndroid Build Coastguard Worker
38*8975f5c5SAndroid Build Coastguard Worker  # Enables TypeScript/JavaScript code coverage.
39*8975f5c5SAndroid Build Coastguard Worker  use_javascript_coverage = false
40*8975f5c5SAndroid Build Coastguard Worker}
41*8975f5c5SAndroid Build Coastguard Worker
42*8975f5c5SAndroid Build Coastguard Workerassert(!use_clang_coverage || is_clang,
43*8975f5c5SAndroid Build Coastguard Worker       "Clang Source-based Code Coverage requires clang.")
44