blob: 9b0b528600f0e963ceb7fb1207af3e2ce6a83b90 [file] [log] [blame]
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08001# -----------------------------------------------------------------
2# Make target for line coverage. This target generates a zip file
3# called `line_coverage_profiles.zip` that contains a large set of
4# zip files one for each fuzz target/critical component. Each zip
5# file contains a set of profile files (*.gcno) that we will use
6# to generate line coverage reports. Furthermore, target compiles
7# all fuzz targets with line coverage instrumentation enabled and
8# packs them into another zip file called `line_coverage_profiles.zip`.
9#
10# To run the make target set the coverage related envvars first:
11# NATIVE_LINE_COVERAGE=true NATIVE_COVERAGE=true \
12# COVERAGE_PATHS=* make haiku-line-coverage
13# -----------------------------------------------------------------
14
15# TODO(b/148306195): Due this issue some fuzz targets cannot be built with
16# line coverage instrumentation. For now we just blacklist them.
17blacklisted_fuzz_targets := libneuralnetworks_fuzzer
18
19fuzz_targets := $(ALL_FUZZ_TARGETS)
20fuzz_targets := $(filter-out $(blacklisted_fuzz_targets),$(fuzz_targets))
21
22
23# Android components that considered critical.
24# Please note that adding/Removing critical components is very rare.
25critical_components_static := \
26 lib-bt-packets \
27 libbt-stack \
28 libffi \
29 libhevcdec \
30 libhevcenc \
31 libmpeg2dec \
32 libosi \
33 libpdx \
34 libselinux \
35 libvold \
36 libyuv
37
Jiyong Park157ac242020-05-01 11:21:40 +090038# Format is <module_name> or <module_name>:<apex_name>
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -080039critical_components_shared := \
40 libaudioprocessing \
41 libbinder \
42 libbluetooth_gd \
43 libbrillo \
44 libcameraservice \
45 libcurl \
46 libhardware \
47 libinputflinger \
48 libopus \
49 libstagefright \
50 libunwind \
Jiyong Park157ac242020-05-01 11:21:40 +090051 libvixl:com.android.art.debug
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -080052
53# Use the intermediates directory to avoid installing libraries to the device.
54intermediates := $(call intermediates-dir-for,PACKAGING,haiku-line-coverage)
55
56
57# We want the profile files for all fuzz targets + critical components.
58line_coverage_profiles := $(intermediates)/line_coverage_profiles.zip
59
60critical_components_static_inputs := $(foreach lib,$(critical_components_static), \
61 $(call intermediates-dir-for,STATIC_LIBRARIES,$(lib))/$(lib).a)
62
63critical_components_shared_inputs := $(foreach lib,$(critical_components_shared), \
Jiyong Park157ac242020-05-01 11:21:40 +090064 $(eval filename := $(call word-colon,1,$(lib))) \
65 $(eval modulename := $(subst :,.,$(lib))) \
66 $(call intermediates-dir-for,SHARED_LIBRARIES,$(modulename))/$(filename).so)
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -080067
68fuzz_target_inputs := $(foreach fuzz,$(fuzz_targets), \
69 $(call intermediates-dir-for,EXECUTABLES,$(fuzz))/$(fuzz))
70
71# When line coverage is enabled (NATIVE_LINE_COVERAGE is set), make creates
72# a "coverage" directory and stores all profile (*.gcno) files in inside.
73# We need everything that is stored inside this directory.
74$(line_coverage_profiles): $(fuzz_target_inputs)
75$(line_coverage_profiles): $(critical_components_static_inputs)
76$(line_coverage_profiles): $(critical_components_shared_inputs)
77$(line_coverage_profiles): $(SOONG_ZIP)
78 $(SOONG_ZIP) -o $@ -D $(PRODUCT_OUT)/coverage
79
80
81# Zip all fuzz targets compiled with line coverage.
82line_coverage_fuzz_targets := $(intermediates)/line_coverage_fuzz_targets.zip
83
84$(line_coverage_fuzz_targets): $(fuzz_target_inputs)
85$(line_coverage_fuzz_targets): $(SOONG_ZIP)
86 $(SOONG_ZIP) -o $@ -j $(addprefix -f ,$(fuzz_target_inputs))
87
88
89.PHONY: haiku-line-coverage
90haiku-line-coverage: $(line_coverage_profiles) $(line_coverage_fuzz_targets)
91$(call dist-for-goals, haiku-line-coverage, \
92 $(line_coverage_profiles):line_coverage_profiles.zip \
93 $(line_coverage_fuzz_targets):line_coverage_fuzz_targets.zip)
94
95line_coverage_profiles :=
96line_coverage_fuzz_targets :=