Implement path-based enabling of code coverage.
Native coverage is enabled by setting NATIVE_COVERAGE to true
and specifying a list of paths in the COVERAGE_PATHS
environment variable. Files are exported to a zip file in the
target out directory.
Change-Id: I66a2ddd88e849bec1cc0cdae1b51fe18a007e2c3
diff --git a/core/binary.mk b/core/binary.mk
index 21a6019..3d51371 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -54,10 +54,15 @@
my_cxx_wrapper := $(CXX_WRAPPER)
my_c_includes := $(LOCAL_C_INCLUDES)
my_generated_sources := $(LOCAL_GENERATED_SOURCES)
-my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
+ifneq (,$(foreach dir,$(COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH))))
+ my_native_coverage := true
+else
+ my_native_coverage := false
+endif
+
ifdef LOCAL_IS_HOST_MODULE
my_allow_undefined_symbols := true
else
@@ -1769,3 +1774,11 @@
$(my_system_shared_libraries)
SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE)
endif
+
+###########################################################
+# Coverage packaging.
+###########################################################
+ifeq ($(my_native_coverage),true)
+LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(all_objects))
+$(foreach f,$(all_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno))))
+endif