blob: 8c1a606ce9ccbfea33a720613ee22e49caf18cd4 [file] [log] [blame]
Brian Carlstromced4bff2013-11-14 23:44:56 -08001# dexpreopt_odex_install.mk is used to define odex creation rules for JARs and APKs
2# This file depends on variables set in base_rules.mk
3# Output variables: LOCAL_DEX_PREOPT, built_odex, dexpreopt_boot_jar_module
4
5# Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc
6LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT))
7ifneq (true,$(WITH_DEXPREOPT))
8 LOCAL_DEX_PREOPT :=
9else # WITH_DEXPREOPT=true
10 ifeq (,$(TARGET_BUILD_APPS)) # TARGET_BUILD_APPS empty
Ying Wang9db168c2014-01-03 16:24:56 -080011 ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined
Ying Wangedfd55a2014-07-09 10:57:32 -070012 ifneq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Installed to system.img.
13 ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty
Ying Wang20ebd2e2014-10-07 18:07:23 -070014 # If we have product-specific config for this module?
15 ifeq (disable,$(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG))
16 LOCAL_DEX_PREOPT := false
17 else
18 LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
19 endif
Ying Wangedfd55a2014-07-09 10:57:32 -070020 else # LOCAL_APK_LIBRARIES not empty
21 LOCAL_DEX_PREOPT := nostripping
22 endif # LOCAL_APK_LIBRARIES not empty
23 endif # Installed to system.img.
Ying Wang9db168c2014-01-03 16:24:56 -080024 endif # LOCAL_DEX_PREOPT undefined
Brian Carlstromced4bff2013-11-14 23:44:56 -080025 endif # TARGET_BUILD_APPS empty
26endif # WITH_DEXPREOPT=true
27ifeq (false,$(LOCAL_DEX_PREOPT))
28 LOCAL_DEX_PREOPT :=
29endif
30ifdef LOCAL_UNINSTALLABLE_MODULE
31LOCAL_DEX_PREOPT :=
32endif
Colin Crossf229de42017-10-05 16:01:00 -070033ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR))) # contains no java code
Brian Carlstromced4bff2013-11-14 23:44:56 -080034LOCAL_DEX_PREOPT :=
35endif
Mathieu Chartierf834ecc2017-08-28 14:19:35 -070036# if WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true and module is not in boot class path skip
37# Also preopt system server jars since selinux prevents system server from loading anything from
38# /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
39# or performance.
40ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
41ifeq ($(filter $(PRODUCT_SYSTEM_SERVER_JARS) $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
Alex Light7326f7b2014-08-04 17:09:41 -070042LOCAL_DEX_PREOPT :=
43endif
44endif
Alex Light4e358ab2016-06-16 14:47:10 -070045# if installing into system, and odex are being installed into system_other, don't strip
46ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
47ifeq ($(LOCAL_DEX_PREOPT),true)
Nicolas Geoffraycdd43432017-03-24 14:45:59 +000048ifneq ($(call install-on-system-other, $(my_module_path)),)
Alex Light4e358ab2016-06-16 14:47:10 -070049LOCAL_DEX_PREOPT := nostripping
50endif
51endif
52endif
Brian Carlstromced4bff2013-11-14 23:44:56 -080053
54built_odex :=
David Brazdil70470162016-08-25 13:50:15 +010055built_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -080056built_art :=
Brian Carlstromced4bff2013-11-14 23:44:56 -080057installed_odex :=
David Brazdil70470162016-08-25 13:50:15 +010058installed_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -080059installed_art :=
Ying Wang74c98502014-05-19 13:03:36 -070060built_installed_odex :=
David Brazdil70470162016-08-25 13:50:15 +010061built_installed_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -080062built_installed_art :=
63
Brian Carlstromced4bff2013-11-14 23:44:56 -080064ifdef LOCAL_DEX_PREOPT
Mathieu Chartierfcc8d8b2017-05-05 17:22:37 -070065
66ifeq (false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))
67LOCAL_DEX_PREOPT_GENERATE_PROFILE := false
68endif
69
Mathieu Chartier98f44b72017-05-09 19:17:33 -070070ifdef LOCAL_VENDOR_MODULE
71ifeq (true,$(LOCAL_DEX_PREOPT_GENERATE_PROFILE))
72$(error profiles are not supported for vendor modules)
73endif
74else
Mathieu Chartierfcc8d8b2017-05-05 17:22:37 -070075ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE
76# If LOCAL_DEX_PREOPT_GENERATE_PROFILE is not defined, default it based on the existence of the
77# profile class listing. TODO: Use product specific directory here.
78my_classes_directory := $(PRODUCT_DEX_PREOPT_PROFILE_DIR)
79LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING := $(my_classes_directory)/$(LOCAL_MODULE).prof.txt
80ifneq (,$(wildcard $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)))
81# Profile listing exists, use it to generate the profile.
82ifeq ($(LOCAL_DEX_PREOPT_APP_IMAGE),)
83LOCAL_DEX_PREOPT_APP_IMAGE := true
84endif
85LOCAL_DEX_PREOPT_GENERATE_PROFILE := true
86endif
87endif
Mathieu Chartier98f44b72017-05-09 19:17:33 -070088endif
Mathieu Chartierfcc8d8b2017-05-05 17:22:37 -070089
Brian Carlstromced4bff2013-11-14 23:44:56 -080090dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
91ifdef dexpreopt_boot_jar_module
Brian Carlstromced4bff2013-11-14 23:44:56 -080092# For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
93# We use this installed_odex trick to get boot.art installed.
94installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
Ying Wangb9aa5d42014-05-13 13:57:28 -070095# Append the odex for the 2nd arch if we have one.
96installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
Brian Carlstromced4bff2013-11-14 23:44:56 -080097else # boot jar
Ying Wangb9aa5d42014-05-13 13:57:28 -070098ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
Ying Wangc7ca6172015-03-09 17:17:51 -070099# For a Java library, by default we build odex for both 1st arch and 2nd arch.
100# But it can be overridden with "LOCAL_MULTILIB := first".
101ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
102# For system server jars, we build for only "first".
103my_module_multilib := first
104else
105my_module_multilib := $(LOCAL_MULTILIB)
106endif
Ying Wangb9aa5d42014-05-13 13:57:28 -0700107# #################################################
108# Odex for the 1st arch
Ying Wangdb48da72014-09-13 11:26:39 -0700109my_2nd_arch_prefix :=
110include $(BUILD_SYSTEM)/setup_one_odex.mk
Ying Wangb9aa5d42014-05-13 13:57:28 -0700111# #################################################
112# Odex for the 2nd arch
113ifdef TARGET_2ND_ARCH
Ying Wang62630222016-04-20 11:53:39 -0700114ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
Ying Wangc7ca6172015-03-09 17:17:51 -0700115ifneq (first,$(my_module_multilib))
Ying Wangdb48da72014-09-13 11:26:39 -0700116my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
117include $(BUILD_SYSTEM)/setup_one_odex.mk
Ying Wangc7ca6172015-03-09 17:17:51 -0700118endif # my_module_multilib is not first.
Ying Wang62630222016-04-20 11:53:39 -0700119endif # TARGET_TRANSLATE_2ND_ARCH not true
Ying Wangb9aa5d42014-05-13 13:57:28 -0700120endif # TARGET_2ND_ARCH
121# #################################################
122else # must be APPS
Ying Wangdb48da72014-09-13 11:26:39 -0700123# The preferred arch
124my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
125include $(BUILD_SYSTEM)/setup_one_odex.mk
Ying Wang7a899192014-09-15 11:45:52 -0700126ifdef TARGET_2ND_ARCH
Ying Wangdb48da72014-09-13 11:26:39 -0700127ifeq ($(LOCAL_MULTILIB),both)
128# The non-preferred arch
129my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
130include $(BUILD_SYSTEM)/setup_one_odex.mk
131endif # LOCAL_MULTILIB is both
Ying Wang7a899192014-09-15 11:45:52 -0700132endif # TARGET_2ND_ARCH
Ying Wangb9aa5d42014-05-13 13:57:28 -0700133endif # LOCAL_MODULE_CLASS
Ying Wang7a899192014-09-15 11:45:52 -0700134endif # boot jar
Brian Carlstromced4bff2013-11-14 23:44:56 -0800135
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800136built_odex := $(strip $(built_odex))
David Brazdil70470162016-08-25 13:50:15 +0100137built_vdex := $(strip $(built_vdex))
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800138built_art := $(strip $(built_art))
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800139installed_odex := $(strip $(installed_odex))
David Brazdil70470162016-08-25 13:50:15 +0100140installed_vdex := $(strip $(installed_vdex))
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800141installed_art := $(strip $(installed_art))
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800142
Brian Carlstromced4bff2013-11-14 23:44:56 -0800143ifdef built_odex
Mathieu Chartier2ac264f2017-03-03 11:17:36 -0800144ifeq (true,$(LOCAL_DEX_PREOPT_GENERATE_PROFILE))
145ifndef LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING
146$(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING))
147endif
148my_built_profile := $(dir $(LOCAL_BUILT_MODULE))/profile.prof
149my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
150$(built_odex): $(my_built_profile)
151$(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile)
Dan Willemsen3d072d52017-03-20 13:54:41 -0700152$(my_built_profile): PRIVATE_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
Mathieu Chartier2ac264f2017-03-03 11:17:36 -0800153$(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location)
154$(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
155$(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
156$(my_built_profile): $(PROFMAN)
Dan Willemsen3d072d52017-03-20 13:54:41 -0700157$(my_built_profile): $(LOCAL_BUILT_MODULE)
Mathieu Chartier2ac264f2017-03-03 11:17:36 -0800158$(my_built_profile):
159 $(hide) mkdir -p $(dir $@)
160 ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
161 --create-profile-from=$(PRIVATE_SOURCE_CLASSES) \
Dan Willemsen3d072d52017-03-20 13:54:41 -0700162 --apk=$(PRIVATE_BUILT_MODULE) \
Mathieu Chartier2ac264f2017-03-03 11:17:36 -0800163 --dex-location=$(PRIVATE_DEX_LOCATION) \
164 --reference-profile-file=$@
Mathieu Chartier98f44b72017-05-09 19:17:33 -0700165my_installed_profile := $(LOCAL_INSTALLED_MODULE).prof
166$(eval $(call copy-one-file,$(my_built_profile),$(my_installed_profile)))
167build_installed_profile:=$(my_built_profile):$(my_installed_profile)
Mathieu Chartier2ac264f2017-03-03 11:17:36 -0800168else
Mathieu Chartier98f44b72017-05-09 19:17:33 -0700169build_installed_profile:=
170my_installed_profile :=
Mathieu Chartier2ac264f2017-03-03 11:17:36 -0800171$(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS :=
172endif
173
Ying Wang20ebd2e2014-10-07 18:07:23 -0700174ifndef LOCAL_DEX_PREOPT_FLAGS
175LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
176ifndef LOCAL_DEX_PREOPT_FLAGS
177LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)
178endif
179endif
Nicolas Geoffrayb08ada12017-03-22 12:36:05 +0000180
Mathieu Chartier6228ec22017-06-23 10:44:45 -0700181my_system_server_compiler_filter := $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)
182ifeq (,$(my_system_server_compiler_filter))
183my_system_server_compiler_filter := speed
184endif
185
Mathieu Chartierabcf66b2017-06-16 11:17:53 -0700186ifeq (,$(filter --compiler-filter=%, $(LOCAL_DEX_PREOPT_FLAGS)))
Mathieu Chartier6228ec22017-06-23 10:44:45 -0700187 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
188 # Jars of system server, use the product option if it is set, speed otherwise.
189 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=$(my_system_server_compiler_filter)
Mathieu Chartierabcf66b2017-06-16 11:17:53 -0700190 else
Mathieu Chartier6228ec22017-06-23 10:44:45 -0700191 ifneq (,$(filter $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(LOCAL_MODULE)))
192 # Apps loaded into system server, and apps the product default to being compiled with the
193 # 'speed' compiler filter.
194 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed
Mathieu Chartier229d0532017-05-05 14:59:06 -0700195 else
Mathieu Chartier6228ec22017-06-23 10:44:45 -0700196 ifeq (true,$(LOCAL_DEX_PREOPT_GENERATE_PROFILE))
197 # For non system server jars, use speed-profile when we have a profile.
198 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed-profile
199 else
200 # If no compiler filter is specified, default to 'quicken' to save on storage.
201 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=quicken
202 endif
Mathieu Chartier229d0532017-05-05 14:59:06 -0700203 endif
Nicolas Geoffray24f54692017-03-30 13:50:12 +0100204 endif
Nicolas Geoffrayb08ada12017-03-22 12:36:05 +0000205endif
206
Mathieu Chartierf0db9082017-06-23 14:47:56 -0700207# PRODUCT_SYSTEM_SERVER_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO.
208my_system_server_debug_info := $(PRODUCT_SYSTEM_SERVER_DEBUG_INFO)
209ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
210# Only enable for non-eng builds.
211ifeq (,$(my_system_server_debug_info))
212my_system_server_debug_info := true
213endif
214endif
215
216ifeq (true, $(my_system_server_debug_info))
217 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
218 LOCAL_DEX_PREOPT_FLAGS += --generate-mini-debug-info
219 endif
220endif
221
Ying Wang20ebd2e2014-10-07 18:07:23 -0700222$(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
David Brazdil70470162016-08-25 13:50:15 +0100223$(built_vdex): $(built_odex)
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800224$(built_art): $(built_odex)
Brian Carlstromced4bff2013-11-14 23:44:56 -0800225endif
226
227# Add the installed_odex to the list of installed files for this module.
Ying Wang74c98502014-05-19 13:03:36 -0700228ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
David Brazdil70470162016-08-25 13:50:15 +0100229ALL_MODULES.$(my_register_name).INSTALLED += $(installed_vdex)
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800230ALL_MODULES.$(my_register_name).INSTALLED += $(installed_art)
Mathieu Chartier98f44b72017-05-09 19:17:33 -0700231ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_profile)
Ying Wang74c98502014-05-19 13:03:36 -0700232ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
David Brazdil70470162016-08-25 13:50:15 +0100233ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_vdex)
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800234ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_art)
Mathieu Chartier98f44b72017-05-09 19:17:33 -0700235ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(build_installed_profile)
Ying Wang74c98502014-05-19 13:03:36 -0700236
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800237# Record dex-preopt config.
238DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
239DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
240DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
241DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
Dan Willemsen05a2b932017-03-20 18:31:17 -0700242DEXPREOPT.$(LOCAL_MODULE).VENDOR_MODULE := $(LOCAL_VENDOR_MODULE)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800243DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
244DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
245DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
246DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \
247 $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
248
249
David Brazdil70470162016-08-25 13:50:15 +0100250# Make sure to install the .odex and .vdex when you run "make <module_name>"
Mathieu Chartier98f44b72017-05-09 19:17:33 -0700251$(my_all_targets): $(installed_odex) $(installed_vdex) $(installed_art) $(my_installed_profile)
Ying Wang5c7fed22014-01-22 16:50:21 -0800252
Brian Carlstromced4bff2013-11-14 23:44:56 -0800253endif # LOCAL_DEX_PREOPT