blob: 270e5f4fed54ff5d55ae13c8b42b0b7cab247c8b [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 ifeq (eng,$(TARGET_BUILD_VARIANT))
Nicolas Geoffrayed6ee7b2018-01-18 15:47:23 +000039 # Don't strip for quick development turnarounds.
40 DEX_PREOPT_DEFAULT := nostripping
41 # For an eng build only pre-opt the boot image and system server. This gives reasonable performance
42 # and still allows a simple workflow: building in frameworks/base and syncing.
Mathieu Chartierf834ecc2017-08-28 14:19:35 -070043 WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true
Nicolas Geoffray7effde02015-12-18 09:58:22 +000044 endif
Nicolas Geoffrayed6ee7b2018-01-18 15:47:23 +000045 # Add mini-debug-info to the boot classpath unless explicitly asked not to.
Andreas Gampea20910f2016-04-29 14:34:10 -070046 ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
47 PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info
48 endif
Mathieu Chartier25942302018-03-06 13:09:01 -080049
50 # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter
51 # only. b/74209329
52 ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
53 ifneq (true,$(WITH_DEXPREOPT))
54 ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
55 $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
56 endif
57 endif
58 endif
Nicolas Geoffray2ad52612015-12-15 09:53:05 +000059endif
60
Ying Wang3a61eeb2016-03-11 10:32:01 -080061GLOBAL_DEXPREOPT_FLAGS :=
Ying Wang3a61eeb2016-03-11 10:32:01 -080062
Brian Carlstromced4bff2013-11-14 23:44:56 -080063# Special rules for building stripped boot jars that override java_library.mk rules
Ying Wange7874c42010-09-17 16:36:06 -070064
65# $(1): boot jar module name
Brian Carlstromced4bff2013-11-14 23:44:56 -080066define _dexpreopt-boot-jar-remove-classes.dex
67_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
68_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
Ying Wange7874c42010-09-17 16:36:06 -070069
Colin Crossea1629e2017-10-06 13:55:48 -070070$(call dexpreopt-copy-jar,$$(_dbj_src_jar),$$(_dbj_jar_no_dex),$(DEX_PREOPT_DEFAULT))
Ying Wange7874c42010-09-17 16:36:06 -070071
Brian Carlstromced4bff2013-11-14 23:44:56 -080072_dbj_jar_no_dex :=
73_dbj_src_jar :=
Ying Wange7874c42010-09-17 16:36:06 -070074endef
75
Brian Carlstromced4bff2013-11-14 23:44:56 -080076$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
Ying Wange7874c42010-09-17 16:36:06 -070077
Brian Carlstromced4bff2013-11-14 23:44:56 -080078include $(BUILD_SYSTEM)/dex_preopt_libart.mk
79
80# Define dexpreopt-one-file based on current default runtime.
Ying Wangb9aa5d42014-05-13 13:57:28 -070081# $(1): the input .jar or .apk file
82# $(2): the output .odex file
Brian Carlstromced4bff2013-11-14 23:44:56 -080083define dexpreopt-one-file
Ying Wangb9aa5d42014-05-13 13:57:28 -070084$(call dex2oat-one-file,$(1),$(2))
Ying Wange7874c42010-09-17 16:36:06 -070085endef
86
Nicolas Geoffray75c08b22014-10-06 14:53:59 +010087DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
Ying Wangb9aa5d42014-05-13 13:57:28 -070088DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
89ifdef TARGET_2ND_ARCH
90$(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
91endif # TARGET_2ND_ARCH