Merge "Support code coverage with Jack"

This commit is contained in:
Sebastien Hertz 2016-02-02 07:31:37 +00:00 committed by Gerrit Code Review
commit 4dad88980f
6 changed files with 42 additions and 0 deletions

View file

@ -1979,6 +1979,7 @@ else \
fi; \
$(call call-jack) \
$(strip $(PRIVATE_JACK_FLAGS)) \
$(strip $(PRIVATE_JACK_COVERAGE_OPTIONS)) \
$(if $(NO_OPTIMIZE_DX), \
-D jack.dex.optimize="false") \
$(if $(PRIVATE_RMTYPEDEFS), \

View file

@ -496,7 +496,11 @@ common_proguard_flags := \
ifeq ($(filter nosystem,$(LOCAL_PROGUARD_ENABLED)),)
common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.flags
ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
ifdef LOCAL_JACK_ENABLED
common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
else
common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.emma.flags
endif # LOCAL_JACK_ENABLED
endif
# If this is a test package, add proguard keep flags for tests.
ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
@ -667,6 +671,15 @@ $(built_dex).toc: $(full_classes_jack)
else #LOCAL_IS_STATIC_JAVA_LIBRARY
$(built_dex_intermediate): PRIVATE_CLASSES_JACK := $(full_classes_jack)
ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
$(built_dex_intermediate): PRIVATE_JACK_COVERAGE_OPTIONS := \
-D jack.coverage="true" \
-D jack.coverage.metadata.file=$(intermediates.COMMON)/coverage.em \
-D jack.coverage.jacoco.package=$(JACOCO_PACKAGE_NAME)
else
$(built_dex_intermediate): PRIVATE_JACK_COVERAGE_OPTIONS :=
endif
$(built_dex_intermediate): $(jack_all_deps) | setup-jack-server
@echo Building with Jack: $@
$(jack-java-to-dex)

View file

@ -47,7 +47,12 @@ endif
ifeq (true,$(EMMA_INSTRUMENT))
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
ifdef LOCAL_JACK_ENABLED
# Jack supports coverage with Jacoco
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
else
LOCAL_STATIC_JAVA_LIBRARIES += emma
endif # LOCAL_JACK_ENABLED
endif # LOCAL_EMMA_INSTRUMENT
endif # EMMA_INSTRUMENT_STATIC
else

View file

@ -334,6 +334,11 @@ include build/core/pdk_config.mk
# Install and start Jack server
-include $(TOPDIR)prebuilts/sdk/tools/jack_server_setup.mk
#
# -----------------------------------------------------------------
# Jacoco package name for Jack
-include $(TOPDIR)external/jacoco/config.mk
# -----------------------------------------------------------------
###
### In this section we set up the things that are different

View file

@ -186,12 +186,22 @@ endif # EMMA_INSTRUMENT is true
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
ifdef LOCAL_JACK_ENABLED
# Jack supports coverage with Jacoco
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
else
LOCAL_STATIC_JAVA_LIBRARIES += emma
endif # LOCAL_JACK_ENABLED
else
ifdef LOCAL_SDK_VERSION
ifdef TARGET_BUILD_APPS
# In unbundled build merge the emma library into the apk.
ifdef LOCAL_JACK_ENABLED
# Jack supports coverage with Jacoco
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
else
LOCAL_STATIC_JAVA_LIBRARIES += emma
endif # LOCAL_JACK_ENABLED
else
# If build against the SDK in full build, core.jar is not used,
# we have to use prebiult emma.jar to make Proguard happy;

View file

@ -0,0 +1,8 @@
# Keep everything for the emma classes
-keep class com.vladium.** {
*;
}
# Keep everything for the jacoco classes
-keep class org.jacoco.** {
*;
}