Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 1 | #################################### |
| 2 | # Dexpreopt on the boot jars |
| 3 | # |
| 4 | #################################### |
| 5 | |
| 6 | # TODO: replace it with device's BOOTCLASSPATH |
Wink Saville | c16c945 | 2012-06-30 16:13:26 -0700 | [diff] [blame] | 7 | DEXPREOPT_BOOT_JARS := core:core-junit:bouncycastle:ext:framework:telephony-common:mms-common:android.policy:services:apache-xml |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 8 | DEXPREOPT_BOOT_JARS_MODULES := $(subst :, ,$(DEXPREOPT_BOOT_JARS)) |
| 9 | |
| 10 | DEXPREOPT_BUILD_DIR := $(OUT_DIR) |
| 11 | DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(PRODUCT_OUT))/dex_bootjars |
| 12 | DEXPREOPT_BOOT_JAR_DIR := system/framework |
| 13 | DEXPREOPT_DEXOPT := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXOPT)) |
| 14 | |
| 15 | DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_BUILD_DIR)/$(DEXPREOPT_PRODUCT_DIR)/$(DEXPREOPT_BOOT_JAR_DIR) |
| 16 | |
| 17 | DEXPREOPT_BOOT_ODEXS := $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),\ |
| 18 | $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(b).odex) |
| 19 | |
Dan Bornstein | c8c09e2 | 2010-09-29 11:54:15 -0700 | [diff] [blame] | 20 | # If the target is a uniprocessor, then explicitly tell the preoptimizer |
| 21 | # that fact. (By default, it always optimizes for an SMP target.) |
| 22 | ifeq ($(TARGET_CPU_SMP),true) |
| 23 | DEXPREOPT_UNIPROCESSOR := |
| 24 | else |
| 25 | DEXPREOPT_UNIPROCESSOR := --uniprocessor |
| 26 | endif |
| 27 | |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 28 | # $(1): the .jar or .apk to remove classes.dex |
| 29 | define dexpreopt-remove-classes.dex |
| 30 | $(hide) $(AAPT) remove $(1) classes.dex |
| 31 | endef |
| 32 | |
| 33 | # $(1): the input .jar or .apk file |
| 34 | # $(2): the output .odex file |
| 35 | define dexpreopt-one-file |
| 36 | $(hide) $(DEXPREOPT) --dexopt=$(DEXPREOPT_DEXOPT) --build-dir=$(DEXPREOPT_BUILD_DIR) \ |
| 37 | --product-dir=$(DEXPREOPT_PRODUCT_DIR) --boot-dir=$(DEXPREOPT_BOOT_JAR_DIR) \ |
Dan Bornstein | c8c09e2 | 2010-09-29 11:54:15 -0700 | [diff] [blame] | 38 | --boot-jars=$(DEXPREOPT_BOOT_JARS) $(DEXPREOPT_UNIPROCESSOR) \ |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 39 | $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(1)) \ |
| 40 | $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(2)) |
| 41 | endef |
| 42 | |
| 43 | # $(1): boot jar module name |
| 44 | define _dexpreopt-boot-jar |
| 45 | $(eval _dbj_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).jar) |
| 46 | $(eval _dbj_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).odex) |
| 47 | $(eval _dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar) |
Ying Wang | a83940f | 2010-09-24 18:09:04 -0700 | [diff] [blame] | 48 | $(eval _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] | 49 | $(eval $(_dbj_odex): PRIVATE_DBJ_JAR := $(_dbj_jar)) |
| 50 | $(_dbj_odex) : $(_dbj_src_jar) | $(ACP) $(DEXPREOPT) $(DEXOPT) |
| 51 | @echo "Dexpreopt Boot Jar: $$@" |
| 52 | $(hide) rm -f $$@ |
| 53 | $(hide) mkdir -p $$(dir $$@) |
Ying Wang | 84ed6fa | 2011-01-18 17:21:20 -0800 | [diff] [blame] | 54 | $(hide) $(ACP) -fp $$< $$(PRIVATE_DBJ_JAR) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 55 | $$(call dexpreopt-one-file,$$(PRIVATE_DBJ_JAR),$$@) |
| 56 | |
| 57 | $(_dbj_jar_no_dex) : $(_dbj_src_jar) | $(ACP) $(AAPT) |
| 58 | $$(call copy-file-to-target) |
| 59 | $$(call dexpreopt-remove-classes.dex,$$@) |
| 60 | |
| 61 | $(eval _dbj_jar :=) |
| 62 | $(eval _dbj_odex :=) |
Ying Wang | 84ed6fa | 2011-01-18 17:21:20 -0800 | [diff] [blame] | 63 | $(eval _dbj_jar_no_dex :=) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 64 | $(eval _dbj_src_jar :=) |
| 65 | endef |
| 66 | |
| 67 | $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar,$(b)))) |
| 68 | |
| 69 | # $(1): the rest list of boot jars |
| 70 | define _build-dexpreopt-boot-jar-dependency-pair |
| 71 | $(if $(filter 1,$(words $(1)))$(filter 0,$(words $(1))),,\ |
| 72 | $(eval _bdbjdp_target := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 2,$(1)).odex) \ |
| 73 | $(eval _bdbjdp_dep := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 1,$(1)).odex) \ |
| 74 | $(eval $(call add-dependency,$(_bdbjdp_target),$(_bdbjdp_dep))) \ |
| 75 | $(eval $(call _build-dexpreopt-boot-jar-dependency-pair,$(wordlist 2,999,$(1))))) |
| 76 | endef |
| 77 | |
| 78 | define _build-dexpreopt-boot-jar-dependency |
| 79 | $(call _build-dexpreopt-boot-jar-dependency-pair,$(DEXPREOPT_BOOT_JARS_MODULES)) |
| 80 | endef |
| 81 | |
| 82 | $(eval $(call _build-dexpreopt-boot-jar-dependency)) |