blob: 46a6479b36ac1956c82e231bdfd79a2dfd8dffb4 [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
Ying Wang8c7e74e2014-03-20 12:13:10 -07006ifneq ($(DALVIK_VM_LIB),)
Brian Carlstromced4bff2013-11-14 23:44:56 -08007
8# list of boot classpath jars for dexpreopt
Ying Wangad6674c2014-01-07 14:31:49 -08009DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
10DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
Ying Wang0650d152013-07-23 17:57:38 -070011PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
Ying Wange7874c42010-09-17 16:36:06 -070012
13DEXPREOPT_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 Wange7874c42010-09-17 16:36:06 -070019# $(1): the .jar or .apk to remove classes.dex
20define dexpreopt-remove-classes.dex
21$(hide) $(AAPT) remove $(1) classes.dex
22endef
23
Brian Carlstromced4bff2013-11-14 23:44:56 -080024# Special rules for building stripped boot jars that override java_library.mk rules
Ying Wange7874c42010-09-17 16:36:06 -070025
26# $(1): boot jar module name
Brian Carlstromced4bff2013-11-14 23:44:56 -080027define _dexpreopt-boot-jar-remove-classes.dex
28_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
29_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
Ying Wange7874c42010-09-17 16:36:06 -070030
Brian Carlstromced4bff2013-11-14 23:44:56 -080031$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP) $(AAPT)
Ying Wange7874c42010-09-17 16:36:06 -070032 $$(call copy-file-to-target)
Brian Carlstrom71fc41d2013-09-12 00:22:42 -070033ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
Ying Wange7874c42010-09-17 16:36:06 -070034 $$(call dexpreopt-remove-classes.dex,$$@)
Brian Carlstrom71fc41d2013-09-12 00:22:42 -070035endif
Ying Wange7874c42010-09-17 16:36:06 -070036
Brian Carlstromced4bff2013-11-14 23:44:56 -080037_dbj_jar_no_dex :=
38_dbj_src_jar :=
Ying Wange7874c42010-09-17 16:36:06 -070039endef
40
Brian Carlstromced4bff2013-11-14 23:44:56 -080041$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
Ying Wange7874c42010-09-17 16:36:06 -070042
Brian Carlstromced4bff2013-11-14 23:44:56 -080043# Conditionally include Dalvik support.
44ifeq ($(DALVIK_VM_LIB),libdvm.so)
45include $(BUILD_SYSTEM)/dex_preopt_libdvm.mk
46endif
47
48# Unconditionally include ART support because its used run dex2oat on the host for tests.
49include $(BUILD_SYSTEM)/dex_preopt_libart.mk
50
51# Define dexpreopt-one-file based on current default runtime.
52# $(1): the boot image to use (unused for libdvm)
53# $(2): the input .jar or .apk file
54# $(3): the input .jar or .apk target location (unused for libdvm)
55# $(4): the output .odex file
56ifeq ($(DALVIK_VM_LIB),libdvm.so)
57define dexpreopt-one-file
58$(call dexopt-one-file,$(2),$(4))
Ying Wange7874c42010-09-17 16:36:06 -070059endef
60
Brian Carlstromced4bff2013-11-14 23:44:56 -080061DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEXOPT_DEPENDENCY)
62DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEXPREOPT_BOOT_ODEXS)
63else
64define dexpreopt-one-file
65$(call dex2oat-one-file,$(1),$(2),$(3),$(4))
Ying Wange7874c42010-09-17 16:36:06 -070066endef
67
Nicolas Geoffrayed154c32014-03-25 11:14:26 +000068DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OATD_DEPENDENCY)
Brian Carlstromced4bff2013-11-14 23:44:56 -080069DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE)
Dave Allison014a3c02013-10-31 11:44:47 -070070endif
Ying Wang8c7e74e2014-03-20 12:13:10 -070071else
72$(warning No DALVIK_VM_LIB, disable dexpreopt.)
73WITH_DEXPREOPT := false
Ying Wang8c7e74e2014-03-20 12:13:10 -070074endif # DALVIK_VM_LIB is defined.