Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 1 | #################################### |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 2 | # dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 3 | # |
| 4 | #################################### |
| 5 | |
Ying Wang | 8c7e74e | 2014-03-20 12:13:10 -0700 | [diff] [blame] | 6 | ifneq ($(DALVIK_VM_LIB),) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 7 | |
| 8 | # list of boot classpath jars for dexpreopt |
Ying Wang | ad6674c | 2014-01-07 14:31:49 -0800 | [diff] [blame] | 9 | DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS)) |
| 10 | DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS) |
Ying Wang | 0650d15 | 2013-07-23 17:57:38 -0700 | [diff] [blame] | 11 | PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 12 | |
| 13 | DEXPREOPT_BUILD_DIR := $(OUT_DIR) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 14 | DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars |
| 15 | DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 16 | DEXPREOPT_BOOT_JAR_DIR := system/framework |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 17 | DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR) |
Dan Bornstein | c8c09e2 | 2010-09-29 11:54:15 -0700 | [diff] [blame] | 18 | |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 19 | # $(1): the .jar or .apk to remove classes.dex |
| 20 | define dexpreopt-remove-classes.dex |
| 21 | $(hide) $(AAPT) remove $(1) classes.dex |
| 22 | endef |
| 23 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 24 | # Special rules for building stripped boot jars that override java_library.mk rules |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 25 | |
| 26 | # $(1): boot jar module name |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 27 | define _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 Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 30 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 31 | $$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP) $(AAPT) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 32 | $$(call copy-file-to-target) |
Brian Carlstrom | 71fc41d | 2013-09-12 00:22:42 -0700 | [diff] [blame] | 33 | ifneq ($(DEX_PREOPT_DEFAULT),nostripping) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 34 | $$(call dexpreopt-remove-classes.dex,$$@) |
Brian Carlstrom | 71fc41d | 2013-09-12 00:22:42 -0700 | [diff] [blame] | 35 | endif |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 36 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 37 | _dbj_jar_no_dex := |
| 38 | _dbj_src_jar := |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 39 | endef |
| 40 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 41 | $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b)))) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 42 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 43 | # Conditionally include Dalvik support. |
| 44 | ifeq ($(DALVIK_VM_LIB),libdvm.so) |
| 45 | include $(BUILD_SYSTEM)/dex_preopt_libdvm.mk |
| 46 | endif |
| 47 | |
| 48 | # Unconditionally include ART support because its used run dex2oat on the host for tests. |
| 49 | include $(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 |
| 56 | ifeq ($(DALVIK_VM_LIB),libdvm.so) |
| 57 | define dexpreopt-one-file |
| 58 | $(call dexopt-one-file,$(2),$(4)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 59 | endef |
| 60 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 61 | DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEXOPT_DEPENDENCY) |
| 62 | DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEXPREOPT_BOOT_ODEXS) |
| 63 | else |
| 64 | define dexpreopt-one-file |
| 65 | $(call dex2oat-one-file,$(1),$(2),$(3),$(4)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 66 | endef |
| 67 | |
Nicolas Geoffray | ed154c3 | 2014-03-25 11:14:26 +0000 | [diff] [blame] | 68 | DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OATD_DEPENDENCY) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 69 | DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) |
Dave Allison | 014a3c0 | 2013-10-31 11:44:47 -0700 | [diff] [blame] | 70 | endif |
Ying Wang | 8c7e74e | 2014-03-20 12:13:10 -0700 | [diff] [blame] | 71 | else |
| 72 | $(warning No DALVIK_VM_LIB, disable dexpreopt.) |
| 73 | WITH_DEXPREOPT := false |
Ying Wang | 8c7e74e | 2014-03-20 12:13:10 -0700 | [diff] [blame] | 74 | endif # DALVIK_VM_LIB is defined. |