Merge "Fix code coverage for apps" into nyc-dev

This commit is contained in:
Sebastien Hertz
2016-04-05 07:11:48 +00:00
committed by Android (Google) Code Review

View File

@@ -241,21 +241,34 @@ endif # LOCAL_JACK_ENABLED
else
ifdef LOCAL_SDK_VERSION
ifdef TARGET_BUILD_APPS
# In unbundled build merge the emma library into the apk.
# In unbundled build, merge the coverage library into the apk.
ifdef LOCAL_JACK_ENABLED
# Jack supports coverage with Jacoco
ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
# Only add jacocoagent if the package contains some java code
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
# Exclude jacoco classes from proguard
LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
LOCAL_JACK_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
endif # Contains java code
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;
# If build against the SDK in full build, core.jar is not used
# so coverage classes are not present.
ifdef LOCAL_JACK_ENABLED
# Jack needs jacoco on the classpath but we do not want it to be in
# the final apk. While it is a static library, we add it to the
# LOCAL_JAVA_LIBRARIES which are only present on the classpath.
# Note: we have nothing to do for proguard since jacoco will be
# on the classpath only, thus not modified during the compilation.
LOCAL_JAVA_LIBRARIES += jacocoagent
else
# We have to use prebuilt emma.jar to make Proguard happy;
# Otherwise emma classes are included in core.jar.
LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR)
endif # LOCAL_JACK_ENABLED
endif # full build
endif # LOCAL_SDK_VERSION
endif # EMMA_INSTRUMENT_STATIC