• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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# Input variables: my_manifest_or_apk
4# Output variables: LOCAL_DEX_PREOPT, LOCAL_UNCOMPRESS_DEX
5
6ifeq (true,$(LOCAL_USE_EMBEDDED_DEX))
7  LOCAL_UNCOMPRESS_DEX := true
8else
9  LOCAL_UNCOMPRESS_DEX :=
10endif
11
12# We explicitly uncompress APKs of privileged apps, and used by
13# privileged apps
14ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))
15  ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
16    LOCAL_UNCOMPRESS_DEX := true
17  endif
18
19  ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE)))
20    LOCAL_UNCOMPRESS_DEX := true
21  endif
22endif  # DONT_UNCOMPRESS_PRIV_APPS_DEXS
23
24# Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc
25LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT))
26ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined
27  LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
28endif
29
30ifeq (false,$(LOCAL_DEX_PREOPT))
31  LOCAL_DEX_PREOPT :=
32endif
33
34# Disable preopt for tests.
35ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
36  LOCAL_DEX_PREOPT :=
37endif
38
39# If we have product-specific config for this module?
40ifneq (,$(filter $(LOCAL_MODULE),$(DEXPREOPT_DISABLED_MODULES)))
41  LOCAL_DEX_PREOPT :=
42endif
43
44# Disable preopt for DISABLE_PREOPT
45ifeq (true,$(DISABLE_PREOPT))
46  LOCAL_DEX_PREOPT :=
47endif
48
49# Disable preopt if not WITH_DEXPREOPT
50ifneq (true,$(WITH_DEXPREOPT))
51  LOCAL_DEX_PREOPT :=
52endif
53
54ifdef LOCAL_UNINSTALLABLE_MODULE
55  LOCAL_DEX_PREOPT :=
56endif
57
58# Disable preopt if the app contains no java code.
59ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR)))
60  LOCAL_DEX_PREOPT :=
61endif
62
63# Don't preopt system server jars that are updatable.
64ifneq (,$(filter %:$(LOCAL_MODULE), $(PRODUCT_UPDATABLE_SYSTEM_SERVER_JARS)))
65  LOCAL_DEX_PREOPT :=
66endif
67
68# if WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true and module is not in boot class path skip
69# Also preopt system server jars since selinux prevents system server from loading anything from
70# /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
71# or performance. If my_preopt_for_extracted_apk is true, we ignore the only preopt boot image
72# options.
73system_server_jars := $(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),$(call word-colon,2,$(m)))
74ifneq (true,$(my_preopt_for_extracted_apk))
75  ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
76    ifeq ($(filter $(system_server_jars) $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
77      LOCAL_DEX_PREOPT :=
78    endif
79  endif
80endif
81
82my_process_profile :=
83my_profile_is_text_listing :=
84
85ifeq (false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))
86  LOCAL_DEX_PREOPT_GENERATE_PROFILE := false
87endif
88
89ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE
90  # If LOCAL_DEX_PREOPT_GENERATE_PROFILE is not defined, default it based on the existence of the
91  # profile class listing. TODO: Use product specific directory here.
92  my_classes_directory := $(PRODUCT_DEX_PREOPT_PROFILE_DIR)
93  LOCAL_DEX_PREOPT_PROFILE := $(my_classes_directory)/$(LOCAL_MODULE).prof
94
95  ifneq (,$(wildcard $(LOCAL_DEX_PREOPT_PROFILE)))
96    my_process_profile := true
97    my_profile_is_text_listing :=
98  endif
99else
100  my_process_profile := $(LOCAL_DEX_PREOPT_GENERATE_PROFILE)
101  my_profile_is_text_listing := true
102  LOCAL_DEX_PREOPT_PROFILE := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
103endif
104
105ifeq (true,$(my_process_profile))
106  ifndef LOCAL_DEX_PREOPT_PROFILE
107    $(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE))
108  endif
109  ifeq (,$(dex_preopt_profile_src_file))
110    $(call pretty-error, Internal error: dex_preopt_profile_src_file must be set)
111  endif
112endif
113
114################################################################################
115# Local module variables and functions used in dexpreopt and manifest_check.
116################################################################################
117
118my_filtered_optional_uses_libraries := $(filter-out $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES), \
119  $(LOCAL_OPTIONAL_USES_LIBRARIES))
120
121# TODO(b/132357300): This may filter out too much, as PRODUCT_PACKAGES doesn't
122# include all packages (the full list is unknown until reading all Android.mk
123# makefiles). As a consequence, a library may be present but not included in
124# dexpreopt, which will result in class loader context mismatch and a failure
125# to load dexpreopt code on device. We should fix this, either by deferring
126# dependency computation until the full list of product packages is known, or
127# by adding product-specific lists of missing libraries.
128my_filtered_optional_uses_libraries := $(filter $(PRODUCT_PACKAGES), \
129  $(my_filtered_optional_uses_libraries))
130
131ifeq ($(LOCAL_MODULE_CLASS),APPS)
132  # compatibility libraries are added to class loader context of an app only if
133  # targetSdkVersion in the app's manifest is lower than the given SDK version
134
135  my_dexpreopt_libs_compat_28 := \
136    org.apache.http.legacy
137
138  my_dexpreopt_libs_compat_29 := \
139    android.hidl.manager-V1.0-java \
140    android.hidl.base-V1.0-java
141
142  my_dexpreopt_libs_compat_30 := \
143    android.test.base \
144    android.test.mock
145
146  my_dexpreopt_libs_compat := \
147    $(my_dexpreopt_libs_compat_28) \
148    $(my_dexpreopt_libs_compat_29) \
149    $(my_dexpreopt_libs_compat_30)
150else
151  my_dexpreopt_libs_compat :=
152endif
153
154my_dexpreopt_libs := \
155  $(LOCAL_USES_LIBRARIES) \
156  $(my_filtered_optional_uses_libraries)
157
158# Module dexpreopt.config depends on dexpreopt.config files of each
159# <uses-library> dependency, because these libraries may be processed after
160# the current module by Make (there's no topological order), so the dependency
161# information (paths, class loader context) may not be ready yet by the time
162# this dexpreopt.config is generated. So it's necessary to add file-level
163# dependencies between dexpreopt.config files.
164my_dexpreopt_dep_configs := $(foreach lib, \
165  $(filter-out $(my_dexpreopt_libs_compat),$(LOCAL_USES_LIBRARIES) $(my_filtered_optional_uses_libraries)), \
166  $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,)/dexpreopt.config)
167
168# 1: SDK version
169# 2: list of libraries
170#
171# Make does not process modules in topological order wrt. <uses-library>
172# dependencies, therefore we cannot rely on variables to get the information
173# about dependencies (in particular, their on-device path and class loader
174# context). This information is communicated via dexpreopt.config files: each
175# config depends on configs for <uses-library> dependencies of this module,
176# and the dex_preopt_config_merger.py script reads all configs and inserts the
177# missing bits from dependency configs into the module config.
178#
179# By default on-device path is /system/framework/*.jar, and class loader
180# subcontext is empty. These values are correct for compatibility libraries,
181# which are special and not handled by dex_preopt_config_merger.py.
182#
183add_json_class_loader_context = \
184  $(call add_json_array, $(1)) \
185  $(foreach lib, $(2),\
186    $(call add_json_map_anon) \
187    $(call add_json_str, Name, $(lib)) \
188    $(call add_json_str, Host, $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/javalib.jar) \
189    $(call add_json_str, Device, /system/framework/$(lib).jar) \
190    $(call add_json_val, Subcontexts, null) \
191    $(call end_json_map)) \
192  $(call end_json_array)
193
194################################################################################
195# Verify <uses-library> coherence between the build system and the manifest.
196################################################################################
197
198# Some libraries do not have a manifest, so there is nothing to check against.
199# Handle it as if the manifest had zero <uses-library> tags: it is ok unless the
200# module has non-empty LOCAL_USES_LIBRARIES or LOCAL_OPTIONAL_USES_LIBRARIES.
201ifndef my_manifest_or_apk
202  ifneq (,$(strip $(LOCAL_USES_LIBRARIES)$(LOCAL_OPTIONAL_USES_LIBRARIES)))
203    $(error $(LOCAL_MODULE) has non-empty <uses-library> list but no manifest)
204  else
205    LOCAL_ENFORCE_USES_LIBRARIES := false
206  endif
207endif
208
209# Disable the check for tests.
210ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
211  LOCAL_ENFORCE_USES_LIBRARIES := false
212endif
213ifneq (,$(LOCAL_COMPATIBILITY_SUITE))
214  LOCAL_ENFORCE_USES_LIBRARIES := false
215endif
216
217# Disable the check if the app contains no java code.
218ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR)))
219  LOCAL_ENFORCE_USES_LIBRARIES := false
220endif
221
222# Disable <uses-library> checks if dexpreopt is globally disabled.
223# Without dexpreopt the check is not necessary, and although it is good to have,
224# it is difficult to maintain on non-linux build platforms where dexpreopt is
225# generally disabled (the check may fail due to various unrelated reasons, such
226# as a failure to get manifest from an APK).
227ifneq (true,$(WITH_DEXPREOPT))
228  LOCAL_ENFORCE_USES_LIBRARIES := false
229else ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
230  LOCAL_ENFORCE_USES_LIBRARIES := false
231endif
232
233# Verify LOCAL_USES_LIBRARIES/LOCAL_OPTIONAL_USES_LIBRARIES against the manifest.
234ifndef LOCAL_ENFORCE_USES_LIBRARIES
235  LOCAL_ENFORCE_USES_LIBRARIES := true
236endif
237
238my_enforced_uses_libraries :=
239ifeq (true,$(LOCAL_ENFORCE_USES_LIBRARIES))
240  my_verify_script := build/soong/scripts/manifest_check.py
241  my_uses_libs_args := $(patsubst %,--uses-library %,$(LOCAL_USES_LIBRARIES))
242  my_optional_uses_libs_args := $(patsubst %,--optional-uses-library %, \
243    $(LOCAL_OPTIONAL_USES_LIBRARIES))
244  my_relax_check_arg := $(if $(filter true,$(RELAX_USES_LIBRARY_CHECK)), \
245    --enforce-uses-libraries-relax,)
246  my_dexpreopt_config_args := $(patsubst %,--dexpreopt-config %,$(my_dexpreopt_dep_configs))
247
248  my_enforced_uses_libraries := $(intermediates.COMMON)/enforce_uses_libraries.status
249  $(my_enforced_uses_libraries): PRIVATE_USES_LIBRARIES := $(my_uses_libs_args)
250  $(my_enforced_uses_libraries): PRIVATE_OPTIONAL_USES_LIBRARIES := $(my_optional_uses_libs_args)
251  $(my_enforced_uses_libraries): PRIVATE_DEXPREOPT_CONFIGS := $(my_dexpreopt_config_args)
252  $(my_enforced_uses_libraries): PRIVATE_RELAX_CHECK := $(my_relax_check_arg)
253  $(my_enforced_uses_libraries): $(AAPT)
254  $(my_enforced_uses_libraries): $(my_verify_script)
255  $(my_enforced_uses_libraries): $(my_dexpreopt_dep_configs)
256  $(my_enforced_uses_libraries): $(my_manifest_or_apk)
257	@echo Verifying uses-libraries: $<
258	rm -f $@
259	$(my_verify_script) \
260	  --enforce-uses-libraries \
261	  --enforce-uses-libraries-status $@ \
262	  --aapt $(AAPT) \
263	  $(PRIVATE_USES_LIBRARIES) \
264	  $(PRIVATE_OPTIONAL_USES_LIBRARIES) \
265	  $(PRIVATE_DEXPREOPT_CONFIGS) \
266	  $(PRIVATE_RELAX_CHECK) \
267	  $<
268  $(LOCAL_BUILT_MODULE) : $(my_enforced_uses_libraries)
269endif
270
271################################################################################
272# Dexpreopt command.
273################################################################################
274
275my_dexpreopt_archs :=
276my_dexpreopt_images :=
277my_dexpreopt_images_deps :=
278my_dexpreopt_image_locations_on_host :=
279my_dexpreopt_image_locations_on_device :=
280my_dexpreopt_infix := boot
281ifeq (true, $(DEXPREOPT_USE_ART_IMAGE))
282  my_dexpreopt_infix := art
283endif
284
285ifdef LOCAL_DEX_PREOPT
286  ifeq (,$(filter PRESIGNED,$(LOCAL_CERTIFICATE)))
287    # Store uncompressed dex files preopted in /system
288    ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
289      ifeq ($(call install-on-system-other, $(my_module_path)),)
290        LOCAL_UNCOMPRESS_DEX := true
291      endif  # install-on-system-other
292    else  # BOARD_USES_SYSTEM_OTHER_ODEX
293      LOCAL_UNCOMPRESS_DEX := true
294    endif
295  endif
296
297  ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
298    my_module_multilib := $(LOCAL_MULTILIB)
299    # If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
300    ifeq (,$(filter $(JAVA_SDK_LIBRARIES),$(LOCAL_MODULE)))
301      # For a Java library, by default we build odex for both 1st arch and 2nd arch.
302      # But it can be overridden with "LOCAL_MULTILIB := first".
303      ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
304        # For system server jars, we build for only "first".
305        my_module_multilib := first
306      endif
307    endif
308
309    # Only preopt primary arch for translated arch since there is only an image there.
310    ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
311      my_module_multilib := first
312    endif
313
314    # #################################################
315    # Odex for the 1st arch
316    my_dexpreopt_archs += $(TARGET_ARCH)
317    my_dexpreopt_images += $(DEXPREOPT_IMAGE_$(my_dexpreopt_infix)_$(TARGET_ARCH))
318    my_dexpreopt_images_deps += $(DEXPREOPT_IMAGE_DEPS_$(my_dexpreopt_infix)_$(TARGET_ARCH))
319    # Odex for the 2nd arch
320    ifdef TARGET_2ND_ARCH
321      ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
322        ifneq (first,$(my_module_multilib))
323          my_dexpreopt_archs += $(TARGET_2ND_ARCH)
324          my_dexpreopt_images += $(DEXPREOPT_IMAGE_$(my_dexpreopt_infix)_$(TARGET_2ND_ARCH))
325          my_dexpreopt_images_deps += $(DEXPREOPT_IMAGE_DEPS_$(my_dexpreopt_infix)_$(TARGET_2ND_ARCH))
326        endif  # my_module_multilib is not first.
327      endif  # TARGET_TRANSLATE_2ND_ARCH not true
328    endif  # TARGET_2ND_ARCH
329    # #################################################
330  else  # must be APPS
331    # The preferred arch
332    # Save the module multilib since setup_one_odex modifies it.
333    my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
334    my_dexpreopt_archs += $(TARGET_$(my_2nd_arch_prefix)ARCH)
335    my_dexpreopt_images += \
336        $(DEXPREOPT_IMAGE_$(my_dexpreopt_infix)_$(TARGET_$(my_2nd_arch_prefix)ARCH))
337    my_dexpreopt_images_deps += \
338        $(DEXPREOPT_IMAGE_DEPS_$(my_dexpreopt_infix)_$(TARGET_$(my_2nd_arch_prefix)ARCH))
339    ifdef TARGET_2ND_ARCH
340      ifeq ($(my_module_multilib),both)
341        # The non-preferred arch
342        my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
343        my_dexpreopt_archs += $(TARGET_$(my_2nd_arch_prefix)ARCH)
344        my_dexpreopt_images += \
345            $(DEXPREOPT_IMAGE_$(my_dexpreopt_infix)_$(TARGET_$(my_2nd_arch_prefix)ARCH))
346        my_dexpreopt_images_deps += \
347            $(DEXPREOPT_IMAGE_DEPS_$(my_dexpreopt_infix)_$(TARGET_$(my_2nd_arch_prefix)ARCH))
348      endif  # LOCAL_MULTILIB is both
349    endif  # TARGET_2ND_ARCH
350  endif  # LOCAL_MODULE_CLASS
351
352  my_dexpreopt_image_locations_on_host += $(DEXPREOPT_IMAGE_LOCATIONS_ON_HOST$(my_dexpreopt_infix))
353  my_dexpreopt_image_locations_on_device += $(DEXPREOPT_IMAGE_LOCATIONS_ON_DEVICE$(my_dexpreopt_infix))
354
355  # Record dex-preopt config.
356  DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
357  DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
358  DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
359  DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
360  DEXPREOPT.$(LOCAL_MODULE).VENDOR_MODULE := $(LOCAL_VENDOR_MODULE)
361  DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
362  DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
363  DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \
364    $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
365
366  $(call json_start)
367
368  # DexPath is not set: it will be filled in by dexpreopt_gen.
369
370  $(call add_json_str,  Name,                           $(LOCAL_MODULE))
371  $(call add_json_str,  DexLocation,                    $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)))
372  $(call add_json_str,  BuildPath,                      $(LOCAL_BUILT_MODULE))
373  $(call add_json_str,  ManifestPath,                   $(full_android_manifest))
374  $(call add_json_str,  ExtrasOutputPath,               $$2)
375  $(call add_json_bool, Privileged,                     $(filter true,$(LOCAL_PRIVILEGED_MODULE)))
376  $(call add_json_bool, UncompressedDex,                $(filter true,$(LOCAL_UNCOMPRESS_DEX)))
377  $(call add_json_bool, HasApkLibraries,                $(LOCAL_APK_LIBRARIES))
378  $(call add_json_list, PreoptFlags,                    $(LOCAL_DEX_PREOPT_FLAGS))
379  $(call add_json_str,  ProfileClassListing,            $(if $(my_process_profile),$(LOCAL_DEX_PREOPT_PROFILE)))
380  $(call add_json_bool, ProfileIsTextListing,           $(my_profile_is_text_listing))
381  $(call add_json_str,  EnforceUsesLibrariesStatusFile, $(my_enforced_uses_libraries))
382  $(call add_json_bool, EnforceUsesLibraries,           $(filter true,$(LOCAL_ENFORCE_USES_LIBRARIES)))
383  $(call add_json_str,  ProvidesUsesLibrary,            $(firstword $(LOCAL_PROVIDES_USES_LIBRARY) $(LOCAL_MODULE)))
384  $(call add_json_map,  ClassLoaderContexts)
385  $(call add_json_class_loader_context, any, $(my_dexpreopt_libs))
386  $(call add_json_class_loader_context,  28, $(my_dexpreopt_libs_compat_28))
387  $(call add_json_class_loader_context,  29, $(my_dexpreopt_libs_compat_29))
388  $(call add_json_class_loader_context,  30, $(my_dexpreopt_libs_compat_30))
389  $(call end_json_map)
390  $(call add_json_list, Archs,                          $(my_dexpreopt_archs))
391  $(call add_json_list, DexPreoptImages,                $(my_dexpreopt_images))
392  $(call add_json_list, DexPreoptImageLocationsOnHost,  $(my_dexpreopt_image_locations_on_host))
393  $(call add_json_list, DexPreoptImageLocationsOnDevice,$(my_dexpreopt_image_locations_on_device))
394  $(call add_json_list, PreoptBootClassPathDexFiles,    $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES))
395  $(call add_json_list, PreoptBootClassPathDexLocations,$(DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS))
396  $(call add_json_bool, PreoptExtractedApk,             $(my_preopt_for_extracted_apk))
397  $(call add_json_bool, NoCreateAppImage,               $(filter false,$(LOCAL_DEX_PREOPT_APP_IMAGE)))
398  $(call add_json_bool, ForceCreateAppImage,            $(filter true,$(LOCAL_DEX_PREOPT_APP_IMAGE)))
399  $(call add_json_bool, PresignedPrebuilt,              $(filter PRESIGNED,$(LOCAL_CERTIFICATE)))
400
401  $(call json_end)
402
403  my_dexpreopt_config := $(intermediates)/dexpreopt.config
404  my_dexpreopt_config_for_postprocessing := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
405  my_dexpreopt_script := $(intermediates)/dexpreopt.sh
406  my_dexpreopt_zip := $(intermediates)/dexpreopt.zip
407  my_dexpreopt_config_merger := $(BUILD_SYSTEM)/dex_preopt_config_merger.py
408
409  $(my_dexpreopt_config): $(my_dexpreopt_dep_configs) $(my_dexpreopt_config_merger)
410  $(my_dexpreopt_config): PRIVATE_MODULE := $(LOCAL_MODULE)
411  $(my_dexpreopt_config): PRIVATE_CONTENTS := $(json_contents)
412  $(my_dexpreopt_config): PRIVATE_DEP_CONFIGS := $(my_dexpreopt_dep_configs)
413  $(my_dexpreopt_config): PRIVATE_CONFIG_MERGER := $(my_dexpreopt_config_merger)
414  $(my_dexpreopt_config):
415	@echo "$(PRIVATE_MODULE) dexpreopt.config"
416	echo -e -n '$(subst $(newline),\n,$(subst ','\'',$(subst \,\\,$(PRIVATE_CONTENTS))))' > $@
417	$(PRIVATE_CONFIG_MERGER) $@ $(PRIVATE_DEP_CONFIGS)
418
419  .KATI_RESTAT: $(my_dexpreopt_script)
420  $(my_dexpreopt_script): PRIVATE_MODULE := $(LOCAL_MODULE)
421  $(my_dexpreopt_script): PRIVATE_GLOBAL_SOONG_CONFIG := $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE)
422  $(my_dexpreopt_script): PRIVATE_GLOBAL_CONFIG := $(DEX_PREOPT_CONFIG_FOR_MAKE)
423  $(my_dexpreopt_script): PRIVATE_MODULE_CONFIG := $(my_dexpreopt_config)
424  $(my_dexpreopt_script): $(DEXPREOPT_GEN)
425  $(my_dexpreopt_script): $(my_dexpreopt_config) $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(DEX_PREOPT_CONFIG_FOR_MAKE)
426	@echo "$(PRIVATE_MODULE) dexpreopt gen"
427	$(DEXPREOPT_GEN) \
428	-global_soong $(PRIVATE_GLOBAL_SOONG_CONFIG) \
429	-global $(PRIVATE_GLOBAL_CONFIG) \
430	-module $(PRIVATE_MODULE_CONFIG) \
431	-dexpreopt_script $@ \
432	-out_dir $(OUT_DIR)
433
434  $(eval $(call copy-one-file,$(my_dexpreopt_config),$(my_dexpreopt_config_for_postprocessing)))
435
436  my_dexpreopt_deps := $(my_dex_jar)
437  my_dexpreopt_deps += $(if $(my_process_profile),$(LOCAL_DEX_PREOPT_PROFILE))
438  my_dexpreopt_deps += \
439    $(foreach lib, $(my_dexpreopt_libs) $(my_dexpreopt_libs_compat), \
440      $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/javalib.jar)
441  my_dexpreopt_deps += $(my_dexpreopt_images_deps)
442  my_dexpreopt_deps += $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES)
443  ifeq ($(LOCAL_ENFORCE_USES_LIBRARIES),true)
444    my_dexpreopt_deps += $(intermediates.COMMON)/enforce_uses_libraries.status
445  endif
446
447  $(my_dexpreopt_zip): PRIVATE_MODULE := $(LOCAL_MODULE)
448  $(my_dexpreopt_zip): $(my_dexpreopt_deps)
449  $(my_dexpreopt_zip): | $(DEXPREOPT_GEN_DEPS)
450  $(my_dexpreopt_zip): .KATI_DEPFILE := $(my_dexpreopt_zip).d
451  $(my_dexpreopt_zip): PRIVATE_DEX := $(my_dex_jar)
452  $(my_dexpreopt_zip): PRIVATE_SCRIPT := $(my_dexpreopt_script)
453  $(my_dexpreopt_zip): $(my_dexpreopt_script)
454	@echo "$(PRIVATE_MODULE) dexpreopt"
455	bash $(PRIVATE_SCRIPT) $(PRIVATE_DEX) $@
456
457  ifdef LOCAL_POST_INSTALL_CMD
458    # Add a shell command separator
459    LOCAL_POST_INSTALL_CMD += &&
460  endif
461
462  LOCAL_POST_INSTALL_CMD += \
463    for i in $$(zipinfo -1 $(my_dexpreopt_zip)); \
464      do mkdir -p $(PRODUCT_OUT)/$$(dirname $$i); \
465    done && \
466    ( unzip -qoDD -d $(PRODUCT_OUT) $(my_dexpreopt_zip) 2>&1 | grep -v "zipfile is empty"; exit $${PIPESTATUS[0]} ) || \
467      ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )
468
469  $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
470  $(LOCAL_INSTALLED_MODULE): $(my_dexpreopt_zip)
471  $(LOCAL_INSTALLED_MODULE): $(my_dexpreopt_config_for_postprocessing)
472
473  $(my_all_targets): $(my_dexpreopt_zip)
474
475  my_dexpreopt_config :=
476  my_dexpreopt_script :=
477  my_dexpreopt_zip :=
478  my_dexpreopt_config_for_postprocessing :=
479endif # LOCAL_DEX_PREOPT
480