blob: d475a00624ae591ef5a615d6ce1316999d983ccc [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
Nicolas Geoffray3972a472018-01-09 11:46:30 +00003# Output variables: LOCAL_DEX_PREOPT, LOCAL_UNCOMPRESS_DEX, built_odex,
4# dexpreopt_boot_jar_module
5
6# We explicitly uncompress APKs of privileged apps, and used by
7# privileged apps
8LOCAL_UNCOMPRESS_DEX := false
9ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))
Colin Cross0a69bb62018-10-09 16:14:44 -070010 ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
Nicolas Geoffray3972a472018-01-09 11:46:30 +000011 LOCAL_UNCOMPRESS_DEX := true
Colin Cross0a69bb62018-10-09 16:14:44 -070012 else
13 ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE)))
14 LOCAL_UNCOMPRESS_DEX := true
15 endif # PRODUCT_LOADED_BY_PRIVILEGED_MODULES
16 endif # LOCAL_PRIVILEGED_MODULE
Nicolas Geoffray3972a472018-01-09 11:46:30 +000017endif # DONT_UNCOMPRESS_PRIV_APPS_DEXS
Brian Carlstromced4bff2013-11-14 23:44:56 -080018
19# Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc
20LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT))
21ifneq (true,$(WITH_DEXPREOPT))
22 LOCAL_DEX_PREOPT :=
23else # WITH_DEXPREOPT=true
24 ifeq (,$(TARGET_BUILD_APPS)) # TARGET_BUILD_APPS empty
Ying Wang9db168c2014-01-03 16:24:56 -080025 ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined
Ying Wangedfd55a2014-07-09 10:57:32 -070026 ifneq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Installed to system.img.
27 ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty
Ying Wang20ebd2e2014-10-07 18:07:23 -070028 # If we have product-specific config for this module?
29 ifeq (disable,$(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG))
30 LOCAL_DEX_PREOPT := false
31 else
32 LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
33 endif
Ying Wangedfd55a2014-07-09 10:57:32 -070034 else # LOCAL_APK_LIBRARIES not empty
35 LOCAL_DEX_PREOPT := nostripping
36 endif # LOCAL_APK_LIBRARIES not empty
Mathieu Chartierfd5dfb82018-07-12 18:17:54 -070037 else
38 # Default to nostripping for non system preopt (enables preopt).
39 # Don't strip in case the oat/vdex version in system ROM doesn't match the one in other
40 # partitions. It needs to be able to fall back to the APK for that case.
41 # Also only enable preopt for non tests.
42 ifeq (,$(filter $(LOCAL_MODULE_TAGS),tests))
43 LOCAL_DEX_PREOPT := nostripping
44 endif
Ying Wangedfd55a2014-07-09 10:57:32 -070045 endif # Installed to system.img.
Ying Wang9db168c2014-01-03 16:24:56 -080046 endif # LOCAL_DEX_PREOPT undefined
Brian Carlstromced4bff2013-11-14 23:44:56 -080047 endif # TARGET_BUILD_APPS empty
48endif # WITH_DEXPREOPT=true
49ifeq (false,$(LOCAL_DEX_PREOPT))
50 LOCAL_DEX_PREOPT :=
51endif
Colin Cross0a69bb62018-10-09 16:14:44 -070052
Brian Carlstromced4bff2013-11-14 23:44:56 -080053ifdef LOCAL_UNINSTALLABLE_MODULE
Colin Cross0a69bb62018-10-09 16:14:44 -070054 LOCAL_DEX_PREOPT :=
Brian Carlstromced4bff2013-11-14 23:44:56 -080055endif
Colin Cross0a69bb62018-10-09 16:14:44 -070056
Colin Crossf229de42017-10-05 16:01:00 -070057ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR))) # contains no java code
Colin Cross0a69bb62018-10-09 16:14:44 -070058 LOCAL_DEX_PREOPT :=
Brian Carlstromced4bff2013-11-14 23:44:56 -080059endif
Colin Cross0a69bb62018-10-09 16:14:44 -070060
Mathieu Chartier418258c2017-08-28 14:19:35 -070061# if WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true and module is not in boot class path skip
62# Also preopt system server jars since selinux prevents system server from loading anything from
63# /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
Mathieu Chartier0fbb8362017-09-15 13:40:48 -070064# or performance. If my_preopt_for_extracted_apk is true, we ignore the only preopt boot image
65# options.
66ifneq (true,$(my_preopt_for_extracted_apk))
Colin Cross0a69bb62018-10-09 16:14:44 -070067 ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
68 ifeq ($(filter $(PRODUCT_SYSTEM_SERVER_JARS) $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
69 LOCAL_DEX_PREOPT :=
70 endif
71 endif
Mathieu Chartier0fbb8362017-09-15 13:40:48 -070072endif
73
Alex Light4e358ab2016-06-16 14:47:10 -070074ifeq ($(LOCAL_DEX_PREOPT),true)
Colin Cross0a69bb62018-10-09 16:14:44 -070075 # Don't strip with dexes we explicitly uncompress (dexopt will not store the dex code).
76 ifeq ($(LOCAL_UNCOMPRESS_DEX),true)
77 LOCAL_DEX_PREOPT := nostripping
78 endif # LOCAL_UNCOMPRESS_DEX
Nicolas Geoffray3972a472018-01-09 11:46:30 +000079
Colin Cross0a69bb62018-10-09 16:14:44 -070080 # system_other isn't there for an OTA, so don't strip
81 # if module is on system, and odex is on system_other.
82 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
83 ifneq ($(call install-on-system-other, $(my_module_path)),)
84 LOCAL_DEX_PREOPT := nostripping
85 endif # install-on-system-other
86 endif # BOARD_USES_SYSTEM_OTHER_ODEX
Nicolas Geoffray3972a472018-01-09 11:46:30 +000087
Colin Cross0a69bb62018-10-09 16:14:44 -070088 # We also don't strip if all dexs are uncompressed (dexopt will not store the dex code),
89 # but that requires to inspect the source file, which is too early at this point (as we
90 # don't know if the source file will actually be used).
91 # See dexpreopt-remove-classes.dex.
Nicolas Geoffray3972a472018-01-09 11:46:30 +000092endif # LOCAL_DEX_PREOPT
Brian Carlstromced4bff2013-11-14 23:44:56 -080093
94built_odex :=
David Brazdil70470162016-08-25 13:50:15 +010095built_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -080096built_art :=
Brian Carlstromced4bff2013-11-14 23:44:56 -080097installed_odex :=
David Brazdil70470162016-08-25 13:50:15 +010098installed_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -080099installed_art :=
Ying Wang74c98502014-05-19 13:03:36 -0700100built_installed_odex :=
David Brazdil70470162016-08-25 13:50:15 +0100101built_installed_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800102built_installed_art :=
Calin Juravlef99ab752018-04-19 20:32:57 -0700103my_process_profile :=
104my_profile_is_text_listing :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800105
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700106ifeq (false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))
Colin Cross0a69bb62018-10-09 16:14:44 -0700107 LOCAL_DEX_PREOPT_GENERATE_PROFILE := false
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700108endif
109
110ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE
Colin Cross0a69bb62018-10-09 16:14:44 -0700111 # If LOCAL_DEX_PREOPT_GENERATE_PROFILE is not defined, default it based on the existence of the
112 # profile class listing. TODO: Use product specific directory here.
113 my_classes_directory := $(PRODUCT_DEX_PREOPT_PROFILE_DIR)
114 LOCAL_DEX_PREOPT_PROFILE := $(my_classes_directory)/$(LOCAL_MODULE).prof
Calin Juravle7d701352018-04-25 15:25:46 -0700115
Colin Cross0a69bb62018-10-09 16:14:44 -0700116 ifneq (,$(wildcard $(LOCAL_DEX_PREOPT_PROFILE)))
117 my_process_profile := true
118 my_profile_is_text_listing := false
119 endif
Calin Juravlef99ab752018-04-19 20:32:57 -0700120else
Colin Cross0a69bb62018-10-09 16:14:44 -0700121 my_process_profile := $(LOCAL_DEX_PREOPT_GENERATE_PROFILE)
122 my_profile_is_text_listing := true
123 LOCAL_DEX_PREOPT_PROFILE := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700124endif
Mathieu Chartier48762292017-09-13 22:08:45 -0700125
Calin Juravlef99ab752018-04-19 20:32:57 -0700126ifeq (true,$(my_process_profile))
Mathieu Chartier48762292017-09-13 22:08:45 -0700127
Colin Cross0a69bb62018-10-09 16:14:44 -0700128 ifeq (,$(LOCAL_DEX_PREOPT_APP_IMAGE))
129 LOCAL_DEX_PREOPT_APP_IMAGE := true
130 endif
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700131
Colin Cross0a69bb62018-10-09 16:14:44 -0700132 ifndef LOCAL_DEX_PREOPT_PROFILE
133 $(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE))
134 endif
135 ifeq (,$(dex_preopt_profile_src_file))
136 $(call pretty-error, Internal error: dex_preopt_profile_src_file must be set)
137 endif
138 my_built_profile := $(dir $(LOCAL_BUILT_MODULE))/profile.prof
139 my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
140 # Remove compressed APK extension.
141 my_dex_location := $(patsubst %.gz,%,$(my_dex_location))
142 $(my_built_profile): PRIVATE_BUILT_MODULE := $(dex_preopt_profile_src_file)
143 $(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location)
144 $(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE)
145 $(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE)
146 $(my_built_profile): $(PROFMAN)
147 $(my_built_profile): $(dex_preopt_profile_src_file)
148 ifeq (true,$(my_profile_is_text_listing))
149 # The profile is a test listing of classes (used for framework jars).
150 # We need to generate the actual binary profile before being able to compile.
151 $(my_built_profile):
Mathieu Chartier48762292017-09-13 22:08:45 -0700152 $(hide) mkdir -p $(dir $@)
153 ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
154 --create-profile-from=$(PRIVATE_SOURCE_CLASSES) \
155 --apk=$(PRIVATE_BUILT_MODULE) \
156 --dex-location=$(PRIVATE_DEX_LOCATION) \
157 --reference-profile-file=$@
Colin Cross0a69bb62018-10-09 16:14:44 -0700158 else
159 # The profile is binary profile (used for apps). Run it through profman to
160 # ensure the profile keys match the apk.
161 $(my_built_profile):
Calin Juravlef99ab752018-04-19 20:32:57 -0700162 $(hide) mkdir -p $(dir $@)
163 touch $@
164 ANDROID_LOG_TAGS="*:i" $(PROFMAN) \
165 --copy-and-update-profile-key \
166 --profile-file=$(PRIVATE_SOURCE_CLASSES) \
167 --apk=$(PRIVATE_BUILT_MODULE) \
Calin Juravle60216612018-04-26 18:52:45 -0700168 --dex-location=$(PRIVATE_DEX_LOCATION) \
Calin Juravlef99ab752018-04-19 20:32:57 -0700169 --reference-profile-file=$@ \
170 || echo "Profile out of date for $(PRIVATE_BUILT_MODULE)"
Colin Cross0a69bb62018-10-09 16:14:44 -0700171 endif
Calin Juravlef99ab752018-04-19 20:32:57 -0700172
Colin Cross0a69bb62018-10-09 16:14:44 -0700173 my_profile_is_text_listing :=
174 dex_preopt_profile_src_file :=
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800175
Colin Cross0a69bb62018-10-09 16:14:44 -0700176 # Remove compressed APK extension.
177 my_installed_profile := $(patsubst %.gz,%,$(LOCAL_INSTALLED_MODULE)).prof
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800178
Colin Cross0a69bb62018-10-09 16:14:44 -0700179 # my_installed_profile := $(LOCAL_INSTALLED_MODULE).prof
180 $(eval $(call copy-one-file,$(my_built_profile),$(my_installed_profile)))
181 build_installed_profile:=$(my_built_profile):$(my_installed_profile)
Mathieu Chartier48762292017-09-13 22:08:45 -0700182else
Colin Cross0a69bb62018-10-09 16:14:44 -0700183 build_installed_profile:=
184 my_installed_profile :=
Mathieu Chartier48762292017-09-13 22:08:45 -0700185endif
186
187ifdef LOCAL_DEX_PREOPT
188
Colin Cross0a69bb62018-10-09 16:14:44 -0700189 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
Mathieu Chartier502892a2018-07-06 13:29:43 -0700190
Colin Cross0a69bb62018-10-09 16:14:44 -0700191 ifdef dexpreopt_boot_jar_module
192 # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
193 # We use this installed_odex trick to get boot.art installed.
194 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
195 # Append the odex for the 2nd arch if we have one.
196 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
197 else # boot jar
198 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
Mathieu Chartier502892a2018-07-06 13:29:43 -0700199
Colin Cross0a69bb62018-10-09 16:14:44 -0700200 my_module_multilib := $(LOCAL_MULTILIB)
201 # If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
202 my_filtered_lib_name := $(patsubst %.impl,%,$(LOCAL_MODULE))
203 ifeq (,$(filter $(JAVA_SDK_LIBRARIES),$(my_filtered_lib_name)))
204 # For a Java library, by default we build odex for both 1st arch and 2nd arch.
205 # But it can be overridden with "LOCAL_MULTILIB := first".
206 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
207 # For system server jars, we build for only "first".
208 my_module_multilib := first
209 endif
210 endif
Mathieu Chartierfd5dfb82018-07-12 18:17:54 -0700211
Colin Cross0a69bb62018-10-09 16:14:44 -0700212 # Only preopt primary arch for translated arch since there is only an image there.
213 ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
214 my_module_multilib := first
215 endif
Brian Carlstromced4bff2013-11-14 23:44:56 -0800216
Colin Cross0a69bb62018-10-09 16:14:44 -0700217 # #################################################
218 # Odex for the 1st arch
219 my_2nd_arch_prefix :=
220 include $(BUILD_SYSTEM)/setup_one_odex.mk
221 # #################################################
222 # Odex for the 2nd arch
223 ifdef TARGET_2ND_ARCH
224 ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
225 ifneq (first,$(my_module_multilib))
226 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
227 include $(BUILD_SYSTEM)/setup_one_odex.mk
228 endif # my_module_multilib is not first.
229 endif # TARGET_TRANSLATE_2ND_ARCH not true
230 endif # TARGET_2ND_ARCH
231 # #################################################
232 else # must be APPS
233 # The preferred arch
234 my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
235 # Save the module multilib since setup_one_odex modifies it.
236 saved_my_module_multilib := $(my_module_multilib)
237 include $(BUILD_SYSTEM)/setup_one_odex.mk
238 my_module_multilib := $(saved_my_module_multilib)
239 ifdef TARGET_2ND_ARCH
240 ifeq ($(my_module_multilib),both)
241 # The non-preferred arch
242 my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
243 include $(BUILD_SYSTEM)/setup_one_odex.mk
244 endif # LOCAL_MULTILIB is both
245 endif # TARGET_2ND_ARCH
246 endif # LOCAL_MODULE_CLASS
247 endif # boot jar
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800248
Colin Cross0a69bb62018-10-09 16:14:44 -0700249 built_odex := $(strip $(built_odex))
250 built_vdex := $(strip $(built_vdex))
251 built_art := $(strip $(built_art))
252 installed_odex := $(strip $(installed_odex))
253 installed_vdex := $(strip $(installed_vdex))
254 installed_art := $(strip $(installed_art))
Mathieu Chartier2ac264f2017-03-03 11:17:36 -0800255
Colin Cross0a69bb62018-10-09 16:14:44 -0700256 ifdef built_odex
257 ifeq (true,$(my_process_profile))
258 $(built_odex): $(my_built_profile)
259 $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile)
Mathieu Chartierc5536ff2017-05-05 14:59:06 -0700260 else
Colin Cross0a69bb62018-10-09 16:14:44 -0700261 $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS :=
262 endif
263
264 ifndef LOCAL_DEX_PREOPT_FLAGS
265 LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
266 ifndef LOCAL_DEX_PREOPT_FLAGS
267 LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)
Mathieu Chartier6a902102017-06-23 10:44:45 -0700268 endif
Mathieu Chartierc5536ff2017-05-05 14:59:06 -0700269 endif
Nicolas Geoffrayb08ada12017-03-22 12:36:05 +0000270
Colin Cross0a69bb62018-10-09 16:14:44 -0700271 my_system_server_compiler_filter := $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)
272 ifeq (,$(my_system_server_compiler_filter))
273 my_system_server_compiler_filter := speed
274 endif
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800275
Colin Cross0a69bb62018-10-09 16:14:44 -0700276 my_default_compiler_filter := $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER)
277 ifeq (,$(my_default_compiler_filter))
278 # If no default compiler filter is specified, default to 'quicken' to save on storage.
279 my_default_compiler_filter := quicken
280 endif
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800281
Colin Cross0a69bb62018-10-09 16:14:44 -0700282 ifeq (,$(filter --compiler-filter=%, $(LOCAL_DEX_PREOPT_FLAGS)))
283 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
284 # Jars of system server, use the product option if it is set, speed otherwise.
285 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=$(my_system_server_compiler_filter)
286 else
287 ifneq (,$(filter $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(LOCAL_MODULE)))
288 # Apps loaded into system server, and apps the product default to being compiled with the
289 # 'speed' compiler filter.
290 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed
291 else
292 ifeq (true,$(my_process_profile))
293 # For non system server jars, use speed-profile when we have a profile.
294 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed-profile
295 else
296 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=$(my_default_compiler_filter)
297 endif
298 endif
299 endif
300 endif
301
302 my_generate_dm := $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES)
303 ifeq (,$(filter $(LOCAL_DEX_PREOPT_FLAGS),--compiler-filter=verify))
304 # Generating DM files only makes sense for verify, avoid doing for non verify compiler filter APKs.
305 my_generate_dm := false
306 endif
307
308 # No reason to use a dm file if the dex is already uncompressed.
309 ifeq ($(LOCAL_UNCOMPRESS_DEX),true)
310 my_generate_dm := false
311 endif
312
313 ifeq (true,$(my_generate_dm))
314 LOCAL_DEX_PREOPT_FLAGS += --copy-dex-files=false
315 LOCAL_DEX_PREOPT := nostripping
316 my_built_dm := $(dir $(LOCAL_BUILT_MODULE))generated.dm
317 my_installed_dm := $(patsubst %.apk,%,$(LOCAL_INSTALLED_MODULE)).dm
318 my_copied_vdex := $(dir $(LOCAL_BUILT_MODULE))primary.vdex
319 $(eval $(call copy-one-file,$(built_vdex),$(my_copied_vdex)))
320 $(my_built_dm): PRIVATE_INPUT_VDEX := $(my_copied_vdex)
321 $(my_built_dm): $(my_copied_vdex) $(ZIPTIME)
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800322 $(hide) mkdir -p $(dir $@)
323 $(hide) rm -f $@
324 $(hide) zip -qD -j -X -9 $@ $(PRIVATE_INPUT_VDEX)
325 $(ZIPTIME) $@
Colin Cross0a69bb62018-10-09 16:14:44 -0700326 $(eval $(call copy-one-file,$(my_built_dm),$(my_installed_dm)))
327 endif
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800328
Colin Cross0a69bb62018-10-09 16:14:44 -0700329 # By default, emit debug info.
Andreas Gampecdfe46b2018-03-19 14:28:15 -0700330 my_dexpreopt_debug_info := true
Colin Cross0a69bb62018-10-09 16:14:44 -0700331 # If the global setting suppresses mini-debug-info, disable it.
332 ifeq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
333 my_dexpreopt_debug_info := false
334 endif
335
336 # PRODUCT_SYSTEM_SERVER_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO.
337 # PRODUCT_OTHER_JAVA_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO.
338 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
339 ifeq (true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))
340 my_dexpreopt_debug_info := true
341 else ifeq (false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))
342 my_dexpreopt_debug_info := false
343 endif
344 else
345 ifeq (true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))
346 my_dexpreopt_debug_info := true
347 else ifeq (false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))
348 my_dexpreopt_debug_info := false
349 endif
350 endif
351
352 # Never enable on eng.
353 ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
354 my_dexpreopt_debug_info := false
355 endif
356
357 # Add dex2oat flag for debug-info/no-debug-info.
358 ifeq (true,$(my_dexpreopt_debug_info))
359 LOCAL_DEX_PREOPT_FLAGS += --generate-mini-debug-info
360 else ifeq (false,$(my_dexpreopt_debug_info))
361 LOCAL_DEX_PREOPT_FLAGS += --no-generate-mini-debug-info
362 endif
363
364 # Set the compiler reason to 'prebuilt' to identify the oat files produced
365 # during the build, as opposed to compiled on the device.
366 LOCAL_DEX_PREOPT_FLAGS += --compilation-reason=prebuilt
367
368 $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
369 $(built_vdex): $(built_odex)
370 $(built_art): $(built_odex)
Mathieu Chartier94f5f932017-06-23 14:47:56 -0700371 endif
Colin Cross0a69bb62018-10-09 16:14:44 -0700372
373 ifneq (true,$(my_generate_dm))
374 # Add the installed_odex to the list of installed files for this module if we aren't generating a
375 # dm file.
376 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
377 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_vdex)
378 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_art)
379
380 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
381 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_vdex)
382 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_art)
383
384 # Make sure to install the .odex and .vdex when you run "make <module_name>"
385 $(my_all_targets): $(installed_odex) $(installed_vdex) $(installed_art)
386 else
387 ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_dm)
388 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(my_built_dm) $(my_installed_dm)
389
390 # Make sure to install the .dm when you run "make <module_name>"
391 $(my_all_targets): $(installed_dm)
Andreas Gampecdfe46b2018-03-19 14:28:15 -0700392 endif
Andreas Gampecdfe46b2018-03-19 14:28:15 -0700393
Colin Cross0a69bb62018-10-09 16:14:44 -0700394 # Record dex-preopt config.
395 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
396 DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
397 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
398 DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
399 DEXPREOPT.$(LOCAL_MODULE).VENDOR_MODULE := $(LOCAL_VENDOR_MODULE)
400 DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
401 DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
402 DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
403 DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \
404 $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800405
Brian Carlstromced4bff2013-11-14 23:44:56 -0800406endif # LOCAL_DEX_PREOPT
Mathieu Chartier48762292017-09-13 22:08:45 -0700407
408# Profile doesn't depend on LOCAL_DEX_PREOPT.
409ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_profile)
410ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(build_installed_profile)
411
Calin Juravle7d701352018-04-25 15:25:46 -0700412my_process_profile :=
413
Mathieu Chartier48762292017-09-13 22:08:45 -0700414$(my_all_targets): $(my_installed_profile)