2010-09-18 07:36:06 +08:00
|
|
|
####################################
|
2013-11-15 15:44:56 +08:00
|
|
|
# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
|
2010-09-18 07:36:06 +08:00
|
|
|
#
|
|
|
|
####################################
|
|
|
|
|
2014-03-21 03:13:10 +08:00
|
|
|
ifneq ($(DALVIK_VM_LIB),)
|
2013-11-15 15:44:56 +08:00
|
|
|
|
|
|
|
# list of boot classpath jars for dexpreopt
|
2014-01-08 06:31:49 +08:00
|
|
|
DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
|
|
|
|
DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
|
2013-07-24 08:57:38 +08:00
|
|
|
PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
|
2010-09-18 07:36:06 +08:00
|
|
|
|
|
|
|
DEXPREOPT_BUILD_DIR := $(OUT_DIR)
|
2013-11-15 15:44:56 +08:00
|
|
|
DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars
|
|
|
|
DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH))
|
2010-09-18 07:36:06 +08:00
|
|
|
DEXPREOPT_BOOT_JAR_DIR := system/framework
|
2013-11-15 15:44:56 +08:00
|
|
|
DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
|
2010-09-30 02:54:15 +08:00
|
|
|
|
2010-09-18 07:36:06 +08:00
|
|
|
# $(1): the .jar or .apk to remove classes.dex
|
|
|
|
define dexpreopt-remove-classes.dex
|
2014-07-01 01:09:56 +08:00
|
|
|
$(hide) zip --quiet --delete $(1) classes.dex; \
|
|
|
|
dex_index=2; \
|
|
|
|
while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
|
|
|
|
let dex_index=dex_index+1; \
|
|
|
|
done
|
2010-09-18 07:36:06 +08:00
|
|
|
endef
|
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
# Special rules for building stripped boot jars that override java_library.mk rules
|
2010-09-18 07:36:06 +08:00
|
|
|
|
|
|
|
# $(1): boot jar module name
|
2013-11-15 15:44:56 +08:00
|
|
|
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
|
2010-09-18 07:36:06 +08:00
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP) $(AAPT)
|
2010-09-18 07:36:06 +08:00
|
|
|
$$(call copy-file-to-target)
|
2013-09-12 15:22:42 +08:00
|
|
|
ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
|
2010-09-18 07:36:06 +08:00
|
|
|
$$(call dexpreopt-remove-classes.dex,$$@)
|
2013-09-12 15:22:42 +08:00
|
|
|
endif
|
2010-09-18 07:36:06 +08:00
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
_dbj_jar_no_dex :=
|
|
|
|
_dbj_src_jar :=
|
2010-09-18 07:36:06 +08:00
|
|
|
endef
|
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
|
2010-09-18 07:36:06 +08:00
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
# 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
|
2010-09-18 07:36:06 +08:00
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
# Define dexpreopt-one-file based on current default runtime.
|
2014-05-14 04:57:28 +08:00
|
|
|
# $(1): the input .jar or .apk file
|
|
|
|
# $(2): the output .odex file
|
2013-11-15 15:44:56 +08:00
|
|
|
ifeq ($(DALVIK_VM_LIB),libdvm.so)
|
|
|
|
define dexpreopt-one-file
|
2014-05-14 04:57:28 +08:00
|
|
|
$(call dexopt-one-file,$(1),$(2))
|
2010-09-18 07:36:06 +08:00
|
|
|
endef
|
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEXOPT_DEPENDENCY)
|
|
|
|
DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEXPREOPT_BOOT_ODEXS)
|
|
|
|
else
|
|
|
|
define dexpreopt-one-file
|
2014-05-14 04:57:28 +08:00
|
|
|
$(call dex2oat-one-file,$(1),$(2))
|
2013-11-15 15:44:56 +08:00
|
|
|
endef
|
2013-11-01 02:44:47 +08:00
|
|
|
|
2014-03-25 19:14:26 +08:00
|
|
|
DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OATD_DEPENDENCY)
|
2014-05-14 04:57:28 +08:00
|
|
|
DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
|
|
|
|
ifdef TARGET_2ND_ARCH
|
|
|
|
$(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
|
|
|
|
endif # TARGET_2ND_ARCH
|
|
|
|
endif # DALVIK_VM_LIB
|
2014-03-21 03:13:10 +08:00
|
|
|
else
|
|
|
|
$(warning No DALVIK_VM_LIB, disable dexpreopt.)
|
|
|
|
WITH_DEXPREOPT := false
|
|
|
|
endif # DALVIK_VM_LIB is defined.
|