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 |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 42 | |
| 43 | built_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 44 | built_vdex := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 45 | installed_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 46 | installed_vdex := |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 47 | built_installed_odex := |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 48 | built_installed_vdex := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 49 | ifdef LOCAL_DEX_PREOPT |
| 50 | dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) |
| 51 | ifdef dexpreopt_boot_jar_module |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 52 | # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). |
| 53 | # We use this installed_odex trick to get boot.art installed. |
| 54 | installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 55 | # Append the odex for the 2nd arch if we have one. |
| 56 | installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 57 | else # boot jar |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 58 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
Ying Wang | c7ca617 | 2015-03-09 17:17:51 -0700 | [diff] [blame] | 59 | # For a Java library, by default we build odex for both 1st arch and 2nd arch. |
| 60 | # But it can be overridden with "LOCAL_MULTILIB := first". |
| 61 | ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE))) |
| 62 | # For system server jars, we build for only "first". |
| 63 | my_module_multilib := first |
| 64 | else |
| 65 | my_module_multilib := $(LOCAL_MULTILIB) |
| 66 | endif |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 67 | # ################################################# |
| 68 | # Odex for the 1st arch |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 69 | my_2nd_arch_prefix := |
| 70 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 71 | # ################################################# |
| 72 | # Odex for the 2nd arch |
| 73 | ifdef TARGET_2ND_ARCH |
Ying Wang | 6263022 | 2016-04-20 11:53:39 -0700 | [diff] [blame] | 74 | ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
Ying Wang | c7ca617 | 2015-03-09 17:17:51 -0700 | [diff] [blame] | 75 | ifneq (first,$(my_module_multilib)) |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 76 | my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 77 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | c7ca617 | 2015-03-09 17:17:51 -0700 | [diff] [blame] | 78 | endif # my_module_multilib is not first. |
Ying Wang | 6263022 | 2016-04-20 11:53:39 -0700 | [diff] [blame] | 79 | endif # TARGET_TRANSLATE_2ND_ARCH not true |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 80 | endif # TARGET_2ND_ARCH |
| 81 | # ################################################# |
| 82 | else # must be APPS |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 83 | # The preferred arch |
| 84 | my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) |
| 85 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 86 | ifdef TARGET_2ND_ARCH |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 87 | ifeq ($(LOCAL_MULTILIB),both) |
| 88 | # The non-preferred arch |
| 89 | my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX)) |
| 90 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
| 91 | endif # LOCAL_MULTILIB is both |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 92 | endif # TARGET_2ND_ARCH |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 93 | endif # LOCAL_MODULE_CLASS |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 94 | endif # boot jar |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 95 | |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 96 | built_odex := $(strip $(built_odex)) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 97 | built_vdex := $(strip $(built_vdex)) |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 98 | installed_odex := $(strip $(installed_odex)) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 99 | installed_vdex := $(strip $(installed_vdex)) |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 100 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 101 | ifdef built_odex |
Ying Wang | 20ebd2e | 2014-10-07 18:07:23 -0700 | [diff] [blame] | 102 | ifndef LOCAL_DEX_PREOPT_FLAGS |
| 103 | LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG) |
| 104 | ifndef LOCAL_DEX_PREOPT_FLAGS |
| 105 | LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS) |
| 106 | endif |
| 107 | endif |
Igor Murashkin | 97f28c6 | 2014-10-30 16:08:07 -0700 | [diff] [blame] | 108 | |
Ying Wang | 20ebd2e | 2014-10-07 18:07:23 -0700 | [diff] [blame] | 109 | $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) |
| 110 | |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 111 | $(built_vdex): $(built_odex) |
| 112 | |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 113 | # Use pattern rule - we may have multiple installed odex files. |
| 114 | # Ugly syntax - See the definition get-odex-file-path. |
Ying Wang | 994c226 | 2014-05-28 13:34:59 -0700 | [diff] [blame] | 115 | $(installed_odex) : $(dir $(LOCAL_INSTALLED_MODULE))%$(notdir $(word 1,$(installed_odex))) \ |
Dan Willemsen | 7f01615 | 2016-02-29 17:52:39 -0800 | [diff] [blame] | 116 | : $(dir $(LOCAL_BUILT_MODULE))%$(notdir $(word 1,$(built_odex))) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 117 | @echo "Install: $@" |
| 118 | $(copy-file-to-target) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 119 | $(installed_vdex) : $(dir $(LOCAL_INSTALLED_MODULE))%$(notdir $(word 1,$(installed_vdex))) \ |
| 120 | : $(dir $(LOCAL_BUILT_MODULE))%$(notdir $(word 1,$(built_vdex))) |
| 121 | @echo "Install: $@" |
| 122 | $(copy-file-to-target) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 123 | endif |
| 124 | |
| 125 | # 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] | 126 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 127 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_vdex) |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 128 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex) |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 129 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_vdex) |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 130 | |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 131 | # Record dex-preopt config. |
| 132 | DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT) |
| 133 | DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB) |
| 134 | DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) |
| 135 | DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE) |
| 136 | DEXPREOPT.$(LOCAL_MODULE).PROPRIETARY_MODULE := $(LOCAL_PROPRIETARY_MODULE) |
| 137 | DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH) |
| 138 | DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex) |
| 139 | DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE) |
| 140 | DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \ |
| 141 | $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE)) |
| 142 | |
| 143 | |
David Brazdil | 7047016 | 2016-08-25 13:50:15 +0100 | [diff] [blame^] | 144 | # Make sure to install the .odex and .vdex when you run "make <module_name>" |
| 145 | $(my_register_name): $(installed_odex) $(installed_vdex) |
Ying Wang | 5c7fed2 | 2014-01-22 16:50:21 -0800 | [diff] [blame] | 146 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 147 | endif # LOCAL_DEX_PREOPT |