From 3fec81d9780275fa2ab832cf1bd22329f74d8b70 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 22 Nov 2017 16:04:55 -0800 Subject: [PATCH] Add support for jacoco in soong Use jacoco values exported from soong and copy jacoco-report-classes.jar to where the jacoco-report-classes-all.jar rule can find it. Bug: 69629238 Test: m EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true SKIP_BOOT_JARS_CHECK=true WITH_DEXPREOPT=false Change-Id: If05381f415fb52a575746b8be0bfcd03d55b2153 --- core/clear_vars.mk | 3 +++ core/config.mk | 1 - core/jacoco.mk | 1 - core/soong_java_prebuilt.mk | 16 ++++++---------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 36a4ae9bb2..99bd691704 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -226,6 +226,9 @@ LOCAL_SDK_RES_VERSION:= LOCAL_SDK_VERSION:= LOCAL_SHARED_ANDROID_LIBRARIES:= LOCAL_SHARED_LIBRARIES:= +LOCAL_SOONG_HEADER_JAR := +LOCAL_SOONG_DEX_JAR := +LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR := # '',true LOCAL_SOURCE_FILES_ALL_GENERATED:= LOCAL_SRC_FILES:= diff --git a/core/config.mk b/core/config.mk index 1994899443..024e35ded1 100644 --- a/core/config.mk +++ b/core/config.mk @@ -658,7 +658,6 @@ RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin FINDBUGS := $(FINDBUGS_DIR)/findbugs -JACOCO_CLI_JAR := $(HOST_OUT_JAVA_LIBRARIES)/jacoco-cli$(COMMON_JAVA_PACKAGE_SUFFIX) # Tool to merge AndroidManifest.xmls ANDROID_MANIFEST_MERGER := $(JAVA) -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge diff --git a/core/jacoco.mk b/core/jacoco.mk index 74d84f44d2..f51790d640 100644 --- a/core/jacoco.mk +++ b/core/jacoco.mk @@ -21,7 +21,6 @@ # determine Jacoco include/exclude filters even when coverage is not enabled # to get syntax checking on LOCAL_JACK_COVERAGE_(INCLUDE|EXCLUDE)_FILTER -DEFAULT_JACOCO_EXCLUDE_FILTER := org/junit/*,org/jacoco/*,org/mockito/* # copy filters from Jack but also skip some known java packages my_include_filter := $(strip $(LOCAL_JACK_COVERAGE_INCLUDE_FILTER)) my_exclude_filter := $(strip $(DEFAULT_JACOCO_EXCLUDE_FILTER),$(LOCAL_JACK_COVERAGE_EXCLUDE_FILTER)) diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk index 53ad50ddab..ccbe745d0a 100644 --- a/core/soong_java_prebuilt.mk +++ b/core/soong_java_prebuilt.mk @@ -2,6 +2,7 @@ # Extra inputs: # LOCAL_SOONG_HEADER_JAR # LOCAL_SOONG_DEX_JAR +# LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) $(call pretty-error,soong_java_prebuilt.mk may only be used from Soong) @@ -18,13 +19,12 @@ full_classes_jar := $(intermediates.COMMON)/classes.jar full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar common_javalib.jar := $(intermediates.COMMON)/javalib.jar -LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(LOCAL_PREBUILT_MODULE_FILE) +$(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(full_classes_jar))) -####################################### -include $(BUILD_SYSTEM)/jacoco.mk -####################################### - -$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_jar))) +ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR + $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\ + $(intermediates.COMMON)/jacoco-report-classes.jar)) +endif ifneq ($(TURBINE_DISABLED),false) ifdef LOCAL_SOONG_HEADER_JAR @@ -94,7 +94,3 @@ my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) my_common := COMMON include $(BUILD_SYSTEM)/link_type.mk endif # !LOCAL_IS_HOST_MODULE - -# Built in equivalent to include $(CLEAR_VARS) -LOCAL_SOONG_HEADER_JAR := -LOCAL_SOONG_DEX_JAR :=