summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2012-08-21 16:59:01 -0700
committerYing Wang <wangying@google.com>2012-08-22 12:11:01 -0700
commitaf4800c8a6a9266ceb7269bd2c6b0bb2f0965bea (patch)
tree571c67540d0168aa90f8eaa1fa1a3e378fc611e6 /core
parent4606449a53c1a802ea9db0059c08c95cb020376d (diff)
downloadbuild-af4800c8a6a9266ceb7269bd2c6b0bb2f0965bea.zip
build-af4800c8a6a9266ceb7269bd2c6b0bb2f0965bea.tar.gz
build-af4800c8a6a9266ceb7269bd2c6b0bb2f0965bea.tar.bz2
Support EMMA_INSTRUMENT in both full and unbundled builds.
Bug: 6987838 - With this change, use "EMMA_INSTRUMENT=true" to enable emma in full or unbundled build. - You don't need to add "LOCAL_STATIC_JAVA_LIBRARIES += emma" any more for unbundled apps. - Now a single var LOCAL_EMMA_INSTRUMENT replaces the previous LOCAL_NO_EMMA_INSTRUMENT and LOCAL_NO_EMMA_COMPILE. - By default, if EMMA_INSTRUMENT is true, emma is enabled for only non-test apps. - A new global var EMMA_INSTRUMENT_STATIC. It enables EMMA_INSTRUMENT and builds emma into apk/jar as static library, instead of using emma as part of shared library core.jar. Change-Id: I0aa219e83074879ececc159b5b07c39eb07ccc00
Diffstat (limited to 'core')
-rw-r--r--core/clear_vars.mk3
-rw-r--r--core/config.mk2
-rw-r--r--core/java.mk36
-rw-r--r--core/java_library.mk10
-rw-r--r--core/main.mk5
-rw-r--r--core/package.mk29
6 files changed, 48 insertions, 37 deletions
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index a564b3c..a389915 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -98,8 +98,7 @@ LOCAL_CERTIFICATE:=
LOCAL_SDK_VERSION:=
LOCAL_SDK_RES_VERSION:=
LOCAL_NDK_STL_VARIANT:=
-LOCAL_NO_EMMA_INSTRUMENT:=
-LOCAL_NO_EMMA_COMPILE:=
+LOCAL_EMMA_INSTRUMENT:=
LOCAL_PROGUARD_ENABLED:= # '',optonly,full,custom,disabled
LOCAL_PROGUARD_FLAGS:=
LOCAL_PROGUARD_FLAG_FILES:=
diff --git a/core/config.mk b/core/config.mk
index aa4e7f1..b35e55d 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -403,8 +403,6 @@ TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
# define llvm tools and global flags
include $(BUILD_SYSTEM)/llvm_config.mk
-PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)
-
# ###############################################################
# Collect a list of the SDK versions that we could compile against
# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
diff --git a/core/java.mk b/core/java.mk
index 4d85601..9e47dc3 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -75,29 +75,8 @@ endif
intermediates := $(call local-intermediates-dir)
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
-# Emma source code coverage
-ifeq ($(EMMA_FULL_APP_INSTRUMENT),true)
- # doing a full emma instrument here, i.e. all app packages instrumented
- EMMA_INSTRUMENT := true
- # do not instrument modules that are not app packages
- ifneq ($(LOCAL_MODULE_CLASS),APPS)
- LOCAL_NO_EMMA_INSTRUMENT := true
- LOCAL_NO_EMMA_COMPILE := true
- endif
- # do not instrument modules that are marked tests
- ifeq ($(LOCAL_MODULE_TAGS),tests)
- LOCAL_NO_EMMA_INSTRUMENT := true
- LOCAL_NO_EMMA_COMPILE := true
- endif
-endif
-
-ifneq ($(EMMA_INSTRUMENT),true)
-LOCAL_NO_EMMA_INSTRUMENT := true
-LOCAL_NO_EMMA_COMPILE := true
-endif
-
# Choose leaf name for the compiled jar file.
-ifneq ($(LOCAL_NO_EMMA_COMPILE),true)
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
full_classes_compiled_jar_leaf := classes-no-debug-var.jar
built_dex_intermediate_leaf := classes-no-local.dex
else
@@ -307,13 +286,7 @@ $(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
$(hide) $(ACP) -fp $< $@
endif
-ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
-# Skip adding emma instrumentation to class files if this is a static library,
-# since it will be instrumented by the package that includes it
-LOCAL_NO_EMMA_INSTRUMENT:= true
-endif
-
-ifneq ($(LOCAL_NO_EMMA_INSTRUMENT),true)
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
# module level coverage filter can be defined using LOCAL_EMMA_COVERAGE_FILTER
@@ -329,10 +302,7 @@ endif
# $(full_classes_emma_jar)
$(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(EMMA_JAR)
$(transform-classes.jar-to-emma)
-$(PRIVATE_EMMA_COVERAGE_FILE): $(full_classes_emma_jar)
-# tell proguard to load emma jar
-LOCAL_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS) $(addprefix -libraryjars ,$(EMMA_JAR))
else
$(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(ACP)
@echo Copying: $@
@@ -396,7 +366,7 @@ $(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
# The workaround here is to build different dex file here based on emma switch
# then later copy into classes.dex. When emma is on, dx is run with --no-locals
# option to remove local variable information
-ifneq ($(LOCAL_NO_EMMA_COMPILE),true)
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
$(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals
endif
$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX)
diff --git a/core/java_library.mk b/core/java_library.mk
index 06cdfc4..03e069d 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -44,6 +44,16 @@ ifeq (false,$(LOCAL_DEX_PREOPT))
LOCAL_DEX_PREOPT :=
endif
+ifeq (true,$(EMMA_INSTRUMENT))
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+endif # LOCAL_EMMA_INSTRUMENT
+endif # EMMA_INSTRUMENT_STATIC
+else
+LOCAL_EMMA_INSTRUMENT := false
+endif # EMMA_INSTRUMENT
+
#################################
include $(BUILD_SYSTEM)/java.mk
#################################
diff --git a/core/main.mk b/core/main.mk
index def9f62..eda80ed 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -218,6 +218,11 @@ ENABLE_INCREMENTALJAVAC := true
MAKECMDGOALS := $(filter-out incrementaljavac, $(MAKECMDGOALS))
endif
+# EMMA_INSTRUMENT_STATIC merges the static emma library to each emma-enabled module.
+ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+EMMA_INSTRUMENT := true
+endif
+
# Bring in standard build system definitions.
include $(BUILD_SYSTEM)/definitions.mk
diff --git a/core/package.mk b/core/package.mk
index a1d901e..c181ae4 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -170,6 +170,35 @@ ifeq (false,$(LOCAL_DEX_PREOPT))
LOCAL_DEX_PREOPT :=
endif
+ifeq (true,$(EMMA_INSTRUMENT))
+ifndef LOCAL_EMMA_INSTRUMENT
+# No emma for test apks.
+ifeq (,$(filer tests,$(LOCAL_MODULE_TAGS))$(LOCAL_INSTRUMENTATION_FOR))
+LOCAL_EMMA_INSTRUMENT := true
+endif # No test apk
+endif # LOCAL_EMMA_INSTRUMENT is not set
+else
+LOCAL_EMMA_INSTRUMENT := false
+endif # EMMA_INSTRUMENT is true
+
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+else
+ifdef LOCAL_SDK_VERSION
+ifdef TARGET_BUILD_APPS
+# In unbundled build merge the emma library into the apk.
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+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;
+# Otherwise emma classes are included in core.jar.
+LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR)
+endif # full build
+endif # LOCAL_SDK_VERSION
+endif # EMMA_INSTRUMENT_STATIC
+endif # LOCAL_EMMA_INSTRUMENT
+
#################################
include $(BUILD_SYSTEM)/java.mk
#################################