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 |
| 36 | # if module oat file requested in data, disable LOCAL_DEX_PREOPT, will default location to dalvik-cache |
| 37 | ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA))) |
| 38 | LOCAL_DEX_PREOPT := |
| 39 | endif |
Alex Light | 7326f7b | 2014-08-04 17:09:41 -0700 | [diff] [blame] | 40 | # if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip |
| 41 | ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_ONLY)) |
| 42 | ifeq ($(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),) |
| 43 | LOCAL_DEX_PREOPT := |
| 44 | endif |
| 45 | endif |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 46 | |
| 47 | built_odex := |
| 48 | installed_odex := |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 49 | built_installed_odex := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 50 | ifdef LOCAL_DEX_PREOPT |
| 51 | dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) |
| 52 | ifdef dexpreopt_boot_jar_module |
| 53 | ifeq ($(DALVIK_VM_LIB),libdvm.so) |
| 54 | built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex |
| 55 | installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 56 | built_installed_odex := $(built_odex):$(installed_odex) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 57 | else # libdvm.so |
| 58 | # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). |
| 59 | # We use this installed_odex trick to get boot.art installed. |
| 60 | installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 61 | # Append the odex for the 2nd arch if we have one. |
| 62 | installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 63 | endif # libdvm.so |
| 64 | else # boot jar |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 65 | ifeq ($(DALVIK_VM_LIB),libdvm.so) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 66 | built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex |
| 67 | installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex |
Ying Wang | 74c9850 | 2014-05-19 13:03:36 -0700 | [diff] [blame] | 68 | built_installed_odex := $(built_odex):$(installed_odex) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 69 | |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 70 | $(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \ |
| 71 | $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) |
| 72 | else # libart |
| 73 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 74 | # For a Java library, we build odex for both 1st arch and 2nd arch, if we have one. |
| 75 | # ################################################# |
| 76 | # Odex for the 1st arch |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 77 | my_2nd_arch_prefix := |
| 78 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 79 | # ################################################# |
| 80 | # Odex for the 2nd arch |
| 81 | ifdef TARGET_2ND_ARCH |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 82 | my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) |
| 83 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 84 | endif # TARGET_2ND_ARCH |
| 85 | # ################################################# |
| 86 | else # must be APPS |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 87 | # The preferred arch |
| 88 | my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) |
| 89 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 90 | ifdef TARGET_2ND_ARCH |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 91 | ifeq ($(LOCAL_MULTILIB),both) |
| 92 | # The non-preferred arch |
| 93 | my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX)) |
| 94 | include $(BUILD_SYSTEM)/setup_one_odex.mk |
| 95 | endif # LOCAL_MULTILIB is both |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 96 | endif # TARGET_2ND_ARCH |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 97 | endif # LOCAL_MODULE_CLASS |
Ying Wang | 7a89919 | 2014-09-15 11:45:52 -0700 | [diff] [blame] | 98 | endif # libart |
| 99 | endif # boot jar |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 100 | |
| 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 | |
| 109 | # Compile apps with position-independent code if WITH_DEXPREOPT_PIC=true |
| 110 | ifeq (true,$(WITH_DEXPREOPT_PIC)) |
| 111 | LOCAL_DEX_PREOPT_FLAGS += --compile-pic |
| 112 | endif |
| 113 | |
Ying Wang | 20ebd2e | 2014-10-07 18:07:23 -0700 | [diff] [blame] | 114 | $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) |
| 115 | |
Ying Wang | b9aa5d4 | 2014-05-13 13:57:28 -0700 | [diff] [blame] | 116 | # Use pattern rule - we may have multiple installed odex files. |
| 117 | # Ugly syntax - See the definition get-odex-file-path. |
Ying Wang | 994c226 | 2014-05-28 13:34:59 -0700 | [diff] [blame] | 118 | $(installed_odex) : $(dir $(LOCAL_INSTALLED_MODULE))%$(notdir $(word 1,$(installed_odex))) \ |
| 119 | : $(dir $(LOCAL_BUILT_MODULE))%$(notdir $(word 1,$(built_odex))) \ |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 120 | | $(ACP) |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 121 | @echo "Install: $@" |
| 122 | $(copy-file-to-target) |
| 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) |
| 127 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex) |
| 128 | |
Ying Wang | 5c7fed2 | 2014-01-22 16:50:21 -0800 | [diff] [blame] | 129 | # Make sure to install the .odex when you run "make <module_name>" |
| 130 | $(my_register_name): $(installed_odex) |
| 131 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 132 | endif # LOCAL_DEX_PREOPT |