am 71e8a22e: Merge "Add DEXPREOPT support for ART"

* commit '71e8a22e3478b6b4277957ef47486058a5306286':
  Add DEXPREOPT support for ART
This commit is contained in:
Ying Wang 2013-12-17 16:58:43 -08:00 committed by Android Git Automerger
commit 82c59aefcd
16 changed files with 357 additions and 143 deletions

View file

@ -535,15 +535,6 @@ $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
$(copy-file-to-target-with-cp)
endif
ifdef LOCAL_DEX_PREOPT
installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
$(installed_odex) : $(built_odex) $(LOCAL_BUILT_MODULE) | $(ACP)
@echo "Install: $@"
$(copy-file-to-target)
$(LOCAL_INSTALLED_MODULE) : $(installed_odex)
endif
endif # !LOCAL_UNINSTALLABLE_MODULE

View file

@ -119,6 +119,7 @@ LOCAL_RENDERSCRIPT_SKIP_INSTALL:=
LOCAL_RENDERSCRIPT_TARGET_API:=
LOCAL_BUILD_HOST_DEX:=
LOCAL_DEX_PREOPT:= # '',true,false,nostripping
LOCAL_DEX_PREOPT_IMAGE:=
LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,nano,full
LOCAL_PROTOC_FLAGS:=
LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=

View file

@ -364,8 +364,6 @@ PROGUARD := external/proguard/bin/proguard.sh
JAVATAGS := build/tools/java-event-log-tags.py
LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc$(HOST_EXECUTABLE_SUFFIX)
BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat$(HOST_EXECUTABLE_SUFFIX)
DEXOPT := $(HOST_OUT_EXECUTABLES)/dexopt$(HOST_EXECUTABLE_SUFFIX)
DEXPREOPT := dalvik/tools/dex-preopt
LINT := prebuilts/sdk/tools/lint
# ACP is always for the build OS, not for the host OS

View file

