Support code coverage with Jack

Building an app with Jack and with the environment variable
EMMA_INSTRUMENT_STATIC set to true will apply code coverage
onto the app targeting Jacoco.

Bug: 20115492
Change-Id: Ief3640fa3faa466f7f6aaa9739e06d3db24110a0
This commit is contained in:
Sebastien Hertz
2015-11-19 17:53:00 +01:00
parent 3e2f5d83a4
commit dfce8ad4f4
6 changed files with 42 additions and 0 deletions

View File

@@ -495,7 +495,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)),)
@@ -666,6 +670,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)