Home | History | Annotate | Download | only in core
      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
     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
     21 endif # WITH_DEXPREOPT=true
     22 ifeq (false,$(LOCAL_DEX_PREOPT))
     23   LOCAL_DEX_PREOPT :=
     24 endif
     25 ifdef LOCAL_UNINSTALLABLE_MODULE
     26 LOCAL_DEX_PREOPT :=
     27 endif
     28 ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code
     29 LOCAL_DEX_PREOPT :=
     30 endif
     31 # if module oat file requested in data, disable LOCAL_DEX_PREOPT, will default location to dalvik-cache
     32 ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA)))
     33 LOCAL_DEX_PREOPT :=
     34 endif
     35 # if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip
     36 ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_ONLY))
     37 ifeq ($(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
     38 LOCAL_DEX_PREOPT :=
     39 endif
     40 endif
     41 
     42 built_odex :=
     43 installed_odex :=
     44 built_installed_odex :=
     45 ifdef LOCAL_DEX_PREOPT
     46 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
     47 ifdef dexpreopt_boot_jar_module
     48 ifeq ($(DALVIK_VM_LIB),libdvm.so)
     49 built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
     50 installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
     51 built_installed_odex := $(built_odex):$(installed_odex)
     52 else # 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.
     55 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
     56 # Append the odex for the 2nd arch if we have one.
     57 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
     58 endif # libdvm.so
     59 else  # boot jar
     60 ifeq ($(DALVIK_VM_LIB),libdvm.so)
     61 built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
     62 installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
     63 built_installed_odex := $(built_odex):$(installed_odex)
     64 
     65 $(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
     66                 $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
     67 else # libart
     68 ifeq ($(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
     72 my_2nd_arch_prefix :=
     73 include $(BUILD_SYSTEM)/setup_one_odex.mk
     74 # #################################################
     75 # Odex for the 2nd arch
     76 ifdef TARGET_2ND_ARCH
     77 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
     78 include $(BUILD_SYSTEM)/setup_one_odex.mk
     79 endif  # TARGET_2ND_ARCH
     80 # #################################################
     81 else  # must be APPS
     82 # The preferred arch
     83 my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
     84 include $(BUILD_SYSTEM)/setup_one_odex.mk
     85 ifdef TARGET_2ND_ARCH
     86 ifeq ($(LOCAL_MULTILIB),both)
     87 # The non-preferred arch
     88 my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
     89 include $(BUILD_SYSTEM)/setup_one_odex.mk
     90 endif  # LOCAL_MULTILIB is both
     91 endif  # TARGET_2ND_ARCH
     92 endif  # LOCAL_MODULE_CLASS
     93 endif  # libart
     94 endif  # boot jar
     95 
     96 ifdef 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)
    104 endif
    105 
    106 # Add the installed_odex to the list of installed files for this module.
    107 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
    108 ALL_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 
    113 endif # LOCAL_DEX_PREOPT
    114