blob: 439f7e56593087af748dce64eedadbed5aed4ad2 [file] [log] [blame]
Ying Wange7874c42010-09-17 16:36:06 -07001####################################
Brian Carlstromced4bff2013-11-14 23:44:56 -08002# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
Ying Wange7874c42010-09-17 16:36:06 -07003#
4####################################
5
Brian Carlstromced4bff2013-11-14 23:44:56 -08006# list of boot classpath jars for dexpreopt
Ying Wangad6674c2014-01-07 14:31:49 -08007DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
8DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
Ying Wang0650d152013-07-23 17:57:38 -07009PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
Ying Wange7874c42010-09-17 16:36:06 -070010
Narayan Kamath89ec4962014-08-05 14:51:08 +010011PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar))
12
Ying Wange7874c42010-09-17 16:36:06 -070013DEXPREOPT_BUILD_DIR := $(OUT_DIR)
Brian Carlstromced4bff2013-11-14 23:44:56 -080014DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars
15DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH))
Ying Wange7874c42010-09-17 16:36:06 -070016DEXPREOPT_BOOT_JAR_DIR := system/framework
Brian Carlstromced4bff2013-11-14 23:44:56 -080017DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
Dan Bornsteinc8c09e22010-09-29 11:54:15 -070018
Ying Wangd54520a2014-12-08 14:46:29 -080019# The default value for LOCAL_DEX_PREOPT
20DEX_PREOPT_DEFAULT ?= true
21
Alex Light4e358ab2016-06-16 14:47:10 -070022# 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 '%'
24SYSTEM_OTHER_ODEX_FILTER ?= app/% priv-app/%
25
Nicolas Geoffraycdd43432017-03-24 14:45:59 +000026# Method returning whether the install path $(1) should be for system_other.
Andreas Gampe4ed21d12017-06-16 10:24:54 -070027# Under SANITIZE_LITE, we do not want system_other. Just put things under /data/asan.
28ifeq ($(SANITIZE_LITE),true)
29install-on-system-other =
30else
Nicolas Geoffray4a0ad4a2017-06-12 15:19:16 +010031install-on-system-other = $(filter-out $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(basename $(notdir $(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(1)))))
Andreas Gampe4ed21d12017-06-16 10:24:54 -070032endif
Nicolas Geoffraycdd43432017-03-24 14:45:59 +000033
Nicolas Geoffray2ad52612015-12-15 09:53:05 +000034# The default values for pre-opting: always preopt PIC.
35# Conditional to building on linux, as dex2oat currently does not work on darwin.
Andreas Gampe6c6c51a2016-03-10 15:07:27 -080036ifeq ($(HOST_OS),linux)
Andreas Gampe6c6c51a2016-03-10 15:07:27 -080037 WITH_DEXPREOPT ?= true
Andreas Gampe4df56572016-03-10 15:34:46 -080038# For an eng build only pre-opt the boot image. This gives reasonable performance and still
39# allows a simple workflow: building in frameworks/base and syncing.
40 ifeq (eng,$(TARGET_BUILD_VARIANT))
41 WITH_DEXPREOPT_BOOT_IMG_ONLY ?= true
Nicolas Geoffray7effde02015-12-18 09:58:22 +000042 endif
Andreas Gampea20910f2016-04-29 14:34:10 -070043# Add mini-debug-info to the boot classpath unless explicitly asked not to.
44 ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
45 PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info
46 endif
Nicolas Geoffray2ad52612015-12-15 09:53:05 +000047endif
48
Ying Wang3a61eeb2016-03-11 10:32:01 -080049GLOBAL_DEXPREOPT_FLAGS :=
Ying Wang3a61eeb2016-03-11 10:32:01 -080050
Ying Wange7874c42010-09-17 16:36:06 -070051# $(1): the .jar or .apk to remove classes.dex
52define dexpreopt-remove-classes.dex
Brian Carlstromfca81452014-06-30 10:09:56 -070053$(hide) zip --quiet --delete $(1) classes.dex; \
54dex_index=2; \
55while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
56 let dex_index=dex_index+1; \
57done
Ying Wange7874c42010-09-17 16:36:06 -070058endef
59
Brian Carlstromced4bff2013-11-14 23:44:56 -080060# Special rules for building stripped boot jars that override java_library.mk rules
Ying Wange7874c42010-09-17 16:36:06 -070061
62# $(1): boot jar module name
Brian Carlstromced4bff2013-11-14 23:44:56 -080063define _dexpreopt-boot-jar-remove-classes.dex
64_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
65_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
Ying Wange7874c42010-09-17 16:36:06 -070066
Dan Willemsen7f016152016-02-29 17:52:39 -080067$$(_dbj_jar_no_dex) : $$(_dbj_src_jar)
Ying Wange7874c42010-09-17 16:36:06 -070068 $$(call copy-file-to-target)
Brian Carlstrom71fc41d2013-09-12 00:22:42 -070069ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
Ying Wange7874c42010-09-17 16:36:06 -070070 $$(call dexpreopt-remove-classes.dex,$$@)
Brian Carlstrom71fc41d2013-09-12 00:22:42 -070071endif
Ying Wange7874c42010-09-17 16:36:06 -070072
Brian Carlstromced4bff2013-11-14 23:44:56 -080073_dbj_jar_no_dex :=
74_dbj_src_jar :=
Ying Wange7874c42010-09-17 16:36:06 -070075endef
76
Brian Carlstromced4bff2013-11-14 23:44:56 -080077$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
Ying Wange7874c42010-09-17 16:36:06 -070078
Brian Carlstromced4bff2013-11-14 23:44:56 -080079include $(BUILD_SYSTEM)/dex_preopt_libart.mk
80
81# Define dexpreopt-one-file based on current default runtime.
Ying Wangb9aa5d42014-05-13 13:57:28 -070082# $(1): the input .jar or .apk file
83# $(2): the output .odex file
Brian Carlstromced4bff2013-11-14 23:44:56 -080084define dexpreopt-one-file
Ying Wangb9aa5d42014-05-13 13:57:28 -070085$(call dex2oat-one-file,$(1),$(2))
Ying Wange7874c42010-09-17 16:36:06 -070086endef
87
Nicolas Geoffray75c08b22014-10-06 14:53:59 +010088DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
Ying Wangb9aa5d42014-05-13 13:57:28 -070089DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
90ifdef TARGET_2ND_ARCH
91$(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
92endif # TARGET_2ND_ARCH