@ -1,89 +1,72 @@
####################################
# Dexpreopt on the boot jars
# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
#
####################################
ifeq ($(DALVIK_VM_LIB),)
$(error No value for DALVIK_VM_LIB)
endif
# list of boot classpath jars for dexpreopt
DEXPREOPT_BOOT_JARS := $(PRODUCT_BOOT_JARS)
DEXPREOPT_BOOT_JARS_MODULES := $(subst :, ,$(DEXPREOPT_BOOT_JARS))
PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
DEXPREOPT_BUILD_DIR := $(OUT_DIR)
DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(PRODUCT_OUT))/dex_bootjars
DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars
DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH))
DEXPREOPT_BOOT_JAR_DIR := system/framework
DEXPREOPT_DEXOPT := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXOPT))
DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_BUILD_DIR)/$(DEXPREOPT_PRODUCT_DIR)/$(DEXPREOPT_BOOT_JAR_DIR)
DEXPREOPT_BOOT_ODEXS := $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),\
$(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(b).odex)
# If the target is a uniprocessor, then explicitly tell the preoptimizer
# that fact. (By default, it always optimizes for an SMP target.)
ifeq ($(TARGET_CPU_SMP),true)
DEXPREOPT_UNIPROCESSOR :=
else
DEXPREOPT_UNIPROCESSOR := --uniprocessor
endif
DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
# $(1): the .jar or .apk to remove classes.dex
define dexpreopt-remove-classes.dex
$(hide) $(AAPT) remove $(1) classes.dex
endef
# $(1): the input .jar or .apk file
# $(2): the output .odex file
define dexpreopt-one-file
$(hide) $(DEXPREOPT) --dexopt=$(DEXPREOPT_DEXOPT) --build-dir=$(DEXPREOPT_BUILD_DIR) \
--product-dir=$(DEXPREOPT_PRODUCT_DIR) --boot-dir=$(DEXPREOPT_BOOT_JAR_DIR) \
--boot-jars=$(DEXPREOPT_BOOT_JARS) $(DEXPREOPT_UNIPROCESSOR) \
$(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(1)) \
$(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(2))
endef
# Special rules for building stripped boot jars that override java_library.mk rules
# $(1): boot jar module name
define _dexpreopt-boot-jar
$(eval _dbj_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).jar)
$(eval _dbj_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).odex)
$(eval _dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar)
$(eval _dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar)
$(eval $(_dbj_odex): PRIVATE_DBJ_JAR := $(_dbj_jar))
$(_dbj_odex) : $(_dbj_src_jar) | $(ACP) $(DEXPREOPT) $(DEXOPT)
@echo "Dexpreopt Boot Jar: $$@"
$(hide) rm -f $$@
$(hide) mkdir -p $$(dir $$@)
$(hide) $(ACP) -fp $$< $$(PRIVATE_DBJ_JAR)
$$(call dexpreopt-one-file,$$(PRIVATE_DBJ_JAR),$$@)
define _dexpreopt-boot-jar-remove-classes.dex
_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
$(_dbj_jar_no_dex) : $(_dbj_src_jar) | $(ACP) $(AAPT)
$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP) $(AAPT)
$$(call copy-file-to-target)
ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
$$(call dexpreopt-remove-classes.dex,$$@)
endif
$(eval _dbj_jar :=)
$(eval _dbj_odex :=)
$(eval _dbj_jar_no_dex :=)
$(eval _dbj_src_jar :=)
_dbj_jar_no_dex :=
_dbj_src_jar :=
endef
$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar,$(b))))
$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
# $(1): the rest list of boot jars
define _build-dexpreopt-boot-jar-dependency-pair
$(if $(filter 1,$(words $(1)))$(filter 0,$(words $(1))),,\
$(eval _bdbjdp_target := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 2,$(1)).odex) \
$(eval _bdbjdp_dep := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 1,$(1)).odex) \
$(eval $(call add-dependency,$(_bdbjdp_target),$(_bdbjdp_dep))) \
$(eval $(call _build-dexpreopt-boot-jar-dependency-pair,$(wordlist 2,999,$(1)))))
endef
define _build-dexpreopt-boot-jar-dependency
$(call _build-dexpreopt-boot-jar-dependency-pair,$(DEXPREOPT_BOOT_JARS_MODULES))
endef
$(eval $(call _build-dexpreopt-boot-jar-dependency))
DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
ifeq ($(TARGET_CPU_VARIANT),$(filter $(TARGET_CPU_VARIANT),cortex-a15 krait))
DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div
# Conditionally include Dalvik support.
ifeq ($(DALVIK_VM_LIB),libdvm.so)
include $(BUILD_SYSTEM)/dex_preopt_libdvm.mk
endif
# Unconditionally include ART support because its used run dex2oat on the host for tests.
include $(BUILD_SYSTEM)/dex_preopt_libart.mk
# Define dexpreopt-one-file based on current default runtime.
# $(1): the boot image to use (unused for libdvm)
# $(2): the input .jar or .apk file
# $(3): the input .jar or .apk target location (unused for libdvm)
# $(4): the output .odex file
ifeq ($(DALVIK_VM_LIB),libdvm.so)
define dexpreopt-one-file
$(call dexopt-one-file,$(2),$(4))
endef
DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEXOPT_DEPENDENCY)
DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEXPREOPT_BOOT_ODEXS)
else
define dexpreopt-one-file
$(call dex2oat-one-file,$(1),$(2),$(3),$(4))
endef
DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE)
endif

96
core/dex_preopt_libart.mk Normal file
View file

