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 6LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT)) 7ifneq (true,$(WITH_DEXPREOPT)) 8 LOCAL_DEX_PREOPT := 9else # WITH_DEXPREOPT=true 10 ifeq (,$(TARGET_BUILD_APPS)) # TARGET_BUILD_APPS empty 11 ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined 12 ifneq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Installed to system.img. 13 ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty 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 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. 24 endif # LOCAL_DEX_PREOPT undefined 25 endif # TARGET_BUILD_APPS empty 26endif # WITH_DEXPREOPT=true 27ifeq (false,$(LOCAL_DEX_PREOPT)) 28 LOCAL_DEX_PREOPT := 29endif 30ifdef LOCAL_UNINSTALLABLE_MODULE 31LOCAL_DEX_PREOPT := 32endif 33ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code 34LOCAL_DEX_PREOPT := 35endif 36# if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip 37ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_ONLY)) 38ifeq ($(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),) 39LOCAL_DEX_PREOPT := 40endif 41endif 42 43built_odex := 44installed_odex := 45built_installed_odex := 46ifdef LOCAL_DEX_PREOPT 47dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) 48ifdef dexpreopt_boot_jar_module 49# For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). 50# We use this installed_odex trick to get boot.art installed. 51installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 52# Append the odex for the 2nd arch if we have one. 53installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 54else # boot jar 55ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 56# For a Java library, by default we build odex for both 1st arch and 2nd arch. 57# But it can be overridden with "LOCAL_MULTILIB := first". 58ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE))) 59# For system server jars, we build for only "first". 60my_module_multilib := first 61else 62my_module_multilib := $(LOCAL_MULTILIB) 63endif 64# ################################################# 65# Odex for the 1st arch 66my_2nd_arch_prefix := 67include $(BUILD_SYSTEM)/setup_one_odex.mk 68# ################################################# 69# Odex for the 2nd arch 70ifdef TARGET_2ND_ARCH 71ifneq (first,$(my_module_multilib)) 72my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 73include $(BUILD_SYSTEM)/setup_one_odex.mk 74endif # my_module_multilib is not first. 75endif # TARGET_2ND_ARCH 76# ################################################# 77else # must be APPS 78# The preferred arch 79my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 80include $(BUILD_SYSTEM)/setup_one_odex.mk 81ifdef TARGET_2ND_ARCH 82ifeq ($(LOCAL_MULTILIB),both) 83# The non-preferred arch 84my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX)) 85include $(BUILD_SYSTEM)/setup_one_odex.mk 86endif # LOCAL_MULTILIB is both 87endif # TARGET_2ND_ARCH 88endif # LOCAL_MODULE_CLASS 89endif # boot jar 90 91ifdef built_odex 92ifndef LOCAL_DEX_PREOPT_FLAGS 93LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG) 94ifndef LOCAL_DEX_PREOPT_FLAGS 95LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS) 96endif 97endif 98 99# Compile apps with position-independent code if WITH_DEXPREOPT_PIC=true 100ifeq (true,$(WITH_DEXPREOPT_PIC)) 101 LOCAL_DEX_PREOPT_FLAGS += --compile-pic 102endif 103 104$(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS) 105 106# Use pattern rule - we may have multiple installed odex files. 107# Ugly syntax - See the definition get-odex-file-path. 108$(installed_odex) : $(dir $(LOCAL_INSTALLED_MODULE))%$(notdir $(word 1,$(installed_odex))) \ 109 : $(dir $(LOCAL_BUILT_MODULE))%$(notdir $(word 1,$(built_odex))) \ 110 | $(ACP) 111 @echo "Install: $@" 112 $(copy-file-to-target) 113endif 114 115# Add the installed_odex to the list of installed files for this module. 116ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex) 117ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex) 118 119# Make sure to install the .odex when you run "make <module_name>" 120$(my_register_name): $(installed_odex) 121 122endif # LOCAL_DEX_PREOPT 123