OSDN Git Service

[DO NOT MERGE] Updating Security String to 2017-03-01 on lmp-dev am: 28dae4b62b ...
[android-x86/build.git] / core / dex_preopt_odex_install.mk
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
43 built_odex :=
44 installed_odex :=
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)
54 else  # boot jar
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
61 else
62 my_module_multilib := $(LOCAL_MULTILIB)
63 endif
64 # #################################################
65 # Odex for the 1st arch
66 my_2nd_arch_prefix :=
67 include $(BUILD_SYSTEM)/setup_one_odex.mk
68 # #################################################
69 # Odex for the 2nd arch
70 ifdef TARGET_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 # #################################################
77 else  # must be APPS
78 # The preferred arch
79 my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
80 include $(BUILD_SYSTEM)/setup_one_odex.mk
81 ifdef TARGET_2ND_ARCH
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
89 endif  # boot jar
90
91 ifdef built_odex
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)
96 endif
97 endif
98
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
102 endif
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)
113 endif
114
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)
118
119 # Make sure to install the .odex when you run "make <module_name>"
120 $(my_register_name): $(installed_odex)
121
122 endif # LOCAL_DEX_PREOPT