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 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 6 | # list of boot classpath jars for dexpreopt |
Ying Wang | ad6674c | 2014-01-07 14:31:49 -0800 | [diff] [blame] | 7 | DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS)) |
| 8 | DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS) |
Ying Wang | 0650d15 | 2013-07-23 17:57:38 -0700 | [diff] [blame] | 9 | 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] | 10 | |
Narayan Kamath | 89ec496 | 2014-08-05 14:51:08 +0100 | [diff] [blame] | 11 | PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar)) |
| 12 | |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 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 | d54520a | 2014-12-08 14:46:29 -0800 | [diff] [blame] | 19 | # The default value for LOCAL_DEX_PREOPT |
| 20 | DEX_PREOPT_DEFAULT ?= true |
| 21 | |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 22 | # $(1): the .jar or .apk to remove classes.dex |
| 23 | define dexpreopt-remove-classes.dex |
Brian Carlstrom | fca8145 | 2014-06-30 10:09:56 -0700 | [diff] [blame] | 24 | $(hide) zip --quiet --delete $(1) classes.dex; \ |
| 25 | dex_index=2; \ |
| 26 | while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \ |
| 27 | let dex_index=dex_index+1; \ |
| 28 | done |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 29 | endef |
| 30 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 31 | # 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] | 32 | |
| 33 | # $(1): boot jar module name |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 34 | define _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 Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 37 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 38 | $$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP) $(AAPT) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 39 | $$(call copy-file-to-target) |
Brian Carlstrom | 71fc41d | 2013-09-12 00:22:42 -0700 | [diff] [blame] | 40 | ifneq ($(DEX_PREOPT_DEFAULT),nostripping) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 41 | $$(call dexpreopt-remove-classes.dex,$$@) |
Brian Carlstrom | 71fc41d | 2013-09-12 00:22:42 -0700 | [diff] [blame] | 42 | endif |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 43 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 44 | _dbj_jar_no_dex := |
| 45 | _dbj_src_jar := |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 46 | endef |
| 47 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 48 | $(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] | 49 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 50 | include $(BUILD_SYSTEM)/dex_preopt_libart.mk |
| 51 | |
| 52 | # Define dexpreopt-one-file based on current default runtime. |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 53 | # $(1): the input .jar or .apk file |
| 54 | # $(2): the output .odex file |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 55 | define dexpreopt-one-file |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 56 | $(call dex2oat-one-file,$(1),$(2)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 57 | endef |
| 58 | |
Nicolas Geoffray | 75c08b2 | 2014-10-06 14:53:59 +0100 | [diff] [blame] | 59 | DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY) |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 60 | DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) |
| 61 | ifdef 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) |
| 63 | endif # TARGET_2ND_ARCH |