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 LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT) 15 else # LOCAL_APK_LIBRARIES not empty 16 LOCAL_DEX_PREOPT := nostripping 17 endif # LOCAL_APK_LIBRARIES not empty 18 endif # Installed to system.img. 19 endif # LOCAL_DEX_PREOPT undefined 20 endif # TARGET_BUILD_APPS empty 21endif # WITH_DEXPREOPT=true 22ifeq (false,$(LOCAL_DEX_PREOPT)) 23 LOCAL_DEX_PREOPT := 24endif 25ifdef LOCAL_UNINSTALLABLE_MODULE 26LOCAL_DEX_PREOPT := 27endif 28ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code 29LOCAL_DEX_PREOPT := 30endif 31# if module oat file requested in data, disable LOCAL_DEX_PREOPT, will default location to dalvik-cache 32ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA))) 33LOCAL_DEX_PREOPT := 34endif 35# if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip 36ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_ONLY)) 37ifeq ($(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),) 38LOCAL_DEX_PREOPT := 39endif 40endif 41 42built_odex := 43installed_odex := 44built_installed_odex := 45ifdef LOCAL_DEX_PREOPT 46dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) 47ifdef dexpreopt_boot_jar_module 48ifeq ($(DALVIK_VM_LIB),libdvm.so) 49built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex 50installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex 51built_installed_odex := $(built_odex):$(installed_odex) 52else # libdvm.so 53# For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). 54# We use this installed_odex trick to get boot.art installed. 55installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 56# Append the odex for the 2nd arch if we have one. 57installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 58endif # libdvm.so 59else # boot jar 60ifeq ($(DALVIK_VM_LIB),libdvm.so) 61built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex 62installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex 63built_installed_odex := $(built_odex):$(installed_odex) 64 65$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \ 66 $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) 67else # libart 68ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 69# For a Java library, we build odex for both 1st arch and 2nd arch, if we have one. 70# ################################################# 71# Odex for the 1st arch 72my_2nd_arch_prefix := 73include $(BUILD_SYSTEM)/setup_one_odex.mk 74# ################################################# 75# Odex for the 2nd arch 76ifdef TARGET_2ND_ARCH 77my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 78include $(BUILD_SYSTEM)/setup_one_odex.mk 79endif # TARGET_2ND_ARCH 80# ################################################# 81else # must be APPS 82# The preferred arch 83my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 84include $(BUILD_SYSTEM)/setup_one_odex.mk 85ifdef TARGET_2ND_ARCH 86ifeq ($(LOCAL_MULTILIB),both) 87# The non-preferred arch 88my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX)) 89include $(BUILD_SYSTEM)/setup_one_odex.mk 90endif # LOCAL_MULTILIB is both 91endif # TARGET_2ND_ARCH 92endif # LOCAL_MODULE_CLASS 93endif # libart 94endif # boot jar 95 96ifdef built_odex 97# Use pattern rule - we may have multiple installed odex files. 98# Ugly syntax - See the definition get-odex-file-path. 99$(installed_odex) : $(dir $(LOCAL_INSTALLED_MODULE))%$(notdir $(word 1,$(installed_odex))) \ 100 : $(dir $(LOCAL_BUILT_MODULE))%$(notdir $(word 1,$(built_odex))) \ 101 | $(ACP) 102 @echo "Install: $@" 103 $(copy-file-to-target) 104endif 105 106# Add the installed_odex to the list of installed files for this module. 107ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex) 108ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex) 109 110# Make sure to install the .odex when you run "make <module_name>" 111$(my_register_name): $(installed_odex) 112 113endif # LOCAL_DEX_PREOPT 114