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 | |
Victor Hsieh | e53dd7b | 2018-10-22 11:25:05 -0700 | [diff] [blame] | 6 | ifeq (true,$(LOCAL_PREFER_INTEGRITY)) |
| 7 | LOCAL_UNCOMPRESS_DEX := true |
| 8 | else |
| 9 | LOCAL_UNCOMPRESS_DEX := |
| 10 | endif |
| 11 | |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 12 | # We explicitly uncompress APKs of privileged apps, and used by |
| 13 | # privileged apps |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 14 | ifneq (true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS)) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 15 | ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 16 | LOCAL_UNCOMPRESS_DEX := true |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 17 | endif |
| 18 | |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 19 | ifneq (,$(filter $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES), $(LOCAL_MODULE))) |
| 20 | LOCAL_UNCOMPRESS_DEX := true |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 21 | endif |
Nicolas Geoffray | 3972a47 | 2018-01-09 11:46:30 +0000 | [diff] [blame] | 22 | endif # DONT_UNCOMPRESS_PRIV_APPS_DEXS |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 23 | |
| 24 | # Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc |
| 25 | LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT)) |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 26 | ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined |
| 27 | LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT) |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 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 |
| 39 | endif |
| 40 | |
| 41 | ifeq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 42 | LOCAL_DEX_PREOPT := true |
| 43 | LOCAL_STRIP_DEX := |
| 44 | else |
| 45 | LOCAL_STRIP_DEX := true |
Colin Cross | fc782ad | 2018-10-22 13:44:27 -0700 | [diff] [blame] | 46 | endif |
| 47 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 48 | ifeq (false,$(LOCAL_DEX_PREOPT)) |
| 49 | LOCAL_DEX_PREOPT := |
| 50 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 51 | |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 52 | # Only enable preopt for non tests. |
| 53 | ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests)) |
| 54 | LOCAL_DEX_PREOPT := |
| 55 | endif |
| 56 | |
| 57 | # If we have product-specific config for this module? |
Colin Cross | 3aa2f8f | 2018-10-05 14:41:04 -0700 | [diff] [blame] | 58 | ifneq (,$(filter $(LOCAL_MODULE),$(DEXPREOPT_DISABLED_MODULES))) |
Colin Cross | c18757e | 2018-10-09 16:33:27 -0700 | [diff] [blame] | 59 | LOCAL_DEX_PREOPT := |
| 60 | endif |
| 61 | |
| 62 | # Disable preopt for TARGET_BUILD_APPS |
| 63 | ifneq (,$(TARGET_BUILD_APPS)) |
| 64 | LOCAL_DEX_PREOPT := |
| 65 | endif |
| 66 | |
| 67 | # Disable preopt if not WITH_DEXPREOPT |
| 68 | ifneq (true,$(WITH_DEXPREOPT)) |
| 69 | LOCAL_DEX_PREOPT := |
| 70 | endif |
| 71 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 72 | ifdef LOCAL_UNINSTALLABLE_MODULE |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 73 | LOCAL_DEX_PREOPT := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 74 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 75 | |
Colin Cross | f229de4 | 2017-10-05 16:01:00 -0700 | [diff] [blame] | 76 | 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] | 77 | LOCAL_DEX_PREOPT := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 78 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 79 | |
Mathieu Chartier | 418258c | 2017-08-28 14:19:35 -0700 | [diff] [blame] | 80 | # 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 Chartier | 0fbb836 | 2017-09-15 13:40:48 -0700 | [diff] [blame] | 83 | # or performance. If my_preopt_for_extracted_apk is true, we ignore the only preopt boot image |
| 84 | # options. |
| 85 | ifneq (true,$(my_preopt_for_extracted_apk)) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 86 | 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 Chartier | 0fbb836 | 2017-09-15 13:40:48 -0700 | [diff] [blame] | 91 | endif |
| 92 | |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 93 | ifeq ($(LOCAL_DEX_PREOPT),true) |
| 94 | # Don't strip with dexes we explicitly uncompress (dexopt will not store the dex code). |
| 95 | ifeq ($(LOCAL_UNCOMPRESS_DEX),true) |
| 96 | LOCAL_STRIP_DEX := |
| 97 | endif # LOCAL_UNCOMPRESS_DEX |
| 98 | |
| 99 | # 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)),) |
| 103 | LOCAL_STRIP_DEX := |
| 104 | endif # install-on-system-other |
| 105 | endif # BOARD_USES_SYSTEM_OTHER_ODEX |
| 106 | |
| 107 | # 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. |
| 111 | endif # LOCAL_DEX_PREOPT |
| 112 | |
| 113 | built_odex := |
| 114 | built_vdex := |
| 115 | built_art := |
| 116 | installed_odex := |
| 117 | installed_vdex := |
| 118 | installed_art := |
| 119 | built_installed_odex := |
| 120 | built_installed_vdex := |
| 121 | built_installed_art := |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 122 | my_process_profile := |
| 123 | my_profile_is_text_listing := |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 124 | my_generate_dm := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 125 | |
Mathieu Chartier | 6324c2d | 2017-05-05 17:22:37 -0700 | [diff] [blame] | 126 | ifeq (false,$(WITH_DEX_PREOPT_GENERATE_PROFILE)) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 127 | LOCAL_DEX_PREOPT_GENERATE_PROFILE := false |
Mathieu Chartier | 6324c2d | 2017-05-05 17:22:37 -0700 | [diff] [blame] | 128 | endif |
| 129 | |
| 130 | ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 131 | # 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 Juravle | 7d70135 | 2018-04-25 15:25:46 -0700 | [diff] [blame] | 135 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 136 | ifneq (,$(wildcard $(LOCAL_DEX_PREOPT_PROFILE))) |
| 137 | my_process_profile := true |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 138 | my_profile_is_text_listing := false |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 139 | endif |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 140 | else |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 141 | 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 Chartier | 6324c2d | 2017-05-05 17:22:37 -0700 | [diff] [blame] | 144 | endif |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 145 | |
Calin Juravle | f99ab75 | 2018-04-19 20:32:57 -0700 | [diff] [blame] | 146 | ifeq (true,$(my_process_profile)) |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 147 | |
| 148 | ifeq (,$(LOCAL_DEX_PREOPT_APP_IMAGE)) |
| 149 | LOCAL_DEX_PREOPT_APP_IMAGE := true |
| 150 | endif |
| 151 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 152 | 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 |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 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): |
| 172 | $(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=$@ |
| 178 | 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): |
| 182 | $(hide) mkdir -p $(dir $@) |
| 183 | touch $@ |
| 184 | ANDROID_LOG_TAGS="*:e" $(PROFMAN) \ |
| 185 | --copy-and-update-profile-key \ |
| 186 | --profile-file=$(PRIVATE_SOURCE_CLASSES) \ |
| 187 | --apk=$(PRIVATE_BUILT_MODULE) \ |
| 188 | --dex-location=$(PRIVATE_DEX_LOCATION) \ |
| 189 | --reference-profile-file=$@ \ |
| 190 | || echo "Profile out of date for $(PRIVATE_BUILT_MODULE)" |
Colin Cross | e736c58 | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 191 | endif |
Colin Cross | e736c58 | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 192 | |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 193 | my_profile_is_text_listing := |
| 194 | dex_preopt_profile_src_file := |
| 195 | |
| 196 | # Remove compressed APK extension. |
| 197 | my_installed_profile := $(patsubst %.gz,%,$(LOCAL_INSTALLED_MODULE)).prof |
| 198 | |
| 199 | # 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) |
| 202 | else |
| 203 | build_installed_profile:= |
| 204 | my_installed_profile := |
| 205 | endif |
Colin Cross | e736c58 | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 206 | |
Mathieu Chartier | 4876229 | 2017-09-13 22:08:45 -0700 | [diff] [blame] | 207 | ifdef LOCAL_DEX_PREOPT |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 208 | |
| 209 | dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) |
| 210 | |
| 211 | 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) |
| 219 | |
| 220 | 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 |
| 231 | |
| 232 | # Only preopt primary arch for translated arch since there is only an image there. |
| 233 | ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 234 | my_module_multilib := first |
| 235 | endif |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 236 | |
| 237 | # ################################################# |
| 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 |
| 268 | |
| 269 | 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)) |
| 275 | |
| 276 | 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) |
| 280 | else |
| 281 | $(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) |
| 288 | endif |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 289 | endif |
| 290 | |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 291 | my_system_server_compiler_filter := $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER) |
| 292 | ifeq (,$(my_system_server_compiler_filter)) |
| 293 | my_system_server_compiler_filter := speed |
Mathieu Chartier | c5536ff | 2017-05-05 14:59:06 -0700 | [diff] [blame] | 294 | endif |
Nicolas Geoffray | b08ada1 | 2017-03-22 12:36:05 +0000 | [diff] [blame] | 295 | |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 296 | 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 |
| 301 | |
| 302 | 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 |
| 335 | LOCAL_DEX_PREOPT := true |
| 336 | LOCAL_STRIP_DEX := |
| 337 | 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) |
| 343 | $(hide) mkdir -p $(dir $@) |
| 344 | $(hide) rm -f $@ |
| 345 | $(hide) zip -qD -j -X -9 $@ $(PRIVATE_INPUT_VDEX) |
| 346 | $(ZIPTIME) $@ |
| 347 | $(eval $(call copy-one-file,$(my_built_dm),$(my_installed_dm))) |
| 348 | endif |
| 349 | |
| 350 | # By default, emit debug info. |
| 351 | my_dexpreopt_debug_info := true |
| 352 | # 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) |
| 392 | endif |
| 393 | |
| 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) |
| 413 | endif |
Andreas Gampe | cdfe46b | 2018-03-19 14:28:15 -0700 | [diff] [blame] | 414 | |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 415 | # 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) |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 422 | DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex) |
Colin Cross | 0a69bb6 | 2018-10-09 16:14:44 -0700 | [diff] [blame] | 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 Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 426 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 427 | endif # LOCAL_DEX_PREOPT |
Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 428 | |
| 429 | # Profile doesn't depend on LOCAL_DEX_PREOPT. |
| 430 | ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed_profile) |
| 431 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(build_installed_profile) |
| 432 | |
| 433 | my_process_profile := |
| 434 | |
| 435 | $(my_all_targets): $(my_installed_profile) |