@ -0,0 +1,96 @@
####################################
# dexpreopt support for ART
#
####################################
DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX)
DEX2OATD := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX)
LIBART_COMPILER := $(HOST_OUT_SHARED_LIBRARIES)/libart-compiler$(HOST_SHLIB_SUFFIX)
LIBARTD_COMPILER := $(HOST_OUT_SHARED_LIBRARIES)/libartd-compiler$(HOST_SHLIB_SUFFIX)
# TODO: for now, override with debug version for better error reporting
DEX2OAT := $(DEX2OATD)
LIBART_COMPILER := $(LIBARTD_COMPILER)
# By default, do not run rerun dex2oat if the tool changes.
# Comment out the | to force dex2oat to rerun on after all changes.
DEX2OAT_DEPENDENCY := art/runtime/oat.cc # dependency on oat version number
DEX2OAT_DEPENDENCY += art/runtime/image.cc # dependency on image version number
DEX2OAT_DEPENDENCY += |
DEX2OAT_DEPENDENCY += $(DEX2OAT)
DEX2OAT_DEPENDENCY += $(LIBART_COMPILER)
PRELOADED_CLASSES := frameworks/base/preloaded-classes
LIBART_BOOT_IMAGE := /$(DEXPREOPT_BOOT_JAR_DIR)/boot.art
DEFAULT_DEX_PREOPT_BUILT_IMAGE := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.art
DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$(LIBART_BOOT_IMAGE)
# The rule to install boot.art and boot.oat
$(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) | $(ACP)
$(call copy-file-to-target)
$(hide) $(ACP) -fp $(patsubst %.art,%.oat,$<) $(patsubst %.art,%.oat,$@)
DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
ifeq ($(TARGET_CPU_VARIANT),$(filter $(TARGET_CPU_VARIANT),cortex-a15 krait))
DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div
endif
# start of image reserved address space
LIBART_IMG_HOST_BASE_ADDRESS := 0x60000000
ifeq ($(TARGET_ARCH),mips)
LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
else
LIBART_IMG_TARGET_BASE_ADDRESS := 0x60000000
endif
########################################################################
# The full system boot classpath
# note we use core-libart.jar in place of core.jar for ART.
LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
# The .oat with symbols
LIBART_TARGET_BOOT_OAT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)$(patsubst %.art,%.oat,$(LIBART_BOOT_IMAGE))
$(DEFAULT_DEX_PREOPT_BUILT_IMAGE): $(LIBART_TARGET_BOOT_DEX_FILES) $(DEX2OAT_DEPENDENCY)
@echo "target dex2oat: $@ ($?)"
@mkdir -p $(dir $@)
@mkdir -p $(dir $(LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
$(hide) $(DEX2OAT) --runtime-arg -Xms256m --runtime-arg -Xmx256m --image-classes=$(PRELOADED_CLASSES) \
$(addprefix --dex-file=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
$(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
--oat-symbols=$(LIBART_TARGET_BOOT_OAT_UNSTRIPPED) \
--oat-file=$(patsubst %.art,%.oat,$@) \
--oat-location=$(patsubst %.art,%.oat,$(LIBART_BOOT_IMAGE)) \
--image=$@ --base=$(LIBART_IMG_TARGET_BASE_ADDRESS) \
--instruction-set=$(TARGET_ARCH) --instruction-set-features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
--host-prefix=$(DEXPREOPT_PRODUCT_DIR_FULL_PATH) --android-root=$(PRODUCT_OUT)/system
########################################################################
# For a single jar or APK
# $(1): the boot image to use
# $(2): the input .jar or .apk file
# $(3): the input .jar or .apk target location
# $(4): the output .odex file
define dex2oat-one-file
$(hide) rm -f $(4)
$(hide) mkdir -p $(dir $(4))
$(hide) $(DEX2OAT) \
--runtime-arg -Xms64m --runtime-arg -Xmx64m \
--boot-image=$(1) \
--dex-file=$(2) \
--dex-location=$(3) \
--oat-file=$(4) \
--host-prefix=$(DEXPREOPT_PRODUCT_DIR_FULL_PATH) \
--android-root=$(PRODUCT_OUT)/system \
--instruction-set=$(TARGET_ARCH) \
--instruction-set-features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
endef

76
core/dex_preopt_libdvm.mk Normal file
View file

@ -0,0 +1,76 @@
####################################
# dexpreopt support for Dalvik
#
####################################
DEXOPT := $(HOST_OUT_EXECUTABLES)/dexopt$(HOST_EXECUTABLE_SUFFIX)
DEXPREOPT := dalvik/tools/dex-preopt
DEXPREOPT_DEXOPT := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXOPT))
DEXPREOPT_BOOT_ODEXS := $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),\
$(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(b).odex)
# If the target is a uniprocessor, then explicitly tell the preoptimizer
# that fact. (By default, it always optimizes for an SMP target.)
ifeq ($(TARGET_CPU_SMP),true)
DEXPREOPT_UNIPROCESSOR :=
else
DEXPREOPT_UNIPROCESSOR := --uniprocessor
endif
# By default, do not run rerun dexopt if the tool changes.
# Comment out the | to force dex2oat to rerun on after all changes.
DEXOPT_DEPENDENCY := |
DEXOPT_DEPENDENCY += $(DEXPREOPT) $(DEXOPT)
# $(1): the input .jar or .apk file
# $(2): the output .odex file
define dexopt-one-file
$(hide) rm -f $(2)
$(hide) mkdir -p $(dir $(2))
$(hide) $(DEXPREOPT) \
--dexopt=$(DEXPREOPT_DEXOPT) \
--build-dir=$(DEXPREOPT_BUILD_DIR) \
--product-dir=$(DEXPREOPT_PRODUCT_DIR) \
--boot-dir=$(DEXPREOPT_BOOT_JAR_DIR) \
--boot-jars=$(DEXPREOPT_BOOT_JARS) \
$(DEXPREOPT_UNIPROCESSOR) \
$(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(1)) \
$(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(2))
endef
# Special rules for building odex files for boot jars that override java_library.mk rules
# $(1): boot jar module name
define _dexpreopt-boot-odex
_dbj_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).jar
_dbj_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).odex
_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
$$(_dbj_odex): PRIVATE_DBJ_JAR := $$(_dbj_jar)
$$(_dbj_odex) : $$(_dbj_src_jar) | $(ACP) $(DEXPREOPT) $(DEXOPT)
@echo "Dexpreopt Boot Jar: $$@"
$(hide) $(ACP) -fp $$< $$(PRIVATE_DBJ_JAR)
$$(call dexopt-one-file,$$(PRIVATE_DBJ_JAR),$$@)
_dbj_jar :=
_dbj_odex :=
_dbj_src_jar :=
endef
$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-odex,$(b))))
# $(1): the rest list of boot jars
define _build-dexpreopt-boot-jar-dependency-pair
$(if $(filter 1,$(words $(1)))$(filter 0,$(words $(1))),,\
$(eval _bdbjdp_target := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 2,$(1)).odex) \
$(eval _bdbjdp_dep := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 1,$(1)).odex) \
$(eval $(call add-dependency,$(_bdbjdp_target),$(_bdbjdp_dep))) \
$(eval $(call _build-dexpreopt-boot-jar-dependency-pair,$(wordlist 2,999,$(1)))))
endef
define _build-dexpreopt-boot-jar-dependency
$(call _build-dexpreopt-boot-jar-dependency-pair,$(DEXPREOPT_BOOT_JARS_MODULES))
endef
$(eval $(call _build-dexpreopt-boot-jar-dependency))

