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           # 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
     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
     33 ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code
     34 LOCAL_DEX_PREOPT :=
     35 endif
     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
     42 # if installing into system, and odex are being installed into system_other, don't strip
     43 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
     44 ifeq ($(LOCAL_DEX_PREOPT),true)
     45 ifneq ($(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(my_module_path)),)
     46 LOCAL_DEX_PREOPT := nostripping
     47 endif
     48 endif
     49 endif
     50 
     51 built_odex :=
     52 installed_odex :=
     53 built_installed_odex :=
     54 ifdef LOCAL_DEX_PREOPT
     55 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
     56 ifdef dexpreopt_boot_jar_module
     57 # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
     58 # We use this installed_odex trick to get boot.art installed.
     59 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
     60 # Append the odex for the 2nd arch if we have one.
     61 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
     62 else  # boot jar
     63 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
     64 # For a Java library, by default we build odex for both 1st arch and 2nd arch.
     65 # But it can be overridden with "LOCAL_MULTILIB := first".
     66 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
     67 # For system server jars, we build for only "first".
     68 my_module_multilib := first
     69 else
     70 my_module_multilib := $(LOCAL_MULTILIB)
     71 endif
     72 # #################################################
     73 # Odex for the 1st arch
     74 my_2nd_arch_prefix :=
     75 include $(BUILD_SYSTEM)/setup_one_odex.mk
     76 # #################################################
     77 # Odex for the 2nd arch
     78 ifdef TARGET_2ND_ARCH
     79 ifneq (first,$(my_module_multilib))
     80 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
     81 include $(BUILD_SYSTEM)/setup_one_odex.mk
     82 endif  # my_module_multilib is not first.
     83 endif  # TARGET_2ND_ARCH
     84 # #################################################
     85 else  # must be APPS
     86 # The preferred arch
     87 my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
     88 include $(BUILD_SYSTEM)/setup_one_odex.mk
     89 ifdef TARGET_2ND_ARCH
     90 ifeq ($(LOCAL_MULTILIB),both)
     91 # The non-preferred arch
     92 my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
     93 include $(BUILD_SYSTEM)/setup_one_odex.mk
     94 endif  # LOCAL_MULTILIB is both
     95 endif  # TARGET_2ND_ARCH
     96 endif  # LOCAL_MODULE_CLASS
     97 endif  # boot jar
     98 
     99 built_odex := $(strip $(built_odex))
    100 installed_odex := $(strip $(installed_odex))
    101 
    102 ifdef built_odex
    103 ifndef LOCAL_DEX_PREOPT_FLAGS
    104 LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
    105 ifndef LOCAL_DEX_PREOPT_FLAGS
    106 LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)
    107 endif
    108 endif
    109 
    110 $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
    111 endif
    112 
    113 # Add the installed_odex to the list of installed files for this module.
    114 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
    115 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
    116 
    117 # Record dex-preopt config.
    118 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
    119 DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
    120 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
    121 DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
    122 DEXPREOPT.$(LOCAL_MODULE).PROPRIETARY_MODULE := $(LOCAL_PROPRIETARY_MODULE)
    123 DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
    124 DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
    125 DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
    126 DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \
    127   $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
    128 
    129 
    130 # Make sure to install the .odex when you run "make <module_name>"
    131 $(my_register_name): $(installed_odex)
    132 
    133 endif # LOCAL_DEX_PREOPT
    134