blob: 284884cda6d14ea149df3a0fa4197c109e4a3b9c [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)
42endif
43
44ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
45 prebuilt_module_is_a_library := true
46else
47 prebuilt_module_is_a_library :=
48endif
49
50# Don't install static libraries by default.
51ifndef LOCAL_UNINSTALLABLE_MODULE
52ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
53 LOCAL_UNINSTALLABLE_MODULE := true
54endif
55endif
56
Ying Wangaf9757e2014-07-17 21:24:42 -070057ifeq ($(LOCAL_MODULE_CLASS),APPS)
58LOCAL_BUILT_MODULE_STEM := package.apk
59LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
60endif
61
Colin Crosse18cb932014-02-13 15:04:18 -080062ifeq ($(LOCAL_STRIP_MODULE),true)
63 ifdef LOCAL_IS_HOST_MODULE
64 $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
65 endif
66 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
67 $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
68 endif
69 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
70 $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
71 endif
72 include $(BUILD_SYSTEM)/dynamic_binary.mk
73 built_module := $(linked_module)
74else # LOCAL_STRIP_MODULE not true
75 include $(BUILD_SYSTEM)/base_rules.mk
76 built_module := $(LOCAL_BUILT_MODULE)
77
78ifdef prebuilt_module_is_a_library
79export_includes := $(intermediates)/export_includes
80$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
81$(export_includes) : $(LOCAL_MODULE_MAKEFILE)
82 @echo Export includes file: $< -- $@
83 $(hide) mkdir -p $(dir $@) && rm -f $@
84ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
85 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
86 echo "-I $$d" >> $@; \
87 done
88else
89 $(hide) touch $@
90endif
91
92$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
93endif # prebuilt_module_is_a_library
94
95# The real dependency will be added after all Android.mks are loaded and the install paths
96# of the shared libraries are determined.
97ifdef LOCAL_INSTALLED_MODULE
98ifdef LOCAL_SHARED_LIBRARIES
Ying Wang58f462f2014-02-25 18:26:29 -080099$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wange1b867d2014-06-10 14:21:20 -0700100 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
Colin Crosse18cb932014-02-13 15:04:18 -0800101
102# We also need the LOCAL_BUILT_MODULE dependency,
103# since we use -rpath-link which points to the built module's path.
104built_shared_libraries := \
Ying Wang58f462f2014-02-25 18:26:29 -0800105 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Colin Crosse18cb932014-02-13 15:04:18 -0800106 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
107 $(LOCAL_SHARED_LIBRARIES)))
108$(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
109endif
110endif
111
112endif # LOCAL_STRIP_MODULE not true
113
Ying Wangf0534c22014-04-15 11:12:21 -0700114ifeq ($(LOCAL_MODULE_CLASS),APPS)
Colin Crosse18cb932014-02-13 15:04:18 -0800115PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
116
Ying Wang96bcad42014-04-17 13:38:04 -0700117rs_compatibility_jni_libs :=
118include $(BUILD_SYSTEM)/install_jni_libs.mk
119
Colin Crosse18cb932014-02-13 15:04:18 -0800120ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
121 # The magic string "EXTERNAL" means this package will be signed with
122 # the default dev key throughout the build process, but we expect
123 # the final package to be signed with a different key.
124 #
125 # This can be used for packages where we don't have access to the
126 # keys, but want the package to be predexopt'ed.
127 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
128 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
129
130 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
131 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
132endif
133ifeq ($(LOCAL_CERTIFICATE),)
Ying Wangf0534c22014-04-15 11:12:21 -0700134 # It is now a build error to add a prebuilt .apk without
135 # specifying a key for it.
136 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
Colin Crosse18cb932014-02-13 15:04:18 -0800137else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
138 # The magic string "PRESIGNED" means this package is already checked
139 # signed with its release key.
140 #
141 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
142 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
143 # but the dexpreopt process will not try to re-sign the app.
144 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
145 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
146else
147 # If this is not an absolute certificate, assign it to a generic one.
148 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
149 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
150 endif
151
152 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
153 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
154 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
155
156 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
157 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
158endif
159
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700160# Disable dex-preopt of prebuilts to save space, if requested.
161ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
Colin Crosse18cb932014-02-13 15:04:18 -0800162LOCAL_DEX_PREOPT := false
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700163endif
Colin Crosse18cb932014-02-13 15:04:18 -0800164
165#######################################
166# defines built_odex along with rule to install odex
167include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
168#######################################
Colin Crosse18cb932014-02-13 15:04:18 -0800169# Sign and align non-presigned .apks.
170$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
171 $(transform-prebuilt-to-target)
Ying Wang8e20ef62014-06-24 20:01:52 -0700172ifdef extracted_jni_libs
Ying Wang74eb6602014-04-18 20:13:41 -0700173 $(hide) zip -d $@ 'lib/*.so' # strip embedded JNI libraries.
174endif
Colin Crosse18cb932014-02-13 15:04:18 -0800175ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
176 $(sign-package)
177endif
178ifdef LOCAL_DEX_PREOPT
Ying Wang36142f62014-05-21 16:13:33 -0700179ifneq (nostripping,$(LOCAL_DEX_PREOPT))
180 $(call dexpreopt-remove-classes.dex,$@)
181endif
Colin Crosse18cb932014-02-13 15:04:18 -0800182endif
183 $(align-package)
184
Ying Wang36142f62014-05-21 16:13:33 -0700185###############################
186## Rule to build the odex file
187ifdef LOCAL_DEX_PREOPT
188$(built_odex) : $(my_prebuilt_src_file)
189 $(call dexpreopt-one-file,$<,$@)
190endif
191
Ying Wang00fe5872014-07-23 14:35:40 -0700192###############################
193## Install split apks.
194ifdef LOCAL_PACKAGE_SPLITS
195# LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
196built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
197installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
198
199# Rules to sign and zipalign the split apks.
200my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
201ifneq (1,$(words $(my_src_dir)))
202$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
203endif
204my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
205
206$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
207$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
208$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP)
209 $(copy-file-to-new-target)
210 $(sign-package)
211 $(align-package)
212
213# Rules to install the split apks.
214$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP)
215 @echo "Install: $@"
216 $(copy-file-to-new-target)
217
218# Register the additional built and installed files.
219ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
220ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
221 $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
222
223# Make sure to install the splits when you run "make <module_name>".
224$(my_register_name): $(installed_apk_splits)
225
226endif # LOCAL_PACKAGE_SPLITS
227
Colin Crosse18cb932014-02-13 15:04:18 -0800228else # LOCAL_MODULE_CLASS != APPS
229ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
230$(built_module) : $(my_prebuilt_src_file)
231 $(transform-prebuilt-to-target-strip-comments)
232else
233$(built_module) : $(my_prebuilt_src_file) | $(ACP)
234 $(transform-prebuilt-to-target)
235ifneq ($(prebuilt_module_is_a_library),)
236 ifneq ($(LOCAL_IS_HOST_MODULE),)
237 $(transform-host-ranlib-copy-hack)
238 else
239 $(transform-ranlib-copy-hack)
240 endif
241endif
242endif
243endif # LOCAL_MODULE_CLASS != APPS
244
245ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
246# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
247# while the deps should be in the common dir, so we make a copy in the common dir.
248# For nonstatic library, $(common_javalib_jar) is the dependency file,
249# while $(common_classes_jar) is used to link.
250common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
251common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
252
253$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
254 $(transform-prebuilt-to-target)
255
256$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
257 $(transform-prebuilt-to-target)
258
259# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
260$(built_module) : $(common_javalib_jar)
261endif # TARGET JAVA_LIBRARIES
262
263$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
264
265my_prebuilt_src_file :=