blob: b0364439a08604ba07259b61bad5582f47f01614 [file] [log] [blame]
Ying Wange7874c42010-09-17 16:36:06 -07001####################################
2# Dexpreopt on the boot jars
3#
4####################################
5
6# TODO: replace it with device's BOOTCLASSPATH
7DEXPREOPT_BOOT_JARS := core:bouncycastle:ext:framework:android.policy:services:core-junit
8DEXPREOPT_BOOT_JARS_MODULES := $(subst :, ,$(DEXPREOPT_BOOT_JARS))
9
10DEXPREOPT_BUILD_DIR := $(OUT_DIR)
11DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(PRODUCT_OUT))/dex_bootjars
12DEXPREOPT_BOOT_JAR_DIR := system/framework
13DEXPREOPT_DEXOPT := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXOPT))
14
15DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_BUILD_DIR)/$(DEXPREOPT_PRODUCT_DIR)/$(DEXPREOPT_BOOT_JAR_DIR)
16
17DEXPREOPT_BOOT_ODEXS := $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),\
18 $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(b).odex)
19
20# $(1): the .jar or .apk to remove classes.dex
21define dexpreopt-remove-classes.dex
22$(hide) $(AAPT) remove $(1) classes.dex
23endef
24
25# $(1): the input .jar or .apk file
26# $(2): the output .odex file
27define dexpreopt-one-file
28$(hide) $(DEXPREOPT) --dexopt=$(DEXPREOPT_DEXOPT) --build-dir=$(DEXPREOPT_BUILD_DIR) \
29 --product-dir=$(DEXPREOPT_PRODUCT_DIR) --boot-dir=$(DEXPREOPT_BOOT_JAR_DIR) \
30 --boot-jars=$(DEXPREOPT_BOOT_JARS) \
31 $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(1)) \
32 $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(2))
33endef
34
35# $(1): boot jar module name
36define _dexpreopt-boot-jar
37$(eval _dbj_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).jar)
38$(eval _dbj_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).odex)
39$(eval _dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar)
40$(eval _dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.dex.jar)
41$(eval $(_dbj_odex): PRIVATE_DBJ_JAR := $(_dbj_jar))
42$(_dbj_odex) : $(_dbj_src_jar) | $(ACP) $(DEXPREOPT) $(DEXOPT)
43 @echo "Dexpreopt Boot Jar: $$@"
44 $(hide) rm -f $$@
45 $(hide) mkdir -p $$(dir $$@)
46 $(hide) $(ACP) -fpt $$< $$(PRIVATE_DBJ_JAR)
47 $$(call dexpreopt-one-file,$$(PRIVATE_DBJ_JAR),$$@)
48
49$(_dbj_jar_no_dex) : $(_dbj_src_jar) | $(ACP) $(AAPT)
50 $$(call copy-file-to-target)
51 $$(call dexpreopt-remove-classes.dex,$$@)
52
53$(eval _dbj_jar :=)
54$(eval _dbj_odex :=)
55$(eval _dbj_src_jar :=)
56endef
57
58$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar,$(b))))
59
60# $(1): the rest list of boot jars
61define _build-dexpreopt-boot-jar-dependency-pair
62$(if $(filter 1,$(words $(1)))$(filter 0,$(words $(1))),,\
63 $(eval _bdbjdp_target := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 2,$(1)).odex) \
64 $(eval _bdbjdp_dep := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 1,$(1)).odex) \
65 $(eval $(call add-dependency,$(_bdbjdp_target),$(_bdbjdp_dep))) \
66 $(eval $(call _build-dexpreopt-boot-jar-dependency-pair,$(wordlist 2,999,$(1)))))
67endef
68
69define _build-dexpreopt-boot-jar-dependency
70$(call _build-dexpreopt-boot-jar-dependency-pair,$(DEXPREOPT_BOOT_JARS_MODULES))
71endef
72
73$(eval $(call _build-dexpreopt-boot-jar-dependency))