blob: e0dde01e95bad1493a913af9f51c4ae641cca31a [file] [log] [blame]
Ying Wange7874c42010-09-17 16:36:06 -07001####################################
Brian Carlstromced4bff2013-11-14 23:44:56 -08002# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
Ying Wange7874c42010-09-17 16:36:06 -07003#
4####################################
5
Brian Carlstromced4bff2013-11-14 23:44:56 -08006# list of boot classpath jars for dexpreopt
Ying Wangad6674c2014-01-07 14:31:49 -08007DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
8DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
Ying Wang0650d152013-07-23 17:57:38 -07009PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
Ying Wange7874c42010-09-17 16:36:06 -070010
Narayan Kamath89ec4962014-08-05 14:51:08 +010011PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar))
12
Ying Wange7874c42010-09-17 16:36:06 -070013DEXPREOPT_BUILD_DIR := $(OUT_DIR)
Brian Carlstromced4bff2013-11-14 23:44:56 -080014DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars
15DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH))
Ying Wange7874c42010-09-17 16:36:06 -070016DEXPREOPT_BOOT_JAR_DIR := system/framework
Brian Carlstromced4bff2013-11-14 23:44:56 -080017DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
Dan Bornsteinc8c09e22010-09-29 11:54:15 -070018
Ying Wangd54520a2014-12-08 14:46:29 -080019# The default value for LOCAL_DEX_PREOPT
20DEX_PREOPT_DEFAULT ?= true
21
Ying Wange7874c42010-09-17 16:36:06 -070022# $(1): the .jar or .apk to remove classes.dex
23define dexpreopt-remove-classes.dex
Brian Carlstromfca81452014-06-30 10:09:56 -070024$(hide) zip --quiet --delete $(1) classes.dex; \
25dex_index=2; \
26while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
27 let dex_index=dex_index+1; \
28done
Ying Wange7874c42010-09-17 16:36:06 -070029endef
30
Brian Carlstromced4bff2013-11-14 23:44:56 -080031# Special rules for building stripped boot jars that override java_library.mk rules
Ying Wange7874c42010-09-17 16:36:06 -070032
33# $(1): boot jar module name
Brian Carlstromced4bff2013-11-14 23:44:56 -080034define _dexpreopt-boot-jar-remove-classes.dex
35_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
36_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
Ying Wange7874c42010-09-17 16:36:06 -070037
Brian Carlstrom1a71f952015-07-23 17:12:10 -070038$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP)
Ying Wange7874c42010-09-17 16:36:06 -070039 $$(call copy-file-to-target)
Brian Carlstrom71fc41d2013-09-12 00:22:42 -070040ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
Ying Wange7874c42010-09-17 16:36:06 -070041 $$(call dexpreopt-remove-classes.dex,$$@)
Brian Carlstrom71fc41d2013-09-12 00:22:42 -070042endif
Ying Wange7874c42010-09-17 16:36:06 -070043
Brian Carlstromced4bff2013-11-14 23:44:56 -080044_dbj_jar_no_dex :=
45_dbj_src_jar :=
Ying Wange7874c42010-09-17 16:36:06 -070046endef
47
Brian Carlstromced4bff2013-11-14 23:44:56 -080048$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
Ying Wange7874c42010-09-17 16:36:06 -070049
Brian Carlstromced4bff2013-11-14 23:44:56 -080050include $(BUILD_SYSTEM)/dex_preopt_libart.mk
51
52# Define dexpreopt-one-file based on current default runtime.
Ying Wangb9aa5d42014-05-13 13:57:28 -070053# $(1): the input .jar or .apk file
54# $(2): the output .odex file
Brian Carlstromced4bff2013-11-14 23:44:56 -080055define dexpreopt-one-file
Ying Wangb9aa5d42014-05-13 13:57:28 -070056$(call dex2oat-one-file,$(1),$(2))
Ying Wange7874c42010-09-17 16:36:06 -070057endef
58
Nicolas Geoffray75c08b22014-10-06 14:53:59 +010059DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
Ying Wangb9aa5d42014-05-13 13:57:28 -070060DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
61ifdef TARGET_2ND_ARCH
62$(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
63endif # TARGET_2ND_ARCH