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 | |
Alex Light | 4e358ab | 2016-06-16 14:47:10 -0700 | [diff] [blame] | 22 | # The default filter for which files go into the system_other image (if it is |
| 23 | # being used). To bundle everything one should set this to '%' |
| 24 | SYSTEM_OTHER_ODEX_FILTER ?= app/% priv-app/% |
| 25 | |
Nicolas Geoffray | 2ad5261 | 2015-12-15 09:53:05 +0000 | [diff] [blame] | 26 | # The default values for pre-opting: always preopt PIC. |
| 27 | # Conditional to building on linux, as dex2oat currently does not work on darwin. |
Andreas Gampe | 6c6c51a | 2016-03-10 15:07:27 -0800 | [diff] [blame] | 28 | ifeq ($(HOST_OS),linux) |
Andreas Gampe | 6c6c51a | 2016-03-10 15:07:27 -0800 | [diff] [blame] | 29 | WITH_DEXPREOPT ?= true |
Andreas Gampe | 4df5657 | 2016-03-10 15:34:46 -0800 | [diff] [blame] | 30 | # For an eng build only pre-opt the boot image. This gives reasonable performance and still |
| 31 | # allows a simple workflow: building in frameworks/base and syncing. |
| 32 | ifeq (eng,$(TARGET_BUILD_VARIANT)) |
| 33 | WITH_DEXPREOPT_BOOT_IMG_ONLY ?= true |
Nicolas Geoffray | 7effde0 | 2015-12-18 09:58:22 +0000 | [diff] [blame] | 34 | endif |
Andreas Gampe | a20910f | 2016-04-29 14:34:10 -0700 | [diff] [blame] | 35 | # Add mini-debug-info to the boot classpath unless explicitly asked not to. |
| 36 | ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO)) |
| 37 | PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info |
| 38 | endif |
Nicolas Geoffray | 2ad5261 | 2015-12-15 09:53:05 +0000 | [diff] [blame] | 39 | endif |
| 40 | |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 41 | GLOBAL_DEXPREOPT_FLAGS := |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 42 | |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 43 | # $(1): the .jar or .apk to remove classes.dex |
| 44 | define dexpreopt-remove-classes.dex |
Brian Carlstrom | fca8145 | 2014-06-30 10:09:56 -0700 | [diff] [blame] | 45 | $(hide) zip --quiet --delete $(1) classes.dex; \ |
| 46 | dex_index=2; \ |
| 47 | while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \ |
| 48 | let dex_index=dex_index+1; \ |
| 49 | done |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 50 | endef |
| 51 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 52 | # 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] | 53 | |
| 54 | # $(1): boot jar module name |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 55 | define _dexpreopt-boot-jar-remove-classes.dex |
| 56 | _dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar |
| 57 | _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] | 58 | |
Dan Willemsen | 7f01615 | 2016-02-29 17:52:39 -0800 | [diff] [blame] | 59 | $$(_dbj_jar_no_dex) : $$(_dbj_src_jar) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 60 | $$(call copy-file-to-target) |
Brian Carlstrom | 71fc41d | 2013-09-12 00:22:42 -0700 | [diff] [blame] | 61 | ifneq ($(DEX_PREOPT_DEFAULT),nostripping) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 62 | $$(call dexpreopt-remove-classes.dex,$$@) |
Brian Carlstrom | 71fc41d | 2013-09-12 00:22:42 -0700 | [diff] [blame] | 63 | endif |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 64 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 65 | _dbj_jar_no_dex := |
| 66 | _dbj_src_jar := |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 67 | endef |
| 68 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 69 | $(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] | 70 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 71 | include $(BUILD_SYSTEM)/dex_preopt_libart.mk |
| 72 | |
| 73 | # Define dexpreopt-one-file based on current default runtime. |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 74 | # $(1): the input .jar or .apk file |
| 75 | # $(2): the output .odex file |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 76 | define dexpreopt-one-file |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 77 | $(call dex2oat-one-file,$(1),$(2)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 78 | endef |
| 79 | |
Nicolas Geoffray | 75c08b2 | 2014-10-06 14:53:59 +0100 | [diff] [blame] | 80 | DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY) |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 81 | DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) |
| 82 | ifdef TARGET_2ND_ARCH |
| 83 | $(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) |
| 84 | endif # TARGET_2ND_ARCH |