dex_preopt.mk revision 8c7e74ee05de0b9f3875318cc405ff0de3d1c878
1####################################
2# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
3#
4####################################
5
6ifneq ($(DALVIK_VM_LIB),)
7
8# list of boot classpath jars for dexpreopt
9DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
10DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
11PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
12
13DEXPREOPT_BUILD_DIR := $(OUT_DIR)
14DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars
15DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH))
16DEXPREOPT_BOOT_JAR_DIR := system/framework
17DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
18
19# $(1): the .jar or .apk to remove classes.dex
20define dexpreopt-remove-classes.dex
21$(hide) $(AAPT) remove $(1) classes.dex
22endef
23
24# Special rules for building stripped boot jars that override java_library.mk rules
25
26# $(1): boot jar module name
27define _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
30
31$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP) $(AAPT)
32	$$(call copy-file-to-target)
33ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
34	$$(call dexpreopt-remove-classes.dex,$$@)
35endif
36
37_dbj_jar_no_dex :=
38_dbj_src_jar :=
39endef
40
41$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
42
43# 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))
59endef
60
61DEXPREOPT_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))
66endef
67
68DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
69DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE)
70endif
71else
72$(warning No DALVIK_VM_LIB, disable dexpreopt.)
73WITH_DEXPREOPT := false
74DISABLE_DEXPREOPT := true
75endif  # DALVIK_VM_LIB is defined.
76