diff --git a/core/Makefile b/core/Makefile index c6c462191..bbb97edeb 100644 --- a/core/Makefile +++ b/core/Makefile @@ -4324,11 +4324,10 @@ $(SYMBOLS_ZIP): $(SOONG_ZIP) # ----------------------------------------------------------------- # A zip of the coverage directory. # -name := $(TARGET_PRODUCT) +name := gcov-report-files-all ifeq ($(TARGET_BUILD_TYPE),debug) name := $(name)_debug endif -name := $(name)-coverage-$(FILE_NAME_TAG) COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip ifndef TARGET_BUILD_APPS $(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \ diff --git a/core/definitions.mk b/core/definitions.mk index 5d3227a0a..512bbc43f 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1838,6 +1838,16 @@ define transform-host-o-to-executable $(transform-host-o-to-executable-inner) endef +########################################################### +## Commands for packaging native coverage files +########################################################### +define package-coverage-files + @rm -f $@ $@.lst $@.premerged + @touch $@.lst + $(foreach obj,$(strip $(PRIVATE_ALL_OBJECTS)), $(hide) echo $(obj) >> $@.lst$(newline)) + $(hide) $(SOONG_ZIP) -o $@.premerged -C $(OUT_DIR) -l $@.lst + $(hide) $(MERGE_ZIPS) -ignore-duplicates $@ $@.premerged $(strip $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) +endef ########################################################### ## Commands for running javac to make .class files diff --git a/core/executable_internal.mk b/core/executable_internal.mk index c28c144f6..558e49ba3 100644 --- a/core/executable_internal.mk +++ b/core/executable_internal.mk @@ -84,7 +84,7 @@ $(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries endif ifeq ($(my_native_coverage),true) -gcno_suffix := .gcnodir +gcno_suffix := .zip built_whole_gcno_libraries := \ $(foreach lib,$(my_whole_static_libraries), \ @@ -106,11 +106,11 @@ endif GCNO_ARCHIVE := $(my_installed_module_stem)$(gcno_suffix) +$(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS) $(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) + $(package-coverage-files) $(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE) $(copy-file-to-target) diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk index 44bb0203b..858884a43 100644 --- a/core/shared_library_internal.mk +++ b/core/shared_library_internal.mk @@ -77,7 +77,7 @@ $(linked_module): \ $(transform-o-to-shared-lib) ifeq ($(my_native_coverage),true) -gcno_suffix := .gcnodir +gcno_suffix := .zip built_whole_gcno_libraries := \ $(foreach lib,$(my_whole_static_libraries), \ @@ -99,11 +99,11 @@ endif GCNO_ARCHIVE := $(basename $(my_installed_module_stem))$(gcno_suffix) +$(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS) $(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) + $(package-coverage-files) $(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE) $(copy-file-to-target) diff --git a/core/soong_cc_prebuilt.mk b/core/soong_cc_prebuilt.mk index 55dd077b2..301f985d2 100644 --- a/core/soong_cc_prebuilt.mk +++ b/core/soong_cc_prebuilt.mk @@ -187,14 +187,14 @@ endif ifeq ($(NATIVE_COVERAGE),true) ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE))) - $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).gcnodir)) + $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).zip)) ifneq ($(LOCAL_UNINSTALLABLE_MODULE),true) 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 - my_coverage_path := $(my_coverage_path)/$(patsubst %.so,%,$(my_installed_module_stem)).gcnodir + my_coverage_path := $(my_coverage_path)/$(patsubst %.so,%,$(my_installed_module_stem)).zip $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path))) $(LOCAL_BUILT_MODULE): $(my_coverage_path) endif @@ -202,13 +202,12 @@ ifeq ($(NATIVE_COVERAGE),true) # Coverage information is needed when static lib is a dependency of another # coverage-enabled module. ifeq (STATIC_LIBRARIES, $(LOCAL_MODULE_CLASS)) - GCNO_ARCHIVE := $(LOCAL_MODULE).gcnodir + GCNO_ARCHIVE := $(LOCAL_MODULE).zip + $(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS) $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := - $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix) - $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) $(intermediates)/$(GCNO_ARCHIVE) : - $(transform-o-to-static-lib) + $(package-coverage-files) endif endif endif diff --git a/core/static_library_internal.mk b/core/static_library_internal.mk index 6b4d22f12..f82e50162 100644 --- a/core/static_library_internal.mk +++ b/core/static_library_internal.mk @@ -25,7 +25,7 @@ $(LOCAL_BUILT_MODULE) : $(all_objects) $(transform-o-to-static-lib) ifeq ($(NATIVE_COVERAGE),true) -gcno_suffix := .gcnodir +gcno_suffix := .zip built_whole_gcno_libraries := \ $(foreach lib,$(my_whole_static_libraries), \ @@ -35,11 +35,9 @@ built_whole_gcno_libraries := \ GCNO_ARCHIVE := $(LOCAL_MODULE)$(gcno_suffix) +$(intermediates)/$(GCNO_ARCHIVE) : $(SOONG_ZIP) $(MERGE_ZIPS) $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES)) $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) -$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix) -$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) -$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_INTERMEDIATES_DIR := $(intermediates) $(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) - $(transform-o-to-static-lib) + $(package-coverage-files) endif