From 14827f2a986b69093fe35f41d59c0bd070e6c10c Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Tue, 7 Nov 2017 09:50:59 -0800 Subject: [PATCH] Support gcno packaging for executables. Adapt the gcno packaging logic from shared_library_internal.mk for the case of executable binaries so that gcov artifacts are properly packaged. Test: lunch walleye_coverage-userdebug && make -j60 Bug: 67998360 Change-Id: I4994fc21521c91d4c18bdf326be079beda1914a4 --- core/executable_internal.mk | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/core/executable_internal.mk b/core/executable_internal.mk index 3509bd2cb..0aec27555 100644 --- a/core/executable_internal.mk +++ b/core/executable_internal.mk @@ -76,4 +76,39 @@ $(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries $(PRIVATE_POST_LINK_CMD) endif +ifeq ($(my_native_coverage),true) +gcno_suffix := .gcnodir + +built_whole_gcno_libraries := \ + $(foreach lib,$(my_whole_static_libraries), \ + $(call intermediates-dir-for, \ + STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ + $(my_host_cross))/$(lib)$(gcno_suffix)) + +built_static_gcno_libraries := \ + $(foreach lib,$(my_static_libraries), \ + $(call intermediates-dir-for, \ + STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \ + $(my_host_cross))/$(lib)$(gcno_suffix)) + +ifdef LOCAL_IS_HOST_MODULE +my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path)) +else +my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) +endif + +GCNO_ARCHIVE := $(my_installed_module_stem)$(gcno_suffix) + +$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES)) +$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries)) +$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_INTERMEDIATES_DIR := $(intermediates) +$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries) + $(transform-o-to-static-lib) + +$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE) + $(copy-file-to-target) + +$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE) +endif + endif # skip_build_from_source