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 |
| 3 | # Output variables: LOCAL_DEX_PREOPT, built_odex, dexpreopt_boot_jar_module |
| 4 | |
| 5 | # Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc |
| 6 | LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT)) |
| 7 | ifneq (true,$(WITH_DEXPREOPT)) |
| 8 | LOCAL_DEX_PREOPT := |
| 9 | else # WITH_DEXPREOPT=true |
| 10 | ifeq (,$(TARGET_BUILD_APPS)) # TARGET_BUILD_APPS empty |
Ying Wang | 9db168c | 2014-01-03 16:24:56 -0800 | [diff] [blame] | 11 | ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined |
Ying Wang | edfd55a | 2014-07-09 10:57:32 -0700 | [diff] [blame] | 12 | ifneq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Installed to system.img. |
| 13 | ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty |
Ying Wang | 20ebd2e | 2014-10-07 18:07:23 -0700 | [diff] [blame] | 14 | # If we have product-specific config for this module? |
| 15 | ifeq (disable,$(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)) |
| 16 | LOCAL_DEX_PREOPT := false |
| 17 | else |
| 18 | LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT) |
| 19 | endif |
Ying Wang | edfd55a | 2014-07-09 10:57:32 -0700 | [diff] [blame] | 20 | else # LOCAL_APK_LIBRARIES not empty |
| 21 | LOCAL_DEX_PREOPT := nostripping |
| 22 | endif # LOCAL_APK_LIBRARIES not empty |
| 23 | endif # Installed to system.img. |
Ying Wang | 9db168c | 2014-01-03 16:24:56 -0800 | [diff] [blame] | 24 | endif # LOCAL_DEX_PREOPT undefined |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 25 | endif # TARGET_BUILD_APPS empty |
| 26 | endif # WITH_DEXPREOPT=true |
| 27 | ifeq (false,$(LOCAL_DEX_PREOPT)) |
| 28 | LOCAL_DEX_PREOPT := |
| 29 | endif |
| 30 | ifdef LOCAL_UNINSTALLABLE_MODULE |
| 31 | LOCAL_DEX_PREOPT := |
| 32 | endif |
Ying Wang | 62fb8a1 | 2014-10-08 14:48:07 -0700 | [diff] [blame] | 33 | ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 34 | LOCAL_DEX_PREOPT := |
| 35 | endif |
Alex Light | 7326f7b | 2014-08-04 17:09:41 -0700 | [diff] [blame] | 36 | # if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip |
| 37 | ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_ONLY)) |
| 38 | ifeq ($(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),) |
| 39 | LOCAL_DEX_PREOPT := |
| 40 | endif |
| 41 | endif |
Alex Light | 4e358ab | 2016-06-16 14:47:10 -0700 | [diff] [blame] | 42 | # if installing into system, and odex are being installed into system_other, don't strip |
| 43 | ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true) |
| 44 | ifeq ($(LOCAL_DEX_PREOPT),true) |
| 45 | ifneq ($(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(my_module_path)),) |
| 46 | LOCAL_DEX_PREOPT := nostripping |
| 47 | endif |
| 48 | endif |
| 49 | endif |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 50 | |
| 51 | built_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 52 | built_vdex := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 53 | built_art := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 54 | installed_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 55 | installed_vdex := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 56 | installed_art := |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 57 | built_installed_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 58 | built_installed_vdex := |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 59 | built_installed_art := |
| 60 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 61 | ifdef LOCAL_DEX_PREOPT |
| 62 | dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) |
| 63 | ifdef dexpreopt_boot_jar_module |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 64 | # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). |
| 65 | # We use this installed_odex trick to get boot.art installed. |
| 66 | installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 67 | # Append the odex for the 2nd arch if we have one. |
| 68 | installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 69 | else # boot jar |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 70 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
Ying Wang | c7ca617 | 2015-03-09 17:17:51 -0700 | [diff] [blame] | 71 | # For a Java library, by default we build odex for both 1st arch and 2nd arch. |
| 72 | # But it can be overridden with "LOCAL_MULTILIB := first". |
| 73 | ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE))) |
| 74 | # For system server jars, we build for only "first". |
| 75 | my_module_multilib := first |
| 76 | else |
| 77 | my_module_multilib := $(LOCAL_MULTILIB) |
| 78 | endif |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 79 | # ################################################# |
| 80 | # Odex for the 1st arch |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 81 | my_2nd_arch_prefix := |
| 82 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 83 | # ################################################# |
| 84 | # Odex for the 2nd arch |
| 85 | ifdef TARGET_2ND_ARCH |
Ying Wang | 6263022 | 2016-04-20 11:53:39 -0700 | [diff] [blame] | 86 | ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
Ying Wang | c7ca617 | 2015-03-09 17:17:51 -0700 | [diff] [blame] | 87 | ifneq (first,$(my_module_multilib)) |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 88 | my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 89 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | c7ca617 | 2015-03-09 17:17:51 -0700 | [diff] [blame] | 90 | endif # my_module_multilib is not first. |
Ying Wang | 6263022 | 2016-04-20 11:53:39 -0700 | [diff] [blame] | 91 | endif # TARGET_TRANSLATE_2ND_ARCH not true |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 92 | endif # TARGET_2ND_ARCH |
| 93 | # ################################################# |
| 94 | else # must be APPS |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 95 | # The preferred arch |
| 96 | my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) |
| 97 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 98 | ifdef TARGET_2ND_ARCH |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 99 | ifeq ($(LOCAL_MULTILIB),both) |
| 100 | # The non-preferred arch |
| 101 | my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX)) |
| 102 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
| 103 | endif # LOCAL_MULTILIB is both |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 104 | endif # TARGET_2ND_ARCH |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 105 | endif # LOCAL_MODULE_CLASS |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 106 | endif # boot jar |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 107 | |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 108 | built_odex := $(strip $(built_odex)) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 109 | built_vdex := $(strip $(built_vdex)) |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 110 | built_art := $(strip $(built_art)) |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 111 | installed_odex := $(strip $(installed_odex)) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 112 | installed_vdex := $(strip $(installed_vdex)) |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 113 | installed_art := $(strip $(installed_art)) |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 114 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 115 | ifdef built_odex |
Mathieu Chartier | 2ac264f | 2017-03-03 11:17:36 -0800 | [diff] [blame] | 116 | |
| 117 | ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE |
| 118 | ifeq (true,$(WITH_DEX_PREOPT_GENERATE_PROFILE)) |
| 119 | LOCAL_DEX_PREOPT_GENERATE_PROFILE := true |
| 120 | endif |
| 121 | endif |
| 122 | |
| 123 | ifeq (true,$(LOCAL_DEX_PREOPT_GENERATE_PROFILE)) |
| 124 | ifndef LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING |
| 125 | $(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)) |
| 126 | endif |
| 127 | my_built_profile := $(dir $(LOCAL_BUILT_MODULE))/profile.prof |
| 128 | my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) |
| 129 | $(built_odex): $(my_built_profile) |
| 130 | $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile) |
Dan Willemsen | 3d072d5 | 2017-03-20 13:54:41 -0700 | [diff] [blame^] | 131 | $(my_built_profile): PRIVATE_BUILT_MODULE := $(LOCAL_BUILT_MODULE) |
Mathieu Chartier | 2ac264f | 2017-03-03 11:17:36 -0800 | [diff] [blame] | 132 | $(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location) |
| 133 | $(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING) |
| 134 | $(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING) |
| 135 | $(my_built_profile): $(PROFMAN) |
Dan Willemsen | 3d072d5 | 2017-03-20 13:54:41 -0700 | [diff] [blame^] | 136 | $(my_built_profile): $(LOCAL_BUILT_MODULE) |
Mathieu Chartier | 2ac264f | 2017-03-03 11:17:36 -0800 | [diff] [blame] | 137 | $(my_built_profile): |
| 138 | $(hide) mkdir -p $(dir $@) |
| 139 | ANDROID_LOG_TAGS="*:e" $(PROFMAN) \ |
| 140 | --create-profile-from=$(PRIVATE_SOURCE_CLASSES) \ |
Dan Willemsen | 3d072d5 | 2017-03-20 13:54:41 -0700 | [diff] [blame^] | 141 | --apk=$(PRIVATE_BUILT_MODULE) \ |
Mathieu Chartier | 2ac264f | 2017-03-03 11:17:36 -0800 | [diff] [blame] | 142 | --dex-location=$(PRIVATE_DEX_LOCATION) \ |
| 143 | --reference-profile-file=$@ |
| 144 | else |
| 145 | $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := |
| 146 | endif |
| 147 | |
Ying Wang | 20ebd2e | 2014-10-07 18:07:23 -0700 | [diff] [blame] | 148 | ifndef LOCAL_DEX_PREOPT_FLAGS |
| 149 | LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG) |
| 150 | ifndef LOCAL_DEX_PREOPT_FLAGS |
| 151 | LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS) |
| 152 | endif |
| 153 | endif |
| 154 | $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 155 | $(built_vdex): $(built_odex) |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 156 | $(built_art): $(built_odex) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 157 | endif |
| 158 | |
| 159 | # Add the installed_odex to the list of installed files for this module. |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 160 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 161 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_vdex) |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 162 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_art) |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 163 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 164 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_vdex) |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 165 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_art) |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 166 | |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 167 | # Record dex-preopt config. |
| 168 | DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT) |
| 169 | DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB) |
| 170 | DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) |
| 171 | DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE) |
| 172 | DEXPREOPT.$(LOCAL_MODULE).PROPRIETARY_MODULE := $(LOCAL_PROPRIETARY_MODULE) |
| 173 | DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH) |
| 174 | DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex) |
| 175 | DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE) |
| 176 | DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \ |
| 177 | $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE)) |
| 178 | |
| 179 | |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame] | 180 | # Make sure to install the .odex and .vdex when you run "make <module_name>" |
Mathieu Chartier | 192b91c | 2017-02-08 18:30:31 -0800 | [diff] [blame] | 181 | $(my_all_targets): $(installed_odex) $(installed_vdex) $(installed_art) |
Ying Wang | 5c7fed2 | 2014-01-22 16:50:21 -0800 | [diff] [blame] | 182 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 183 | endif # LOCAL_DEX_PREOPT |