View file

@ -0,0 +1,70 @@
# dexpreopt_odex_install.mk is used to define odex creation rules for JARs and APKs
# This file depends on variables set in base_rules.mk
# Output variables: LOCAL_DEX_PREOPT, built_odex, dexpreopt_boot_jar_module
# Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc
LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT))
ifneq (true,$(WITH_DEXPREOPT))
LOCAL_DEX_PREOPT :=
else # WITH_DEXPREOPT=true
ifeq (,$(TARGET_BUILD_APPS)) # TARGET_BUILD_APPS empty
ifneq (,$(LOCAL_SRC_FILES)) # LOCAL_SRC_FILES not empty
ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined
ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty
LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
else # LOCAL_APK_LIBRARIES not empty
LOCAL_DEX_PREOPT := nostripping
endif # LOCAL_APK_LIBRARIES not empty
endif # LOCAL_DEX_PREOPT undefined
endif # LOCAL_SRC_FILES not empty
endif # TARGET_BUILD_APPS empty
endif # WITH_DEXPREOPT=true
ifeq (false,$(LOCAL_DEX_PREOPT))
LOCAL_DEX_PREOPT :=
endif
ifdef LOCAL_UNINSTALLABLE_MODULE
LOCAL_DEX_PREOPT :=
endif
ifeq (,$(strip $(all_java_sources)$(full_static_java_libs)$(my_prebuilt_src_file))) # contains no java code
LOCAL_DEX_PREOPT :=
endif
# if module oat file requested in data, disable LOCAL_DEX_PREOPT, will default location to dalvik-cache
ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA)))
LOCAL_DEX_PREOPT :=
endif
built_odex :=
installed_odex :=
ifdef LOCAL_DEX_PREOPT
dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
ifdef dexpreopt_boot_jar_module
ifeq ($(DALVIK_VM_LIB),libdvm.so)
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
else # libdvm.so
# For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
# We use this installed_odex trick to get boot.art installed.
installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
endif # libdvm.so
else # boot jar
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
ifneq ($(DALVIK_VM_LIB),libdvm.so) # libart
ifndef LOCAL_DEX_PREOPT_IMAGE
LOCAL_DEX_PREOPT_IMAGE := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE)
endif
endif # libart
endif # boot jar
ifdef built_odex
# We need $(LOCAL_BUILT_MODULE) in the deps to enforce reinstallation
# even if $(built_odex) is byproduct of $(LOCAL_BUILT_MODULE), such as in package.mk.
$(installed_odex) : $(built_odex) $(LOCAL_BUILT_MODULE) | $(ACP)
@echo "Install: $@"
$(copy-file-to-target)
endif
# Add the installed_odex to the list of installed files for this module.
ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(installed_odex)
endif # LOCAL_DEX_PREOPT

