blob: 69f2986c2942a1d5b1a91ffc0281768ff63192aa [file] [log] [blame]
Colin Crosse18cb932014-02-13 15:04:18 -08001###########################################################
2## Standard rules for copying files that are prebuilt
3##
4## Additional inputs from base_rules.make:
5## None.
6##
7###########################################################
8
9ifneq ($(LOCAL_PREBUILT_LIBS),)
10$(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
11endif
12ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
13$(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
14endif
15ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
16$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
17endif
18
19# Not much sense to check build prebuilts
20LOCAL_DONT_CHECK_MODULE := true
21
Ying Wang34d5f1b2014-05-16 10:38:43 -070022my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
23
Colin Crosse18cb932014-02-13 15:04:18 -080024ifdef LOCAL_PREBUILT_MODULE_FILE
Ying Wangc0adfb72014-02-27 14:10:53 -080025 my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
Colin Crosse18cb932014-02-13 15:04:18 -080026else
Ying Wang6feb6d52014-04-17 10:03:35 -070027 ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
28 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Ying Wangc0adfb72014-02-27 14:10:53 -080029 else
Ying Wang34d5f1b2014-05-16 10:38:43 -070030 ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix)
31 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
32 else
33 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
34 endif
Ying Wangc0adfb72014-02-27 14:10:53 -080035 endif
Colin Crosse18cb932014-02-13 15:04:18 -080036endif
37
Colin Crosse18cb932014-02-13 15:04:18 -080038ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
39 # Put the built targets of all shared libraries in a common directory
40 # to simplify the link line.
41 OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
Ying Wangbfb52a22014-08-20 17:12:32 -070042 ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_STRIP_MODULE),)
43 # Strip but not try to add debuglink
44 LOCAL_STRIP_MODULE := no_debuglink
45 endif
Colin Crosse18cb932014-02-13 15:04:18 -080046endif
47
48ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
49 prebuilt_module_is_a_library := true
50else
51 prebuilt_module_is_a_library :=
52endif
53
54# Don't install static libraries by default.
55ifndef LOCAL_UNINSTALLABLE_MODULE
56ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
57 LOCAL_UNINSTALLABLE_MODULE := true
58endif
59endif
60
Ying Wangaf9757e2014-07-17 21:24:42 -070061ifeq ($(LOCAL_MODULE_CLASS),APPS)
62LOCAL_BUILT_MODULE_STEM := package.apk
63LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
64endif
65
Ying Wangbfb52a22014-08-20 17:12:32 -070066ifneq ($(filter true no_debuglink,$(LOCAL_STRIP_MODULE)),)
Colin Crosse18cb932014-02-13 15:04:18 -080067 ifdef LOCAL_IS_HOST_MODULE
68 $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
69 endif
70 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
71 $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
72 endif
73 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
74 $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
75 endif
76 include $(BUILD_SYSTEM)/dynamic_binary.mk
77 built_module := $(linked_module)
Ying Wangbfb52a22014-08-20 17:12:32 -070078
Colin Crosse18cb932014-02-13 15:04:18 -080079else # LOCAL_STRIP_MODULE not true
80 include $(BUILD_SYSTEM)/base_rules.mk
81 built_module := $(LOCAL_BUILT_MODULE)
82
83ifdef prebuilt_module_is_a_library
84export_includes := $(intermediates)/export_includes
85$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
86$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
87 @echo Export includes file: $< -- $@
88 $(hide) mkdir -p $(dir $@) && rm -f $@
89ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
90 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
91 echo "-I $$d" >> $@; \
92 done
93else
94 $(hide) touch $@
95endif
96
97$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
98endif # prebuilt_module_is_a_library
99
100# The real dependency will be added after all Android.mks are loaded and the install paths
101# of the shared libraries are determined.
102ifdef LOCAL_INSTALLED_MODULE
103ifdef LOCAL_SHARED_LIBRARIES
Ying Wang7c877392014-10-07 13:03:29 -0700104my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
105# Extra shared libraries introduced by LOCAL_CXX_STL.
106include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wang58f462f2014-02-25 18:26:29 -0800107$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wang7c877392014-10-07 13:03:29 -0700108 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
Colin Crosse18cb932014-02-13 15:04:18 -0800109
110# We also need the LOCAL_BUILT_MODULE dependency,
111# since we use -rpath-link which points to the built module's path.
Ying Wang7c877392014-10-07 13:03:29 -0700112my_built_shared_libraries := \
Ying Wang58f462f2014-02-25 18:26:29 -0800113 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Colin Crosse18cb932014-02-13 15:04:18 -0800114 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
Ying Wang7c877392014-10-07 13:03:29 -0700115 $(my_shared_libraries)))
116$(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries)
Colin Crosse18cb932014-02-13 15:04:18 -0800117endif
118endif
119
Ying Wang7c877392014-10-07 13:03:29 -0700120# We need to enclose the above export_includes and my_built_shared_libraries in
Ying Wangbfb52a22014-08-20 17:12:32 -0700121# "LOCAL_STRIP_MODULE not true" because otherwise the rules are defined in dynamic_binary.mk.
Colin Crosse18cb932014-02-13 15:04:18 -0800122endif # LOCAL_STRIP_MODULE not true
123
Ying Wangf0534c22014-04-15 11:12:21 -0700124ifeq ($(LOCAL_MODULE_CLASS),APPS)
Colin Crosse18cb932014-02-13 15:04:18 -0800125PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
126
Ying Wang96bcad42014-04-17 13:38:04 -0700127rs_compatibility_jni_libs :=
128include $(BUILD_SYSTEM)/install_jni_libs.mk
129
Colin Crosse18cb932014-02-13 15:04:18 -0800130ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
131 # The magic string "EXTERNAL" means this package will be signed with
132 # the default dev key throughout the build process, but we expect
133 # the final package to be signed with a different key.
134 #
135 # This can be used for packages where we don't have access to the
136 # keys, but want the package to be predexopt'ed.
137 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
138 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
139
140 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
141 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
142endif
143ifeq ($(LOCAL_CERTIFICATE),)
Ying Wangf0534c22014-04-15 11:12:21 -0700144 # It is now a build error to add a prebuilt .apk without
145 # specifying a key for it.
146 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
Colin Crosse18cb932014-02-13 15:04:18 -0800147else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
148 # The magic string "PRESIGNED" means this package is already checked
149 # signed with its release key.
150 #
151 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
152 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
153 # but the dexpreopt process will not try to re-sign the app.
154 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
155 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
156else
157 # If this is not an absolute certificate, assign it to a generic one.
158 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
159 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
160 endif
161
162 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
163 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
164 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
165
166 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
167 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
168endif
169
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700170# Disable dex-preopt of prebuilts to save space, if requested.
171ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
Colin Crosse18cb932014-02-13 15:04:18 -0800172LOCAL_DEX_PREOPT := false
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700173endif
Colin Crosse18cb932014-02-13 15:04:18 -0800174
175#######################################
176# defines built_odex along with rule to install odex
177include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
178#######################################
Colin Crosse18cb932014-02-13 15:04:18 -0800179# Sign and align non-presigned .apks.
180$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
181 $(transform-prebuilt-to-target)
Ying Wang8e20ef62014-06-24 20:01:52 -0700182ifdef extracted_jni_libs
Ying Wang74eb6602014-04-18 20:13:41 -0700183 $(hide) zip -d $@ 'lib/*.so' # strip embedded JNI libraries.
184endif
Colin Crosse18cb932014-02-13 15:04:18 -0800185ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
186 $(sign-package)
187endif
188ifdef LOCAL_DEX_PREOPT
Ying Wang36142f62014-05-21 16:13:33 -0700189ifneq (nostripping,$(LOCAL_DEX_PREOPT))
190 $(call dexpreopt-remove-classes.dex,$@)
191endif
Colin Crosse18cb932014-02-13 15:04:18 -0800192endif
193 $(align-package)
194
Ying Wang36142f62014-05-21 16:13:33 -0700195###############################
196## Rule to build the odex file
197ifdef LOCAL_DEX_PREOPT
198$(built_odex) : $(my_prebuilt_src_file)
199 $(call dexpreopt-one-file,$<,$@)
200endif
201
Ying Wang00fe5872014-07-23 14:35:40 -0700202###############################
203## Install split apks.
204ifdef LOCAL_PACKAGE_SPLITS
205# LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
206built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
207installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
208
209# Rules to sign and zipalign the split apks.
210my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
211ifneq (1,$(words $(my_src_dir)))
212$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
213endif
214my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
215
216$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
217$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
218$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP)
219 $(copy-file-to-new-target)
220 $(sign-package)
221 $(align-package)
222
223# Rules to install the split apks.
224$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP)
225 @echo "Install: $@"
226 $(copy-file-to-new-target)
227
228# Register the additional built and installed files.
229ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
230ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
231 $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
232
233# Make sure to install the splits when you run "make <module_name>".
234$(my_register_name): $(installed_apk_splits)
235
236endif # LOCAL_PACKAGE_SPLITS
237
Colin Crosse18cb932014-02-13 15:04:18 -0800238else # LOCAL_MODULE_CLASS != APPS
239ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
240$(built_module) : $(my_prebuilt_src_file)
241 $(transform-prebuilt-to-target-strip-comments)
242else
243$(built_module) : $(my_prebuilt_src_file) | $(ACP)
244 $(transform-prebuilt-to-target)
245ifneq ($(prebuilt_module_is_a_library),)
246 ifneq ($(LOCAL_IS_HOST_MODULE),)
247 $(transform-host-ranlib-copy-hack)
248 else
249 $(transform-ranlib-copy-hack)
250 endif
251endif
252endif
253endif # LOCAL_MODULE_CLASS != APPS
254
255ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
256# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
257# while the deps should be in the common dir, so we make a copy in the common dir.
258# For nonstatic library, $(common_javalib_jar) is the dependency file,
259# while $(common_classes_jar) is used to link.
260common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
261common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
262
263$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
264 $(transform-prebuilt-to-target)
265
266$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
267 $(transform-prebuilt-to-target)
268
269# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
270$(built_module) : $(common_javalib_jar)
271endif # TARGET JAVA_LIBRARIES
272
273$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
274
275my_prebuilt_src_file :=