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
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))
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
18 LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
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))
30 ifdef LOCAL_UNINSTALLABLE_MODULE
33 ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code
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)),)
45 built_installed_odex :=
46 ifdef LOCAL_DEX_PREOPT
47 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
48 ifdef 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.
51 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
52 # Append the odex for the 2nd arch if we have one.
53 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
55 ifeq ($(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".
58 ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
59 # For system server jars, we build for only "first".
60 my_module_multilib := first
62 my_module_multilib := $(LOCAL_MULTILIB)
64 # #################################################
65 # Odex for the 1st arch
67 include $(BUILD_SYSTEM)/setup_one_odex.mk
68 # #################################################
69 # Odex for the 2nd arch
71 ifneq (first,$(my_module_multilib))
72 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
73 include $(BUILD_SYSTEM)/setup_one_odex.mk
74 endif # my_module_multilib is not first.
75 endif # TARGET_2ND_ARCH
76 # #################################################
79 my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
80 include $(BUILD_SYSTEM)/setup_one_odex.mk
82 ifeq ($(LOCAL_MULTILIB),both)
83 # The non-preferred arch
84 my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
85 include $(BUILD_SYSTEM)/setup_one_odex.mk
86 endif # LOCAL_MULTILIB is both
87 endif # TARGET_2ND_ARCH
88 endif # LOCAL_MODULE_CLASS
92 ifndef LOCAL_DEX_PREOPT_FLAGS
93 LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
94 ifndef LOCAL_DEX_PREOPT_FLAGS
95 LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)
99 # Compile apps with position-independent code if WITH_DEXPREOPT_PIC=true
100 ifeq (true,$(WITH_DEXPREOPT_PIC))
101 LOCAL_DEX_PREOPT_FLAGS += --compile-pic
104 $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
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))) \
112 $(copy-file-to-target)
115 # Add the installed_odex to the list of installed files for this module.
116 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
117 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
119 # Make sure to install the .odex when you run "make <module_name>"
120 $(my_register_name): $(installed_odex)
122 endif # LOCAL_DEX_PREOPT