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