Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 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 |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 3 | # 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 |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 8 | ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS)) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 9 | ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 10 | LOCAL_UNCOMPRESS_DEX := true |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 11 | endif |
| 12 | |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 13 | ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE))) |
| 14 | LOCAL_UNCOMPRESS_DEX := true |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 15 | endif |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 16 | endif # DONT_UNCOMPRESS_PRIV_APPS_DEXS |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 17 | |
| 18 | # Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc |
| 19 | LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT)) |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 20 | ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined |
| 21 | LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT) |
| 22 | |
| 23 | ifeq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Not installed to system.img. |
| 24 | # Default to nostripping for non system preopt (enables preopt). |
| 25 | # Don't strip in case the oat/vdex version in system ROM doesn't match the one in other |
| 26 | # partitions. It needs to be able to fall back to the APK for that case. |
| 27 | LOCAL_DEX_PREOPT := nostripping |
| 28 | endif |
| 29 | |
| 30 | ifneq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES not empty |
| 31 | LOCAL_DEX_PREOPT := nostripping |
| 32 | endif |
| 33 | endif |
| 34 | |
Colin Cross | fc782ad | 2018-10-22 13:44:27 -0700 | [diff] [blame] | 35 | ifeq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 36 | LOCAL_DEX_PREOPT := true |
| 37 | LOCAL_STRIP_DEX := |
| 38 | else |
| 39 | LOCAL_STRIP_DEX := true |
| 40 | endif |
| 41 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 42 | ifeq (false,$(LOCAL_DEX_PREOPT)) |
| 43 | LOCAL_DEX_PREOPT := |
| 44 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 45 | |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 46 | # Only enable preopt for non tests. |
| 47 | ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests)) |
| 48 | LOCAL_DEX_PREOPT := |
| 49 | endif |
| 50 | |
| 51 | # If we have product-specific config for this module? |
| 52 | ifeq (disable,$(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)) |
| 53 | LOCAL_DEX_PREOPT := |
| 54 | endif |
| 55 | |
| 56 | # Disable preopt for TARGET_BUILD_APPS |
| 57 | ifneq (,$(TARGET_BUILD_APPS)) |
| 58 | LOCAL_DEX_PREOPT := |
| 59 | endif |
| 60 | |
| 61 | # Disable preopt if not WITH_DEXPREOPT |
| 62 | ifneq (true,$(WITH_DEXPREOPT)) |
| 63 | LOCAL_DEX_PREOPT := |
| 64 | endif |
| 65 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 66 | ifdef LOCAL_UNINSTALLABLE_MODULE |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 67 | LOCAL_DEX_PREOPT := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 68 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 69 | |
Colin Cross | f229de4 | 2017-10-05 16:01:00 -0700 | [diff] [blame] | 70 | ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR))) # contains no java code |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 71 | LOCAL_DEX_PREOPT := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 72 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 73 | |
Mathieu Chartier | 418258c | 2017-08-28 14:19:35 -0700 | [diff] [blame] | 74 | # if WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true and module is not in boot class path skip |
| 75 | # Also preopt system server jars since selinux prevents system server from loading anything from |
| 76 | # /data. If we don't do this they will need to be extracted which is not favorable for RAM usage |
Mathieu Chartier | 0fbb836 | 2017-09-15 13:40:48 -0700 | [diff] [blame] | 77 | # or performance. If my_preopt_for_extracted_apk is true, we ignore the only preopt boot image |
| 78 | # options. |
| 79 | ifneq (true,$(my_preopt_for_extracted_apk)) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 80 | ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)) |
| 81 | ifeq ($(filter $(PRODUCT_SYSTEM_SERVER_JARS) $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),) |
| 82 | LOCAL_DEX_PREOPT := |
| 83 | endif |
| 84 | endif |
Mathieu Chartier | 0fbb836 | 2017-09-15 13:40:48 -0700 | [diff] [blame] | 85 | endif |
| 86 | |
Alex Light | 4e358ab | 2016-06-16 14:47:10 -0700 | [diff] [blame] | 87 | ifeq ($(LOCAL_DEX_PREOPT),true) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 88 | # Don't strip with dexes we explicitly uncompress (dexopt will not store the dex code). |
| 89 | ifeq ($(LOCAL_UNCOMPRESS_DEX),true) |
Colin Cross | fc782ad | 2018-10-22 13:44:27 -0700 | [diff] [blame] | 90 | LOCAL_STRIP_DEX := |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 91 | endif # LOCAL_UNCOMPRESS_DEX |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 92 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 93 | # system_other isn't there for an OTA, so don't strip |
| 94 | # if module is on system, and odex is on system_other. |
| 95 | ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true) |
| 96 | ifneq ($(call install-on-system-other, $(my_module_path)),) |
Colin Cross | fc782ad | 2018-10-22 13:44:27 -0700 | [diff] [blame] | 97 | LOCAL_STRIP_DEX := |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 98 | endif # install-on-system-other |
| 99 | endif # BOARD_USES_SYSTEM_OTHER_ODEX |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 100 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 101 | # We also don't strip if all dexs are uncompressed (dexopt will not store the dex code), |
| 102 | # but that requires to inspect the source file, which is too early at this point (as we |
| 103 | # don't know if the source file will actually be used). |
| 104 | # See dexpreopt-remove-classes.dex. |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 105 | endif # LOCAL_DEX_PREOPT |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 106 | |
| 107 | built_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 108 | built_vdex := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 109 | built_art := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 110 | installed_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 111 | installed_vdex := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 112 | installed_art := |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 113 | built_installed_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 114 | built_installed_vdex := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 115 | built_installed_art := |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 116 | my_process_profile := |
| 117 | my_profile_is_text_listing := |
Po Hu | eaef4d8 | 2018-10-10 13:13:38 +0800 | [diff] [blame] | 118 | my_generate_dm := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 119 | |
Mathieu Chartier | 6324c2d | 2017-05-05 17:22:37 -0700 | [diff] [blame] | 120 | ifeq (false,$(WITH_DEX_PREOPT_GENERATE_PROFILE)) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 121 | LOCAL_DEX_PREOPT_GENERATE_PROFILE := false |
Mathieu Chartier | 6324c2d | 2017-05-05 17:22:37 -0700 | [diff] [blame] | 122 | endif |
| 123 | |
| 124 | ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 125 | # If LOCAL_DEX_PREOPT_GENERATE_PROFILE is not defined, default it based on the existence of the |
| 126 | # profile class listing. TODO: Use product specific directory here. |
| 127 | my_classes_directory := $(PRODUCT_DEX_PREOPT_PROFILE_DIR) |
| 128 | LOCAL_DEX_PREOPT_PROFILE := $(my_classes_directory)/$(LOCAL_MODULE).prof |
Calin Juravle | 7d70135 | 2018-04-25 15:25:46 -0700 | [diff] [blame] | 129 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 130 | ifneq (,$(wildcard $(LOCAL_DEX_PREOPT_PROFILE))) |
| 131 | my_process_profile := true |
| 132 | my_profile_is_text_listing := false |
| 133 | endif |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 134 | else |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 135 | my_process_profile := $(LOCAL_DEX_PREOPT_GENERATE_PROFILE) |
| 136 | my_profile_is_text_listing := true |
| 137 | LOCAL_DEX_PREOPT_PROFILE := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING) |
Mathieu Chartier | 6324c2d | 2017-05-05 17:22:37 -0700 | [diff] [blame] | 138 | endif |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 139 | |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 140 | ifeq (true,$(my_process_profile)) |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 141 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 142 | ifeq (,$(LOCAL_DEX_PREOPT_APP_IMAGE)) |
| 143 | LOCAL_DEX_PREOPT_APP_IMAGE := true |
| 144 | endif |
Mathieu Chartier | 6324c2d | 2017-05-05 17:22:37 -0700 | [diff] [blame] | 145 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 146 | ifndef LOCAL_DEX_PREOPT_PROFILE |
| 147 | $(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE)) |
| 148 | endif |
| 149 | ifeq (,$(dex_preopt_profile_src_file)) |
| 150 | $(call pretty-error, Internal error: dex_preopt_profile_src_file must be set) |
| 151 | endif |
| 152 | my_built_profile := $(dir $(LOCAL_BUILT_MODULE))/profile.prof |
| 153 | my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) |
| 154 | # Remove compressed APK extension. |
| 155 | my_dex_location := $(patsubst %.gz,%,$(my_dex_location)) |
| 156 | $(my_built_profile): PRIVATE_BUILT_MODULE := $(dex_preopt_profile_src_file) |
| 157 | $(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location) |
| 158 | $(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE) |
| 159 | $(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE) |
| 160 | $(my_built_profile): $(PROFMAN) |
| 161 | $(my_built_profile): $(dex_preopt_profile_src_file) |
| 162 | ifeq (true,$(my_profile_is_text_listing)) |
| 163 | # The profile is a test listing of classes (used for framework jars). |
| 164 | # We need to generate the actual binary profile before being able to compile. |
| 165 | $(my_built_profile): |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 166 | $(hide) mkdir -p $(dir $@) |
| 167 | ANDROID_LOG_TAGS="*:e" $(PROFMAN) \ |
| 168 | --create-profile-from=$(PRIVATE_SOURCE_CLASSES) \ |
| 169 | --apk=$(PRIVATE_BUILT_MODULE) \ |
| 170 | --dex-location=$(PRIVATE_DEX_LOCATION) \ |
| 171 | --reference-profile-file=$@ |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 172 | else |
| 173 | # The profile is binary profile (used for apps). Run it through profman to |
| 174 | # ensure the profile keys match the apk. |
| 175 | $(my_built_profile): |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 176 | $(hide) mkdir -p $(dir $@) |
| 177 | touch $@ |
| 178 | ANDROID_LOG_TAGS="*:i" $(PROFMAN) \ |
| 179 | --copy-and-update-profile-key \ |
| 180 | --profile-file=$(PRIVATE_SOURCE_CLASSES) \ |
| 181 | --apk=$(PRIVATE_BUILT_MODULE) \ |
Calin Juravle | 6021661 | 2018-04-26 18:52:45 -0700 | [diff] [blame] | 182 | --dex-location=$(PRIVATE_DEX_LOCATION) \ |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 183 | --reference-profile-file=$@ \ |
| 184 | || echo "Profile out of date for $(PRIVATE_BUILT_MODULE)" |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 185 | endif |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 186 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 187 | my_profile_is_text_listing := |
| 188 | dex_preopt_profile_src_file := |
Mathieu Chartier | 5c658ac | 2018-02-15 13:19:38 -0800 | [diff] [blame] | 189 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 190 | # Remove compressed APK extension. |
| 191 | my_installed_profile := $(patsubst %.gz,%,$(LOCAL_INSTALLED_MODULE)).prof |
Mathieu Chartier | 5c658ac | 2018-02-15 13:19:38 -0800 | [diff] [blame] | 192 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 193 | # my_installed_profile := $(LOCAL_INSTALLED_MODULE).prof |
| 194 | $(eval $(call copy-one-file,$(my_built_profile),$(my_installed_profile))) |
| 195 | build_installed_profile:=$(my_built_profile):$(my_installed_profile) |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 196 | else |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 197 | build_installed_profile:= |
| 198 | my_installed_profile := |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 199 | endif |
| 200 | |
| 201 | ifdef LOCAL_DEX_PREOPT |
| 202 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 203 | dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) |
Andreas Gampe | 039bb48 | 2018-01-19 10:56:23 -0800 | [diff] [blame] | 204 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 205 | ifdef dexpreopt_boot_jar_module |
| 206 | # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). |
| 207 | # We use this installed_odex trick to get boot.art installed. |
| 208 | installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
| 209 | # Append the odex for the 2nd arch if we have one. |
| 210 | installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
| 211 | else # boot jar |
| 212 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
Andreas Gampe | 039bb48 | 2018-01-19 10:56:23 -0800 | [diff] [blame] | 213 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 214 | my_module_multilib := $(LOCAL_MULTILIB) |
| 215 | # If the module is not an SDK library and it's a system server jar, only preopt the primary arch. |
| 216 | my_filtered_lib_name := $(patsubst %.impl,%,$(LOCAL_MODULE)) |
| 217 | ifeq (,$(filter $(JAVA_SDK_LIBRARIES),$(my_filtered_lib_name))) |
| 218 | # For a Java library, by default we build odex for both 1st arch and 2nd arch. |
| 219 | # But it can be overridden with "LOCAL_MULTILIB := first". |
| 220 | ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE))) |
| 221 | # For system server jars, we build for only "first". |
| 222 | my_module_multilib := first |
| 223 | endif |
| 224 | endif |
Mathieu Chartier | 502892a | 2018-07-06 13:29:43 -0700 | [diff] [blame] | 225 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 226 | # Only preopt primary arch for translated arch since there is only an image there. |
| 227 | ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
| 228 | my_module_multilib := first |
| 229 | endif |
Mathieu Chartier | 502892a | 2018-07-06 13:29:43 -0700 | [diff] [blame] | 230 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 231 | # ################################################# |
| 232 | # Odex for the 1st arch |
| 233 | my_2nd_arch_prefix := |
| 234 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
| 235 | # ################################################# |
| 236 | # Odex for the 2nd arch |
| 237 | ifdef TARGET_2ND_ARCH |
| 238 | ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
| 239 | ifneq (first,$(my_module_multilib)) |
| 240 | my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 241 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
| 242 | endif # my_module_multilib is not first. |
| 243 | endif # TARGET_TRANSLATE_2ND_ARCH not true |
| 244 | endif # TARGET_2ND_ARCH |
| 245 | # ################################################# |
| 246 | else # must be APPS |
| 247 | # The preferred arch |
| 248 | my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) |
| 249 | # Save the module multilib since setup_one_odex modifies it. |
| 250 | saved_my_module_multilib := $(my_module_multilib) |
| 251 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
| 252 | my_module_multilib := $(saved_my_module_multilib) |
| 253 | ifdef TARGET_2ND_ARCH |
| 254 | ifeq ($(my_module_multilib),both) |
| 255 | # The non-preferred arch |
| 256 | my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX)) |
| 257 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
| 258 | endif # LOCAL_MULTILIB is both |
| 259 | endif # TARGET_2ND_ARCH |
| 260 | endif # LOCAL_MODULE_CLASS |
| 261 | endif # boot jar |
Mathieu Chartier | fd5dfb8 | 2018-07-12 18:17:54 -0700 | [diff] [blame] | 262 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 263 | built_odex := $(strip $(built_odex)) |
| 264 | built_vdex := $(strip $(built_vdex)) |
| 265 | built_art := $(strip $(built_art)) |
| 266 | installed_odex := $(strip $(installed_odex)) |
| 267 | installed_vdex := $(strip $(installed_vdex)) |
| 268 | installed_art := $(strip $(installed_art)) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 269 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 270 | ifdef built_odex |
| 271 | ifeq (true,$(my_process_profile)) |
| 272 | $(built_odex): $(my_built_profile) |
| 273 | $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile) |
Mathieu Chartier | c5536ff | 2017-05-05 14:59:06 -0700 | [diff] [blame] | 274 | else |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 275 | $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := |
| 276 | endif |
| 277 | |
| 278 | ifndef LOCAL_DEX_PREOPT_FLAGS |
| 279 | LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG) |
| 280 | ifndef LOCAL_DEX_PREOPT_FLAGS |
| 281 | LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS) |
Mathieu Chartier | 6a90210 | 2017-06-23 10:44:45 -0700 | [diff] [blame] | 282 | endif |
Mathieu Chartier | c5536ff | 2017-05-05 14:59:06 -0700 | [diff] [blame] | 283 | endif |
Nicolas Geoffray | b08ada1 | 2017-03-22 12:36:05 +0000 | [diff] [blame] | 284 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 285 | my_system_server_compiler_filter := $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER) |
| 286 | ifeq (,$(my_system_server_compiler_filter)) |
| 287 | my_system_server_compiler_filter := speed |
| 288 | endif |
Mathieu Chartier | 5c658ac | 2018-02-15 13:19:38 -0800 | [diff] [blame] | 289 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 290 | my_default_compiler_filter := $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER) |
| 291 | ifeq (,$(my_default_compiler_filter)) |
| 292 | # If no default compiler filter is specified, default to 'quicken' to save on storage. |
| 293 | my_default_compiler_filter := quicken |
| 294 | endif |
Mathieu Chartier | 5c658ac | 2018-02-15 13:19:38 -0800 | [diff] [blame] | 295 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 296 | ifeq (,$(filter --compiler-filter=%, $(LOCAL_DEX_PREOPT_FLAGS))) |
| 297 | ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE))) |
| 298 | # Jars of system server, use the product option if it is set, speed otherwise. |
| 299 | LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=$(my_system_server_compiler_filter) |
| 300 | else |
| 301 | ifneq (,$(filter $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(LOCAL_MODULE))) |
| 302 | # Apps loaded into system server, and apps the product default to being compiled with the |
| 303 | # 'speed' compiler filter. |
| 304 | LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed |
| 305 | else |
| 306 | ifeq (true,$(my_process_profile)) |
| 307 | # For non system server jars, use speed-profile when we have a profile. |
| 308 | LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed-profile |
| 309 | else |
| 310 | LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=$(my_default_compiler_filter) |
| 311 | endif |
| 312 | endif |
| 313 | endif |
| 314 | endif |
| 315 | |
| 316 | my_generate_dm := $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES) |
| 317 | ifeq (,$(filter $(LOCAL_DEX_PREOPT_FLAGS),--compiler-filter=verify)) |
| 318 | # Generating DM files only makes sense for verify, avoid doing for non verify compiler filter APKs. |
| 319 | my_generate_dm := false |
| 320 | endif |
| 321 | |
| 322 | # No reason to use a dm file if the dex is already uncompressed. |
| 323 | ifeq ($(LOCAL_UNCOMPRESS_DEX),true) |
| 324 | my_generate_dm := false |
| 325 | endif |
| 326 | |
| 327 | ifeq (true,$(my_generate_dm)) |
| 328 | LOCAL_DEX_PREOPT_FLAGS += --copy-dex-files=false |
Colin Cross | fc782ad | 2018-10-22 13:44:27 -0700 | [diff] [blame] | 329 | LOCAL_DEX_PREOPT := true |
| 330 | LOCAL_STRIP_DEX := |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 331 | my_built_dm := $(dir $(LOCAL_BUILT_MODULE))generated.dm |
| 332 | my_installed_dm := $(patsubst %.apk,%,$(LOCAL_INSTALLED_MODULE)).dm |
| 333 | my_copied_vdex := $(dir $(LOCAL_BUILT_MODULE))primary.vdex |
| 334 | $(eval $(call copy-one-file,$(built_vdex),$(my_copied_vdex))) |
| 335 | $(my_built_dm): PRIVATE_INPUT_VDEX := $(my_copied_vdex) |
| 336 | $(my_built_dm): $(my_copied_vdex) $(ZIPTIME) |
Mathieu Chartier | 5c658ac | 2018-02-15 13:19:38 -0800 | [diff] [blame] | 337 | $(hide) mkdir -p $(dir $@) |
| 338 | $(hide) rm -f $@ |
| 339 | $(hide) zip -qD -j -X -9 $@ $(PRIVATE_INPUT_VDEX) |
| 340 | $(ZIPTIME) $@ |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 341 | $(eval $(call copy-one-file,$(my_built_dm),$(my_installed_dm))) |
| 342 | endif |
Mathieu Chartier | 5c658ac | 2018-02-15 13:19:38 -0800 | [diff] [blame] | 343 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 344 | # By default, emit debug info. |
Andreas Gampe | cdfe46b | 2018-03-19 14:28:15 -0700 | [diff] [blame] | 345 | my_dexpreopt_debug_info := true |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 346 | # If the global setting suppresses mini-debug-info, disable it. |
| 347 | ifeq (false,$(WITH_DEXPREOPT_DEBUG_INFO)) |
| 348 | my_dexpreopt_debug_info := false |
| 349 | endif |
| 350 | |
| 351 | # PRODUCT_SYSTEM_SERVER_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO. |
| 352 | # PRODUCT_OTHER_JAVA_DEBUG_INFO overrides WITH_DEXPREOPT_DEBUG_INFO. |
| 353 | ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE))) |
| 354 | ifeq (true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO)) |
| 355 | my_dexpreopt_debug_info := true |
| 356 | else ifeq (false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO)) |
| 357 | my_dexpreopt_debug_info := false |
| 358 | endif |
| 359 | else |
| 360 | ifeq (true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO)) |
| 361 | my_dexpreopt_debug_info := true |
| 362 | else ifeq (false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO)) |
| 363 | my_dexpreopt_debug_info := false |
| 364 | endif |
| 365 | endif |
| 366 | |
| 367 | # Never enable on eng. |
| 368 | ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT))) |
| 369 | my_dexpreopt_debug_info := false |
| 370 | endif |
| 371 | |
| 372 | # Add dex2oat flag for debug-info/no-debug-info. |
| 373 | ifeq (true,$(my_dexpreopt_debug_info)) |
| 374 | LOCAL_DEX_PREOPT_FLAGS += --generate-mini-debug-info |
| 375 | else ifeq (false,$(my_dexpreopt_debug_info)) |
| 376 | LOCAL_DEX_PREOPT_FLAGS += --no-generate-mini-debug-info |
| 377 | endif |
| 378 | |
| 379 | # Set the compiler reason to 'prebuilt' to identify the oat files produced |
| 380 | # during the build, as opposed to compiled on the device. |
| 381 | LOCAL_DEX_PREOPT_FLAGS += --compilation-reason=prebuilt |
| 382 | |
| 383 | $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) |
| 384 | $(built_vdex): $(built_odex) |
| 385 | $(built_art): $(built_odex) |
Mathieu Chartier | 94f5f93 | 2017-06-23 14:47:56 -0700 | [diff] [blame] | 386 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 387 | |
| 388 | ifneq (true,$(my_generate_dm)) |
| 389 | # Add the installed_odex to the list of installed files for this module if we aren't generating a |
| 390 | # dm file. |
| 391 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex) |
| 392 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_vdex) |
| 393 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_art) |
| 394 | |
| 395 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex) |
| 396 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_vdex) |
| 397 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_art) |
| 398 | |
| 399 | # Make sure to install the .odex and .vdex when you run "make <module_name>" |
| 400 | $(my_all_targets): $(installed_odex) $(installed_vdex) $(installed_art) |
| 401 | else |
| 402 | ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_dm) |
| 403 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(my_built_dm) $(my_installed_dm) |
| 404 | |
| 405 | # Make sure to install the .dm when you run "make <module_name>" |
| 406 | $(my_all_targets): $(installed_dm) |
Andreas Gampe | cdfe46b | 2018-03-19 14:28:15 -0700 | [diff] [blame] | 407 | endif |
Andreas Gampe | cdfe46b | 2018-03-19 14:28:15 -0700 | [diff] [blame] | 408 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 409 | # Record dex-preopt config. |
| 410 | DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT) |
| 411 | DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB) |
| 412 | DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) |
| 413 | DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE) |
| 414 | DEXPREOPT.$(LOCAL_MODULE).VENDOR_MODULE := $(LOCAL_VENDOR_MODULE) |
| 415 | DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH) |
| 416 | DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex) |
| 417 | DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE) |
| 418 | DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \ |
| 419 | $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE)) |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 420 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 421 | endif # LOCAL_DEX_PREOPT |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 422 | |
| 423 | # Profile doesn't depend on LOCAL_DEX_PREOPT. |
| 424 | ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_profile) |
| 425 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(build_installed_profile) |
| 426 | |
Calin Juravle | 7d70135 | 2018-04-25 15:25:46 -0700 | [diff] [blame] | 427 | my_process_profile := |
| 428 | |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 429 | $(my_all_targets): $(my_installed_profile) |