summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dan Willemsen <dwillemsen@google.com> 2017-02-10 00:07:17 -0800
committer Dan Willemsen <dwillemsen@google.com> 2017-02-10 09:27:35 -0800
commit0f90908026b13ab465c327f99d1ac1c50d28d80e (patch)
tree36098b2d9de880aebbabf7b5767aad9774cea7e2
parentaf055f207ac41334fda9ff53e80f35a653e4dd7c (diff)
Support Soong native coverage
Soong (or any other prebuilt) can provide a .gcnodir file using LOCAL_PREBUILT_COVERAGE_ARCHIVE. Just like today, if one isn't provided for static libraries, an empty one will be created for Make modules to use. Also fixes a problem I noticed including whole static libs having coverage into static libs. It was trying to write to /WHOLE since PRIVATE_INTERMEDIATES_DIR was not set. Bug: 32749731 Test: See build/soong change for soong-side tests Test: Enabled coverage of a soong static lib, then include it in a make static lib with LOCAL_WHOLE_STATIC_LIBRARIES and ensure that the any shared libraries using the make static lib get the embedded coverage information. Change-Id: I32762f099c9757074fec922ee4822f819c9ceaf5
-rw-r--r--core/clear_vars.mk1
-rw-r--r--core/prebuilt_internal.mk14
-rw-r--r--core/shared_library_internal.mk1
-rw-r--r--core/soong_config.mk3
-rw-r--r--core/static_library_internal.mk1
5 files changed, 20 insertions, 0 deletions
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index bae38c5b43..614a7ca5e5 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -164,6 +164,7 @@ LOCAL_PACK_MODULE_RELOCATIONS:=
LOCAL_PICKUP_FILES:=
LOCAL_POST_INSTALL_CMD:=
LOCAL_POST_LINK_CMD:=
+LOCAL_PREBUILT_COVERAGE_ARCHIVE:=
LOCAL_PREBUILT_EXECUTABLES:=
LOCAL_PREBUILT_JAVA_LIBRARIES:=
LOCAL_PREBUILT_JNI_LIBS:=
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 10512ff327..997f97161f 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -174,6 +174,19 @@ endif
endif # my_strip_module not true
ifeq ($(NATIVE_COVERAGE),true)
+ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE)))
+ $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).gcnodir))
+ 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)/$(basename $(my_installed_module_stem)).gcnodir
+ $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path)))
+ $(LOCAL_BUILT_MODULE): $(my_coverage_path)
+ endif
+else
# Coverage information is needed when static lib is a dependency of another
# coverage-enabled module.
ifeq (STATIC_LIBRARIES, $(LOCAL_MODULE_CLASS))
@@ -186,6 +199,7 @@ $(intermediates)/$(GCNO_ARCHIVE) :
$(transform-o-to-static-lib)
endif
endif
+endif
ifeq ($(LOCAL_MODULE_CLASS),APPS)
PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk
index 6b914c98d2..1ea4cb8989 100644
--- a/core/shared_library_internal.mk
+++ b/core/shared_library_internal.mk
@@ -96,6 +96,7 @@ GCNO_ARCHIVE := $(basename $(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)
diff --git a/core/soong_config.mk b/core/soong_config.mk
index ad2f204391..c038a32255 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -43,6 +43,9 @@ $(SOONG_VARIABLES): FORCE
echo ' "ClangTidy": $(if $(filter 1 true,$(WITH_TIDY)),true,false),'; \
echo ' "TidyChecks": "$(WITH_TIDY_CHECKS)",'; \
echo ''; \
+ echo ' "NativeCoverage": $(if $(filter true,$(NATIVE_COVERAGE)),true,false),'; \
+ echo ' "CoveragePaths": [$(if $(COVERAGE_PATHS),"$(subst $(space),"$(comma)",$(subst $(comma),$(space),$(COVERAGE_PATHS)))")],'; \
+ echo ''; \
echo ' "DeviceName": "$(TARGET_DEVICE)",'; \
echo ' "DeviceArch": "$(TARGET_ARCH)",'; \
echo ' "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \
diff --git a/core/static_library_internal.mk b/core/static_library_internal.mk
index 6133ea2a7f..6b4d22f129 100644
--- a/core/static_library_internal.mk
+++ b/core/static_library_internal.mk
@@ -39,6 +39,7 @@ $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_F
$(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)
endif