View file

@ -252,6 +252,11 @@ include $(BUILD_SYSTEM)/base_rules.mk
java_alternative_checked_module :=
#######################################
# defines built_odex along with rule to install odex
include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
#######################################
# Make sure there's something to build.
ifdef full_classes_jar
ifndef need_compile_java

View file

@ -34,21 +34,6 @@ ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
LOCAL_PROGUARD_ENABLED :=
endif
ifneq (true,$(WITH_DEXPREOPT))
LOCAL_DEX_PREOPT :=
else
ifeq (,$(TARGET_BUILD_APPS))
ifeq (,$(LOCAL_APK_LIBRARIES))
ifndef LOCAL_DEX_PREOPT
LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
endif
endif
endif
endif
ifeq (false,$(LOCAL_DEX_PREOPT))
LOCAL_DEX_PREOPT :=
endif
ifeq (true,$(EMMA_INSTRUMENT))
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
@ -93,28 +78,30 @@ ifneq ($(extra_jar_args),)
endif
ifdef LOCAL_DEX_PREOPT
dexpreopt_boot_jar_module := $(filter $(LOCAL_MODULE),$(DEXPREOPT_BOOT_JARS_MODULES))
ifneq ($(dexpreopt_boot_jar_module),)
ifneq ($(dexpreopt_boot_jar_module),) # boot jar
# boot jar's rules are defined in dex_preopt.mk
dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
$(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP)
$(call copy-file-to-target)
# For libart boot jars, we don't have .odex files.
ifeq ($(DALVIK_VM_LIB),libdvm.so)
dexpreopted_boot_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module).odex
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
$(built_odex) : $(dexpreopted_boot_odex) | $(ACP)
$(call copy-file-to-target)
endif
else # dexpreopt_boot_jar_module
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
else # ! boot jar
$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
$(built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
$(built_odex): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
# Make sure the boot jars get dex-preopt-ed first
$(built_odex) : $(DEXPREOPT_BOOT_ODEXS)
$(built_odex) : $(common_javalib.jar) | $(DEXPREOPT) $(DEXOPT)
$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
$(built_odex) : $(LOCAL_DEX_PREOPT_IMAGE)
$(built_odex) : $(common_javalib.jar)
@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
$(hide) rm -f $@
@mkdir -p $(dir $@)
$(call dexpreopt-one-file,$<,$@)
$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$<,$(PRIVATE_DEX_LOCATION),$@)
$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
$(call copy-file-to-target)
@ -122,7 +109,7 @@ ifneq (nostripping,$(LOCAL_DEX_PREOPT))
$(call dexpreopt-remove-classes.dex,$@)
endif
endif # dexpreopt_boot_jar_module
endif # ! boot jar
else # LOCAL_DEX_PREOPT
$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)

View file

@ -146,23 +146,6 @@ endif # all_resources
endif # !custom
LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
ifneq (true,$(WITH_DEXPREOPT))
LOCAL_DEX_PREOPT :=
else
ifeq (,$(TARGET_BUILD_APPS))
ifeq (,$(LOCAL_APK_LIBRARIES))
ifneq (,$(LOCAL_SRC_FILES))
ifndef LOCAL_DEX_PREOPT
LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
endif
endif
endif
endif
endif
ifeq (false,$(LOCAL_DEX_PREOPT))
LOCAL_DEX_PREOPT :=
endif
ifeq (true,$(EMMA_INSTRUMENT))
ifndef LOCAL_EMMA_INSTRUMENT
# No emma for test apks.
@ -391,8 +374,16 @@ $(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\
# Define the rule to build the actual package.
$(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN)
ifdef LOCAL_DEX_PREOPT
$(LOCAL_BUILT_MODULE): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
$(LOCAL_BUILT_MODULE): PRIVATE_BUILT_ODEX := $(built_odex)
$(LOCAL_BUILT_MODULE): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
# Make sure the boot jars get dexpreopt-ed first
$(LOCAL_BUILT_MODULE): $(DEXPREOPT_BOOT_ODEXS) | $(DEXPREOPT) $(DEXOPT)
$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
$(LOCAL_BUILT_MODULE) : $(LOCAL_DEX_PREOPT_IMAGE)
# built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
$(built_odex) : $(LOCAL_BUILT_MODULE)
endif
$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abi)
@ -423,8 +414,7 @@ ifneq ($(extra_jar_args),)
endif
$(sign-package)
ifdef LOCAL_DEX_PREOPT
$(hide) rm -f $(patsubst %.apk,%.odex,$@)
$(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
$(call dexpreopt-remove-classes.dex,$@)
endif
@ -432,11 +422,6 @@ endif
@# Alignment must happen after all other zip operations.
$(align-package)
ifdef LOCAL_DEX_PREOPT
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
$(built_odex): $(LOCAL_BUILT_MODULE)
endif
# Save information about this package
PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)

