blob: 6a892e23a88eb9b0db6fa14c7b96ca2089449ce5 [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
Victor Hsiehe53dd7b2018-10-22 11:25:05 -07006ifeq (true,$(LOCAL_PREFER_INTEGRITY))
7 LOCAL_UNCOMPRESS_DEX := true
8else
9 LOCAL_UNCOMPRESS_DEX :=
10endif
11
Nicolas Geoffray3972a472018-01-09 11:46:30 +000012# We explicitly uncompress APKs of privileged apps, and used by
13# privileged apps
Nicolas Geoffray3972a472018-01-09 11:46:30 +000014ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))
Colin Cross0a69bb62018-10-09 16:14:44 -070015 ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
Nicolas Geoffray3972a472018-01-09 11:46:30 +000016 LOCAL_UNCOMPRESS_DEX := true
Colin Crossc18757e2018-10-09 16:33:27 -070017 endif
18
Nicolas Geoffray3972a472018-01-09 11:46:30 +000019 ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE)))
20 LOCAL_UNCOMPRESS_DEX := true
Colin Crossc18757e2018-10-09 16:33:27 -070021 endif
Nicolas Geoffray3972a472018-01-09 11:46:30 +000022endif # DONT_UNCOMPRESS_PRIV_APPS_DEXS
Brian Carlstromced4bff2013-11-14 23:44:56 -080023
24# Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc
25LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT))
Colin Crossc18757e2018-10-09 16:33:27 -070026ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined
27 LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
28
29 ifeq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Not installed to system.img.
30 # Default to nostripping for non system preopt (enables preopt).
31 # Don't strip in case the oat/vdex version in system ROM doesn't match the one in other
32 # partitions. It needs to be able to fall back to the APK for that case.
33 LOCAL_DEX_PREOPT := nostripping
34 endif
35
36 ifneq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES not empty
37 LOCAL_DEX_PREOPT := nostripping
38 endif
39endif
40
Colin Crossfc782ad2018-10-22 13:44:27 -070041ifeq (nostripping,$(LOCAL_DEX_PREOPT))
42 LOCAL_DEX_PREOPT := true
43 LOCAL_STRIP_DEX :=
44else
45 LOCAL_STRIP_DEX := true
46endif
47
Brian Carlstromced4bff2013-11-14 23:44:56 -080048ifeq (false,$(LOCAL_DEX_PREOPT))
49 LOCAL_DEX_PREOPT :=
50endif
Colin Cross0a69bb62018-10-09 16:14:44 -070051
Colin Crossc18757e2018-10-09 16:33:27 -070052# Only enable preopt for non tests.
53ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
54 LOCAL_DEX_PREOPT :=
55endif
56
57# If we have product-specific config for this module?
Colin Cross3aa2f8f2018-10-05 14:41:04 -070058ifneq (,$(filter $(LOCAL_MODULE),$(DEXPREOPT_DISABLED_MODULES)))
Colin Crossc18757e2018-10-09 16:33:27 -070059 LOCAL_DEX_PREOPT :=
60endif
61
62# Disable preopt for TARGET_BUILD_APPS
63ifneq (,$(TARGET_BUILD_APPS))
64 LOCAL_DEX_PREOPT :=
65endif
66
67# Disable preopt if not WITH_DEXPREOPT
68ifneq (true,$(WITH_DEXPREOPT))
69 LOCAL_DEX_PREOPT :=
70endif
71
Brian Carlstromced4bff2013-11-14 23:44:56 -080072ifdef LOCAL_UNINSTALLABLE_MODULE
Colin Cross0a69bb62018-10-09 16:14:44 -070073 LOCAL_DEX_PREOPT :=
Brian Carlstromced4bff2013-11-14 23:44:56 -080074endif
Colin Cross0a69bb62018-10-09 16:14:44 -070075
Colin Crossf229de42017-10-05 16:01:00 -070076ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR))) # contains no java code
Colin Cross0a69bb62018-10-09 16:14:44 -070077 LOCAL_DEX_PREOPT :=
Brian Carlstromced4bff2013-11-14 23:44:56 -080078endif
Colin Cross0a69bb62018-10-09 16:14:44 -070079
Mathieu Chartier418258c2017-08-28 14:19:35 -070080# if WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true and module is not in boot class path skip
81# Also preopt system server jars since selinux prevents system server from loading anything from
82# /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 -070083# or performance. If my_preopt_for_extracted_apk is true, we ignore the only preopt boot image
84# options.
85ifneq (true,$(my_preopt_for_extracted_apk))
Colin Cross0a69bb62018-10-09 16:14:44 -070086 ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
87 ifeq ($(filter $(PRODUCT_SYSTEM_SERVER_JARS) $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
88 LOCAL_DEX_PREOPT :=
89 endif
90 endif
Mathieu Chartier0fbb8362017-09-15 13:40:48 -070091endif
92
Alex Light4e358ab2016-06-16 14:47:10 -070093ifeq ($(LOCAL_DEX_PREOPT),true)
Colin Cross0a69bb62018-10-09 16:14:44 -070094 # Don't strip with dexes we explicitly uncompress (dexopt will not store the dex code).
95 ifeq ($(LOCAL_UNCOMPRESS_DEX),true)
Colin Crossfc782ad2018-10-22 13:44:27 -070096 LOCAL_STRIP_DEX :=
Colin Cross0a69bb62018-10-09 16:14:44 -070097 endif # LOCAL_UNCOMPRESS_DEX
Nicolas Geoffray3972a472018-01-09 11:46:30 +000098
Colin Cross0a69bb62018-10-09 16:14:44 -070099 # system_other isn't there for an OTA, so don't strip
100 # if module is on system, and odex is on system_other.
101 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
102 ifneq ($(call install-on-system-other, $(my_module_path)),)
Colin Crossfc782ad2018-10-22 13:44:27 -0700103 LOCAL_STRIP_DEX :=
Colin Cross0a69bb62018-10-09 16:14:44 -0700104 endif # install-on-system-other
105 endif # BOARD_USES_SYSTEM_OTHER_ODEX
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000106
Colin Cross0a69bb62018-10-09 16:14:44 -0700107 # We also don't strip if all dexs are uncompressed (dexopt will not store the dex code),
108 # but that requires to inspect the source file, which is too early at this point (as we
109 # don't know if the source file will actually be used).
110 # See dexpreopt-remove-classes.dex.
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000111endif # LOCAL_DEX_PREOPT
Brian Carlstromced4bff2013-11-14 23:44:56 -0800112
113built_odex :=
David Brazdil70470162016-08-25 13:50:15 +0100114built_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800115built_art :=
Brian Carlstromced4bff2013-11-14 23:44:56 -0800116installed_odex :=
David Brazdil70470162016-08-25 13:50:15 +0100117installed_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800118installed_art :=
Ying Wang74c98502014-05-19 13:03:36 -0700119built_installed_odex :=
David Brazdil70470162016-08-25 13:50:15 +0100120built_installed_vdex :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800121built_installed_art :=
Calin Juravlef99ab752018-04-19 20:32:57 -0700122my_process_profile :=
123my_profile_is_text_listing :=
Po Hueaef4d82018-10-10 13:13:38 +0800124my_generate_dm :=
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800125
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700126ifeq (false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))
Colin Cross0a69bb62018-10-09 16:14:44 -0700127 LOCAL_DEX_PREOPT_GENERATE_PROFILE := false
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700128endif
129
130ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE
Colin Cross0a69bb62018-10-09 16:14:44 -0700131 # If LOCAL_DEX_PREOPT_GENERATE_PROFILE is not defined, default it based on the existence of the
132 # profile class listing. TODO: Use product specific directory here.
133 my_classes_directory := $(PRODUCT_DEX_PREOPT_PROFILE_DIR)
134 LOCAL_DEX_PREOPT_PROFILE := $(my_classes_directory)/$(LOCAL_MODULE).prof
Calin Juravle7d701352018-04-25 15:25:46 -0700135
Colin Cross0a69bb62018-10-09 16:14:44 -0700136 ifneq (,$(wildcard $(LOCAL_DEX_PREOPT_PROFILE)))
137 my_process_profile := true
138 my_profile_is_text_listing := false
139 endif
Calin Juravlef99ab752018-04-19 20:32:57 -0700140else
Colin Cross0a69bb62018-10-09 16:14:44 -0700141 my_process_profile := $(LOCAL_DEX_PREOPT_GENERATE_PROFILE)
142 my_profile_is_text_listing := true
143 LOCAL_DEX_PREOPT_PROFILE := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700144endif
Mathieu Chartier48762292017-09-13 22:08:45 -0700145
Calin Juravlef99ab752018-04-19 20:32:57 -0700146ifeq (true,$(my_process_profile))
Mathieu Chartier48762292017-09-13 22:08:45 -0700147
Colin Cross0a69bb62018-10-09 16:14:44 -0700148 ifeq (,$(LOCAL_DEX_PREOPT_APP_IMAGE))
149 LOCAL_DEX_PREOPT_APP_IMAGE := true
150 endif
Mathieu Chartier6324c2d2017-05-05 17:22:37 -0700151
Colin Cross0a69bb62018-10-09 16:14:44 -0700152 ifndef LOCAL_DEX_PREOPT_PROFILE
153 $(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE))
154 endif
155 ifeq (,$(dex_preopt_profile_src_file))
156 $(call pretty-error, Internal error: dex_preopt_profile_src_file must be set)
157 endif
158 my_built_profile := $(dir $(LOCAL_BUILT_MODULE))/profile.prof
159 my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
160 # Remove compressed APK extension.
161 my_dex_location := $(patsubst %.gz,%,$(my_dex_location))
162 $(my_built_profile): PRIVATE_BUILT_MODULE := $(dex_preopt_profile_src_file)
163 $(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location)
164 $(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE)
165 $(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE)
166 $(my_built_profile): $(PROFMAN)
167 $(my_built_profile): $(dex_preopt_profile_src_file)
168 ifeq (true,$(my_profile_is_text_listing))
169 # The profile is a test listing of classes (used for framework jars).
170 # We need to generate the actual binary profile before being able to compile.
171 $(my_built_profile):
Mathieu Chartier48762292017-09-13 22:08:45 -0700172 $(hide) mkdir -p $(dir $@)
173 ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
174 --create-profile-from=$(PRIVATE_SOURCE_CLASSES) \
175 --apk=$(PRIVATE_BUILT_MODULE) \
176 --dex-location=$(PRIVATE_DEX_LOCATION) \
177 --reference-profile-file=$@
Colin Cross0a69bb62018-10-09 16:14:44 -0700178 else
179 # The profile is binary profile (used for apps). Run it through profman to
180 # ensure the profile keys match the apk.
181 $(my_built_profile):
Calin Juravlef99ab752018-04-19 20:32:57 -0700182 $(hide) mkdir -p $(dir $@)
183 touch $@
184 ANDROID_LOG_TAGS="*:i" $(PROFMAN) \
185 --copy-and-update-profile-key \
186 --profile-file=$(PRIVATE_SOURCE_CLASSES) \
187 --apk=$(PRIVATE_BUILT_MODULE) \
Calin Juravle60216612018-04-26 18:52:45 -0700188 --dex-location=$(PRIVATE_DEX_LOCATION) \
Calin Juravlef99ab752018-04-19 20:32:57 -0700189 --reference-profile-file=$@ \
190 || echo "Profile out of date for $(PRIVATE_BUILT_MODULE)"
Colin Cross0a69bb62018-10-09 16:14:44 -0700191 endif
Calin Juravlef99ab752018-04-19 20:32:57 -0700192
Colin Cross0a69bb62018-10-09 16:14:44 -0700193 my_profile_is_text_listing :=
194 dex_preopt_profile_src_file :=
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800195
Colin Cross0a69bb62018-10-09 16:14:44 -0700196 # Remove compressed APK extension.
197 my_installed_profile := $(patsubst %.gz,%,$(LOCAL_INSTALLED_MODULE)).prof
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800198
Colin Cross0a69bb62018-10-09 16:14:44 -0700199 # my_installed_profile := $(LOCAL_INSTALLED_MODULE).prof
200 $(eval $(call copy-one-file,$(my_built_profile),$(my_installed_profile)))
201 build_installed_profile:=$(my_built_profile):$(my_installed_profile)
Mathieu Chartier48762292017-09-13 22:08:45 -0700202else
Colin Cross0a69bb62018-10-09 16:14:44 -0700203 build_installed_profile:=
204 my_installed_profile :=
Mathieu Chartier48762292017-09-13 22:08:45 -0700205endif
206
207ifdef LOCAL_DEX_PREOPT
208
Colin Cross0a69bb62018-10-09 16:14:44 -0700209 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
Andreas Gampe039bb482018-01-19 10:56:23 -0800210
Colin Cross0a69bb62018-10-09 16:14:44 -0700211 ifdef dexpreopt_boot_jar_module
212 # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
213 # We use this installed_odex trick to get boot.art installed.
214 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
215 # Append the odex for the 2nd arch if we have one.
216 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
217 else # boot jar
218 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
Andreas Gampe039bb482018-01-19 10:56:23 -0800219
Colin Cross0a69bb62018-10-09 16:14:44 -0700220 my_module_multilib := $(LOCAL_MULTILIB)
221 # If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
222 my_filtered_lib_name := $(patsubst %.impl,%,$(LOCAL_MODULE))
223 ifeq (,$(filter $(JAVA_SDK_LIBRARIES),$(my_filtered_lib_name)))
224 # For a Java library, by default we build odex for both 1st arch and 2nd arch.
225 # But it can be overridden with "LOCAL_MULTILIB := first".
226 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
227 # For system server jars, we build for only "first".
228 my_module_multilib := first
229 endif
230 endif
Mathieu Chartier502892a2018-07-06 13:29:43 -0700231
Colin Cross0a69bb62018-10-09 16:14:44 -0700232 # Only preopt primary arch for translated arch since there is only an image there.
233 ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
234 my_module_multilib := first
235 endif
Mathieu Chartier502892a2018-07-06 13:29:43 -0700236
Colin Cross0a69bb62018-10-09 16:14:44 -0700237 # #################################################
238 # Odex for the 1st arch
239 my_2nd_arch_prefix :=
240 include $(BUILD_SYSTEM)/setup_one_odex.mk
241 # #################################################
242 # Odex for the 2nd arch
243 ifdef TARGET_2ND_ARCH
244 ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
245 ifneq (first,$(my_module_multilib))
246 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
247 include $(BUILD_SYSTEM)/setup_one_odex.mk
248 endif # my_module_multilib is not first.
249 endif # TARGET_TRANSLATE_2ND_ARCH not true
250 endif # TARGET_2ND_ARCH
251 # #################################################
252 else # must be APPS
253 # The preferred arch
254 my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
255 # Save the module multilib since setup_one_odex modifies it.
256 saved_my_module_multilib := $(my_module_multilib)
257 include $(BUILD_SYSTEM)/setup_one_odex.mk
258 my_module_multilib := $(saved_my_module_multilib)
259 ifdef TARGET_2ND_ARCH
260 ifeq ($(my_module_multilib),both)
261 # The non-preferred arch
262 my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
263 include $(BUILD_SYSTEM)/setup_one_odex.mk
264 endif # LOCAL_MULTILIB is both
265 endif # TARGET_2ND_ARCH
266 endif # LOCAL_MODULE_CLASS
267 endif # boot jar
Mathieu Chartierfd5dfb82018-07-12 18:17:54 -0700268
Colin Cross0a69bb62018-10-09 16:14:44 -0700269 built_odex := $(strip $(built_odex))
270 built_vdex := $(strip $(built_vdex))
271 built_art := $(strip $(built_art))
272 installed_odex := $(strip $(installed_odex))
273 installed_vdex := $(strip $(installed_vdex))
274 installed_art := $(strip $(installed_art))
Brian Carlstromced4bff2013-11-14 23:44:56 -0800275
Colin Cross0a69bb62018-10-09 16:14:44 -0700276 ifdef built_odex
277 ifeq (true,$(my_process_profile))
278 $(built_odex): $(my_built_profile)
279 $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile)
Mathieu Chartierc5536ff2017-05-05 14:59:06 -0700280 else
Colin Cross0a69bb62018-10-09 16:14:44 -0700281 $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS :=
282 endif
283
284 ifndef LOCAL_DEX_PREOPT_FLAGS
285 LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
286 ifndef LOCAL_DEX_PREOPT_FLAGS
287 LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)
Mathieu Chartier6a902102017-06-23 10:44:45 -0700288 endif
Mathieu Chartierc5536ff2017-05-05 14:59:06 -0700289 endif
Nicolas Geoffrayb08ada12017-03-22 12:36:05 +0000290
Colin Cross0a69bb62018-10-09 16:14:44 -0700291 my_system_server_compiler_filter := $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)
292 ifeq (,$(my_system_server_compiler_filter))
293 my_system_server_compiler_filter := speed
294 endif
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800295
Colin Cross0a69bb62018-10-09 16:14:44 -0700296 my_default_compiler_filter := $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER)
297 ifeq (,$(my_default_compiler_filter))
298 # If no default compiler filter is specified, default to 'quicken' to save on storage.
299 my_default_compiler_filter := quicken
300 endif
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800301
Colin Cross0a69bb62018-10-09 16:14:44 -0700302 ifeq (,$(filter --compiler-filter=%, $(LOCAL_DEX_PREOPT_FLAGS)))
303 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
304 # Jars of system server, use the product option if it is set, speed otherwise.
305 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=$(my_system_server_compiler_filter)
306 else
307 ifneq (,$(filter $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(LOCAL_MODULE)))
308 # Apps loaded into system server, and apps the product default to being compiled with the
309 # 'speed' compiler filter.
310 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed
311 else
312 ifeq (true,$(my_process_profile))
313 # For non system server jars, use speed-profile when we have a profile.
314 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed-profile
315 else
316 LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=$(my_default_compiler_filter)
317 endif
318 endif
319 endif
320 endif
321
322 my_generate_dm := $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES)
323 ifeq (,$(filter $(LOCAL_DEX_PREOPT_FLAGS),--compiler-filter=verify))
324 # Generating DM files only makes sense for verify, avoid doing for non verify compiler filter APKs.
325 my_generate_dm := false
326 endif
327
328 # No reason to use a dm file if the dex is already uncompressed.
329 ifeq ($(LOCAL_UNCOMPRESS_DEX),true)
330 my_generate_dm := false
331 endif
332
333 ifeq (true,$(my_generate_dm))
334 LOCAL_DEX_PREOPT_FLAGS += --copy-dex-files=false
Colin Crossfc782ad2018-10-22 13:44:27 -0700335 LOCAL_DEX_PREOPT := true
336 LOCAL_STRIP_DEX :=
Colin Cross0a69bb62018-10-09 16:14:44 -0700337 my_built_dm := $(dir $(LOCAL_BUILT_MODULE))generated.dm
338 my_installed_dm := $(patsubst %.apk,%,$(LOCAL_INSTALLED_MODULE)).dm
339 my_copied_vdex := $(dir $(LOCAL_BUILT_MODULE))primary.vdex
340 $(eval $(call copy-one-file,$(built_vdex),$(my_copied_vdex)))
341 $(my_built_dm): PRIVATE_INPUT_VDEX := $(my_copied_vdex)
342 $(my_built_dm): $(my_copied_vdex) $(ZIPTIME)
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800343 $(hide) mkdir -p $(dir $@)
344 $(hide) rm -f $@
345 $(hide) zip -qD -j -X -9 $@ $(PRIVATE_INPUT_VDEX)
346 $(ZIPTIME) $@
Colin Cross0a69bb62018-10-09 16:14:44 -0700347 $(eval $(call copy-one-file,$(my_built_dm),$(my_installed_dm)))
348 endif
Mathieu Chartier5c658ac2018-02-15 13:19:38 -0800349
Colin Cross0a69bb62018-10-09 16:14:44 -0700350 # By default, emit debug info.
Andreas Gampecdfe46b2018-03-19 14:28:15 -0700351 my_dexpreopt_debug_info := true
Colin Cross0a69bb62018-10-09 16:14:44 -0700352 # If the global setting suppresses mini-debug-info, disable it.
353 ifeq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
354 my_dexpreopt_debug_info := false
355 endif
356
357 # PRODUCT_SYSTEM_SERVER_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO.
358 # PRODUCT_OTHER_JAVA_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO.
359 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
360 ifeq (true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))
361 my_dexpreopt_debug_info := true
362 else ifeq (false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))
363 my_dexpreopt_debug_info := false
364 endif
365 else
366 ifeq (true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))
367 my_dexpreopt_debug_info := true
368 else ifeq (false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))
369 my_dexpreopt_debug_info := false
370 endif
371 endif
372
373 # Never enable on eng.
374 ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
375 my_dexpreopt_debug_info := false
376 endif
377
378 # Add dex2oat flag for debug-info/no-debug-info.
379 ifeq (true,$(my_dexpreopt_debug_info))
380 LOCAL_DEX_PREOPT_FLAGS += --generate-mini-debug-info
381 else ifeq (false,$(my_dexpreopt_debug_info))
382 LOCAL_DEX_PREOPT_FLAGS += --no-generate-mini-debug-info
383 endif
384
385 # Set the compiler reason to 'prebuilt' to identify the oat files produced
386 # during the build, as opposed to compiled on the device.
387 LOCAL_DEX_PREOPT_FLAGS += --compilation-reason=prebuilt
388
389 $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
390 $(built_vdex): $(built_odex)
391 $(built_art): $(built_odex)
Mathieu Chartier94f5f932017-06-23 14:47:56 -0700392 endif
Colin Cross0a69bb62018-10-09 16:14:44 -0700393
394 ifneq (true,$(my_generate_dm))
395 # Add the installed_odex to the list of installed files for this module if we aren't generating a
396 # dm file.
397 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
398 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_vdex)
399 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_art)
400
401 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
402 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_vdex)
403 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_art)
404
405 # Make sure to install the .odex and .vdex when you run "make <module_name>"
406 $(my_all_targets): $(installed_odex) $(installed_vdex) $(installed_art)
407 else
408 ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_dm)
409 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(my_built_dm) $(my_installed_dm)
410
411 # Make sure to install the .dm when you run "make <module_name>"
412 $(my_all_targets): $(installed_dm)
Andreas Gampecdfe46b2018-03-19 14:28:15 -0700413 endif
Andreas Gampecdfe46b2018-03-19 14:28:15 -0700414
Colin Cross0a69bb62018-10-09 16:14:44 -0700415 # Record dex-preopt config.
416 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
417 DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
418 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
419 DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
420 DEXPREOPT.$(LOCAL_MODULE).VENDOR_MODULE := $(LOCAL_VENDOR_MODULE)
421 DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
422 DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
423 DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
424 DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \
425 $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800426
Brian Carlstromced4bff2013-11-14 23:44:56 -0800427endif # LOCAL_DEX_PREOPT
Mathieu Chartier48762292017-09-13 22:08:45 -0700428
429# Profile doesn't depend on LOCAL_DEX_PREOPT.
430ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_profile)
431ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(build_installed_profile)
432
Calin Juravle7d701352018-04-25 15:25:46 -0700433my_process_profile :=
434
Mathieu Chartier48762292017-09-13 22:08:45 -0700435$(my_all_targets): $(my_installed_profile)