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