View file

@ -145,18 +145,37 @@ else
endif
ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
# Ensure that presigned .apks have been aligned.
$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN)
$(transform-prebuilt-to-target-with-zipalign)
else
# Disable dex-preopt of prebuilts to save space
LOCAL_DEX_PREOPT := false
#######################################
# defines built_odex along with rule to install odex
include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
#######################################
ifdef LOCAL_DEX_PREOPT
$(built_module): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
$(built_module): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
$(built_module): PRIVATE_BUILT_ODEX := $(built_odex)
# Make sure the boot jars get dexpreopt-ed first
$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
(built_module) : $(LOCAL_DEX_PREOPT_IMAGE)
# built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
$(built_odex) : $(LOCAL_BUILT_MODULE)
endif # LOCAL_DEX_PREOPT
# Sign and align non-presigned .apks.
$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
$(transform-prebuilt-to-target)
ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
$(sign-package)
$(align-package)
endif
else
ifdef LOCAL_DEX_PREOPT
$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
endif
$(align-package)
else # LOCAL_MODULE_CLASS != APPS
ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
$(built_module) : $(my_prebuilt_src_file)
$(transform-prebuilt-to-target-strip-comments)
@ -171,7 +190,7 @@ ifneq ($(prebuilt_module_is_a_library),)
endif
endif
endif
endif
endif # LOCAL_MODULE_CLASS != APPS
ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
@ -192,3 +211,5 @@ $(built_module) : $(common_javalib_jar)
endif # TARGET JAVA_LIBRARIES
$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
my_prebuilt_src_file :=

View file

@ -266,6 +266,17 @@ $(call clear-var-list, $(_product_var_list))
# Now we can assign to PRODUCT_RUNTIMES
PRODUCT_RUNTIMES := $(product_runtimes)
product_runtimes :=
PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES += persist.sys.dalvik.vm.lib=$(DALVIK_VM_LIB)
ifeq ($(words $(PRODUCT_RUNTIMES)),1)
# If we only have one runtime, we can strip classes.dex by default during dex_preopt
DEX_PREOPT_DEFAULT := true
else
# If we have more than one, we leave the classes.dex alone for post-boot analysis
DEX_PREOPT_DEFAULT := nostripping
endif
#############################################################################
# A list of module names of BOOTCLASSPATH (jar files)

View file

@ -28,7 +28,4 @@ ifeq ($(WITH_HOST_DALVIK),true)
core-libart-hostdex
endif
# We currently don't suport DEX_PREOPT for art
DEX_PREOPT_DEFAULT := nostripping
include $(SRC_TARGET_DIR)/product/runtime_common.mk

View file

@ -16,7 +16,6 @@
# Set ART as the default runtime environment
PRODUCT_PROPERTY_OVERRIDES += \
persist.sys.dalvik.vm.lib=libart.so
DALVIK_VM_LIB := libart.so
include $(SRC_TARGET_DIR)/product/runtime_libart.mk

View file

@ -27,9 +27,4 @@ ifeq ($(WITH_HOST_DALVIK),true)
core-hostdex
endif
# If runtime_libart has disabled, do not override
ifndef DEX_PREOPT_DEFAULT
DEX_PREOPT_DEFAULT := true
endif
include $(SRC_TARGET_DIR)/product/runtime_common.mk

View file

@ -16,7 +16,6 @@
# Set Dalvik as the default runtime environment
PRODUCT_PROPERTY_OVERRIDES += \
persist.sys.dalvik.vm.lib=libdvm.so
DALVIK_VM_LIB := libdvm.so
include $(SRC_TARGET_DIR)/product/runtime_libdvm.mk