blob: 701414a774e4451fed713712f7fb9777e6b274fd [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))
Dan Willemsen5709bd52016-02-01 21:40:17 -080029 LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) :=
Ying Wangc0adfb72014-02-27 14:10:53 -080030 else
Ying Wang34d5f1b2014-05-16 10:38:43 -070031 ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix)
32 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
Dan Willemsen3bb168f2016-01-19 20:07:08 -080033 LOCAL_SRC_FILES_$(my_32_64_bit_suffix) :=
Ying Wang34d5f1b2014-05-16 10:38:43 -070034 else
35 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
Dan Willemsen3bb168f2016-01-19 20:07:08 -080036 LOCAL_SRC_FILES :=
Ying Wang34d5f1b2014-05-16 10:38:43 -070037 endif
Ying Wangc0adfb72014-02-27 14:10:53 -080038 endif
Colin Crosse18cb932014-02-13 15:04:18 -080039endif
40
Ying Wang6efe88b2016-03-01 20:14:52 -080041my_strip_module := $(firstword \
42 $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
43 $(LOCAL_STRIP_MODULE))
44my_pack_module_relocations := $(firstword \
45 $(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
46 $(LOCAL_PACK_MODULE_RELOCATIONS))
47
Colin Crosse18cb932014-02-13 15:04:18 -080048ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
Dan Albert4ac42312016-07-20 11:02:18 -070049 # LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES indicates that this prebuilt should be
50 # installed to the common directory of libraries. This is needed for the NDK
51 # shared libraries built by soong, as we build many different versions of each
52 # library (one for each API level). Since they all have the same basename,
53 # they'd clobber each other (as well as any platform libraries by the same
54 # name).
55 ifneq ($(LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES),false)
56 # Put the built targets of all shared libraries in a common directory
57 # to simplify the link line.
58 OVERRIDE_BUILT_MODULE_PATH := \
59 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
60 endif
Ying Wang6efe88b2016-03-01 20:14:52 -080061 ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),)
Ying Wangbfb52a22014-08-20 17:12:32 -070062 # Strip but not try to add debuglink
Ying Wang6efe88b2016-03-01 20:14:52 -080063 my_strip_module := no_debuglink
Ying Wangbfb52a22014-08-20 17:12:32 -070064 endif
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070065
Ying Wang6efe88b2016-03-01 20:14:52 -080066 ifeq ($(LOCAL_IS_HOST_MODULE)$(my_pack_module_relocations),)
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070067 # Do not pack relocations by default
Ying Wang6efe88b2016-03-01 20:14:52 -080068 my_pack_module_relocations := false
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070069 endif
Dan Albert52831d12015-11-12 15:27:49 -080070
71 ifeq ($(DISABLE_RELOCATION_PACKER),true)
Ying Wang6efe88b2016-03-01 20:14:52 -080072 my_pack_module_relocations := false
Dan Albert52831d12015-11-12 15:27:49 -080073 endif
Colin Crosse18cb932014-02-13 15:04:18 -080074endif
75
76ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
77 prebuilt_module_is_a_library := true
78else
79 prebuilt_module_is_a_library :=
80endif
81
82# Don't install static libraries by default.
83ifndef LOCAL_UNINSTALLABLE_MODULE
84ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
85 LOCAL_UNINSTALLABLE_MODULE := true
86endif
87endif
88
Ying Wangfbc5b9f2016-03-11 10:32:01 -080089ifeq (JAVA_LIBRARIES,$(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE)))
90 prebuilt_module_is_dex_javalib := true
91else
92 prebuilt_module_is_dex_javalib :=
93endif
94
Ying Wangaf9757e2014-07-17 21:24:42 -070095ifeq ($(LOCAL_MODULE_CLASS),APPS)
96LOCAL_BUILT_MODULE_STEM := package.apk
97LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
98endif
99
Dan Willemsen4598fbc2016-07-13 16:08:36 -0700100ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module) $(my_pack_module_relocations)),)
Colin Crosse18cb932014-02-13 15:04:18 -0800101 ifdef LOCAL_IS_HOST_MODULE
Dmitriy Ivanov64762c32015-04-24 15:33:14 -0700102 $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH))
Colin Crosse18cb932014-02-13 15:04:18 -0800103 endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -0800104 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Dmitriy Ivanov64762c32015-04-24 15:33:14 -0700105 $(error Can strip/pack only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
Colin Crosse18cb932014-02-13 15:04:18 -0800106 endif
107 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Dmitriy Ivanov64762c32015-04-24 15:33:14 -0700108 $(error Cannot strip/pack scripts LOCAL_PATH=$(LOCAL_PATH))
Colin Crosse18cb932014-02-13 15:04:18 -0800109 endif
Ying Wang6efe88b2016-03-01 20:14:52 -0800110 # Set the arch-specific variables to set up the strip/pack rules.
111 LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module)
112 LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_pack_module_relocations)
Colin Crosse18cb932014-02-13 15:04:18 -0800113 include $(BUILD_SYSTEM)/dynamic_binary.mk
114 built_module := $(linked_module)
Ying Wangbfb52a22014-08-20 17:12:32 -0700115
Ying Wang6efe88b2016-03-01 20:14:52 -0800116else # my_strip_module and my_pack_module_relocations not true
Colin Crosse18cb932014-02-13 15:04:18 -0800117 include $(BUILD_SYSTEM)/base_rules.mk
118 built_module := $(LOCAL_BUILT_MODULE)
119
120ifdef prebuilt_module_is_a_library
121export_includes := $(intermediates)/export_includes
122$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800123$(export_includes) :
Colin Crosse18cb932014-02-13 15:04:18 -0800124 @echo Export includes file: $< -- $@
125 $(hide) mkdir -p $(dir $@) && rm -f $@
126ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
127 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
128 echo "-I $$d" >> $@; \
129 done
130else
131 $(hide) touch $@
132endif
133
Dan Willemsenb097fbe2016-06-07 14:25:14 -0700134my_link_type := $(intermediates)/link_type
135$(my_link_type): PRIVATE_LINK_TYPE := $(if $(LOCAL_SDK_VERSION),ndk,platform)
136$(my_link_type):
137 @echo Check module type: $@
138 $(hide) mkdir -p $(dir $@) && rm -f $@
139 $(hide) echo $(PRIVATE_LINK_TYPE) >$@
140
141$(LOCAL_BUILT_MODULE) : | $(export_includes) $(my_link_type)
Colin Crosse18cb932014-02-13 15:04:18 -0800142endif # prebuilt_module_is_a_library
143
144# The real dependency will be added after all Android.mks are loaded and the install paths
145# of the shared libraries are determined.
146ifdef LOCAL_INSTALLED_MODULE
147ifdef LOCAL_SHARED_LIBRARIES
Ying Wang7c877392014-10-07 13:03:29 -0700148my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
149# Extra shared libraries introduced by LOCAL_CXX_STL.
150include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wang58f462f2014-02-25 18:26:29 -0800151$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wang7c877392014-10-07 13:03:29 -0700152 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
Colin Crosse18cb932014-02-13 15:04:18 -0800153
154# We also need the LOCAL_BUILT_MODULE dependency,
155# since we use -rpath-link which points to the built module's path.
Ying Wang7c877392014-10-07 13:03:29 -0700156my_built_shared_libraries := \
Ying Wang58f462f2014-02-25 18:26:29 -0800157 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Colin Crosse18cb932014-02-13 15:04:18 -0800158 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
Ying Wang7c877392014-10-07 13:03:29 -0700159 $(my_shared_libraries)))
160$(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries)
Colin Crosse18cb932014-02-13 15:04:18 -0800161endif
162endif
163
Ying Wang7c877392014-10-07 13:03:29 -0700164# We need to enclose the above export_includes and my_built_shared_libraries in
Ying Wang6efe88b2016-03-01 20:14:52 -0800165# "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk.
166endif # my_strip_module not true
Colin Crosse18cb932014-02-13 15:04:18 -0800167
Ying Wangf0534c22014-04-15 11:12:21 -0700168ifeq ($(LOCAL_MODULE_CLASS),APPS)
Colin Crosse18cb932014-02-13 15:04:18 -0800169PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
170
Ying Wang43f7a322014-11-17 16:56:04 -0800171# Select dpi-specific source
172ifdef LOCAL_DPI_VARIANTS
Ying Wang60686582014-12-10 12:40:09 -0800173my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI)))
Ying Wang43f7a322014-11-17 16:56:04 -0800174ifdef my_dpi
175ifdef LOCAL_DPI_FILE_STEM
176my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM)
177else
178my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk
179endif
180my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem))
181endif # my_dpi
182endif # LOCAL_DPI_VARIANTS
183
Ying Wang96bcad42014-04-17 13:38:04 -0700184rs_compatibility_jni_libs :=
185include $(BUILD_SYSTEM)/install_jni_libs.mk
186
Colin Crosse18cb932014-02-13 15:04:18 -0800187ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
188 # The magic string "EXTERNAL" means this package will be signed with
189 # the default dev key throughout the build process, but we expect
190 # the final package to be signed with a different key.
191 #
192 # This can be used for packages where we don't have access to the
193 # keys, but want the package to be predexopt'ed.
194 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
195 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
196
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900197 $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Colin Crosse18cb932014-02-13 15:04:18 -0800198 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
199 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
200endif
201ifeq ($(LOCAL_CERTIFICATE),)
Ying Wangf0534c22014-04-15 11:12:21 -0700202 # It is now a build error to add a prebuilt .apk without
203 # specifying a key for it.
204 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
Colin Crosse18cb932014-02-13 15:04:18 -0800205else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
206 # The magic string "PRESIGNED" means this package is already checked
207 # signed with its release key.
208 #
209 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
210 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
211 # but the dexpreopt process will not try to re-sign the app.
212 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
213 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
214else
215 # If this is not an absolute certificate, assign it to a generic one.
216 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
217 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
218 endif
219
220 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
221 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
222 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
223
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900224 $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Colin Crosse18cb932014-02-13 15:04:18 -0800225 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
226 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
227endif
228
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700229# Disable dex-preopt of prebuilts to save space, if requested.
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800230ifndef LOCAL_DEX_PREOPT
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700231ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
Colin Crosse18cb932014-02-13 15:04:18 -0800232LOCAL_DEX_PREOPT := false
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700233endif
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800234endif
Colin Crosse18cb932014-02-13 15:04:18 -0800235
236#######################################
237# defines built_odex along with rule to install odex
238include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
239#######################################
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800240ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
241# There is a replacement for the prebuilt .apk we can install without any processing.
242$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED) | $(ACP)
243 $(transform-prebuilt-to-target)
Ying Wang1fb01522015-05-01 14:02:26 -0700244
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800245else # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
246# Sign and align non-presigned .apks.
Ying Wang1fb01522015-05-01 14:02:26 -0700247# The embedded prebuilt jni to uncompress.
Ying Wang226eb922015-06-01 19:19:57 -0700248ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
249# For PRESIGNED apks we must uncompress every .so file:
250# even if the .so file isn't for the current TARGET_ARCH,
251# we can't strip the file.
252embedded_prebuilt_jni_libs := 'lib/*.so'
253endif
Ying Wang1fb01522015-05-01 14:02:26 -0700254ifndef embedded_prebuilt_jni_libs
255# No LOCAL_PREBUILT_JNI_LIBS, uncompress all.
256embedded_prebuilt_jni_libs := 'lib/*.so'
257endif
258$(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
259
Dan Willemsen7f016152016-02-29 17:52:39 -0800260$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(SIGNAPK_JAR) $(AAPT)
Colin Crosse18cb932014-02-13 15:04:18 -0800261 $(transform-prebuilt-to-target)
Ying Wang226eb922015-06-01 19:19:57 -0700262 $(uncompress-shared-libs)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800263ifdef LOCAL_DEX_PREOPT
264ifneq ($(BUILD_PLATFORM_ZIP),)
265 @# Keep a copy of apk with classes.dex unstripped
266 $(hide) cp -f $@ $(dir $@)package.dex.apk
267endif # BUILD_PLATFORM_ZIP
268endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700269ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
270 @# Only strip out files if we can re-sign the package.
Colin Crosse18cb932014-02-13 15:04:18 -0800271ifdef LOCAL_DEX_PREOPT
Ying Wang36142f62014-05-21 16:13:33 -0700272ifneq (nostripping,$(LOCAL_DEX_PREOPT))
273 $(call dexpreopt-remove-classes.dex,$@)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800274endif # LOCAL_DEX_PREOPT != nostripping
275endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700276 $(sign-package)
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800277 # No need for align-package because sign-package takes care of alignment
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800278else # LOCAL_CERTIFICATE == PRESIGNED
Colin Crosse18cb932014-02-13 15:04:18 -0800279 $(align-package)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800280endif # LOCAL_CERTIFICATE
281endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
Colin Crosse18cb932014-02-13 15:04:18 -0800282
Ying Wang36142f62014-05-21 16:13:33 -0700283###############################
284## Rule to build the odex file
285ifdef LOCAL_DEX_PREOPT
286$(built_odex) : $(my_prebuilt_src_file)
287 $(call dexpreopt-one-file,$<,$@)
288endif
289
Ying Wang00fe5872014-07-23 14:35:40 -0700290###############################
291## Install split apks.
292ifdef LOCAL_PACKAGE_SPLITS
293# LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
294built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
295installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
296
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800297# Rules to sign the split apks.
Ying Wang00fe5872014-07-23 14:35:40 -0700298my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
299ifneq (1,$(words $(my_src_dir)))
300$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
301endif
302my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
303
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900304$(built_apk_splits) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Ying Wang00fe5872014-07-23 14:35:40 -0700305$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
306$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
Dan Willemsen7f016152016-02-29 17:52:39 -0800307$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(AAPT)
Ying Wang00fe5872014-07-23 14:35:40 -0700308 $(copy-file-to-new-target)
309 $(sign-package)
Ying Wang00fe5872014-07-23 14:35:40 -0700310
311# Rules to install the split apks.
Dan Willemsen7f016152016-02-29 17:52:39 -0800312$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk
Ying Wang00fe5872014-07-23 14:35:40 -0700313 @echo "Install: $@"
314 $(copy-file-to-new-target)
315
316# Register the additional built and installed files.
317ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
318ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
319 $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
320
321# Make sure to install the splits when you run "make <module_name>".
322$(my_register_name): $(installed_apk_splits)
323
324endif # LOCAL_PACKAGE_SPLITS
325
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800326else ifeq ($(prebuilt_module_is_dex_javalib),true) # LOCAL_MODULE_CLASS != APPS
327# This is a target shared library, i.e. a jar with classes.dex.
328#######################################
329# defines built_odex along with rule to install odex
330include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
331#######################################
332ifdef LOCAL_DEX_PREOPT
333ifneq ($(dexpreopt_boot_jar_module),) # boot jar
334# boot jar's rules are defined in dex_preopt.mk
335dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
336$(built_module) : $(dexpreopted_boot_jar) | $(ACP)
337 $(call copy-file-to-target)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800338
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800339# For libart boot jars, we don't have .odex files.
340else # ! boot jar
341$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
342# Use pattern rule - we may have multiple built odex files.
343$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(my_prebuilt_src_file)
344 @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
345 $(call dexpreopt-one-file,$<,$@)
346
347$(built_module) : $(my_prebuilt_src_file) | $(ACP)
348 $(call copy-file-to-target)
349ifneq (nostripping,$(LOCAL_DEX_PREOPT))
350 $(call dexpreopt-remove-classes.dex,$@)
351endif
352endif # boot jar
353else # ! LOCAL_DEX_PREOPT
354$(built_module) : $(my_prebuilt_src_file) | $(ACP)
355 $(call copy-file-to-target)
356endif # LOCAL_DEX_PREOPT
357
358else # ! prebuilt_module_is_dex_javalib
Colin Crosse18cb932014-02-13 15:04:18 -0800359$(built_module) : $(my_prebuilt_src_file)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800360ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Colin Crosse18cb932014-02-13 15:04:18 -0800361 $(transform-prebuilt-to-target-strip-comments)
362else
Colin Crosse18cb932014-02-13 15:04:18 -0800363 $(transform-prebuilt-to-target)
Colin Crosse18cb932014-02-13 15:04:18 -0800364endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -0800365ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800366 $(hide) chmod +x $@
367endif
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800368endif # ! prebuilt_module_is_dex_javalib
Colin Crosse18cb932014-02-13 15:04:18 -0800369
Ying Wang86e74b92016-02-22 15:54:27 -0800370ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
371my_src_jar := $(my_prebuilt_src_file)
372ifeq ($(LOCAL_IS_HOST_MODULE),)
Colin Crosse18cb932014-02-13 15:04:18 -0800373# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
374# while the deps should be in the common dir, so we make a copy in the common dir.
Ying Wange9dd9f22014-10-29 15:48:32 -0700375common_classes_jar := $(intermediates.COMMON)/classes.jar
376common_javalib_jar := $(intermediates.COMMON)/javalib.jar
Colin Crosse18cb932014-02-13 15:04:18 -0800377
Ying Wange9dd9f22014-10-29 15:48:32 -0700378$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
379
Dan Willemsen62dfb592016-07-08 21:33:05 -0700380my_link_type := $(intermediates.COMMON)/link_type
381ifeq ($(LOCAL_SDK_VERSION),system_current)
382$(my_link_type): PRIVATE_LINK_TYPE := system
383else ifneq ($(LOCAL_SDK_VERSION),)
384$(my_link_type): PRIVATE_LINK_TYPE := sdk
385else
386$(my_link_type): PRIVATE_LINK_TYPE := platform
387endif
388$(my_link_type):
389 @echo Check module type: $@
390 $(hide) mkdir -p $(dir $@) && rm -f $@
391 $(hide) echo $(PRIVATE_LINK_TYPE) >$@
392$(LOCAL_BUILT_MODULE): $(my_link_type)
393
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800394ifeq ($(prebuilt_module_is_dex_javalib),true)
395# For prebuilt shared Java library we don't have classes.jar.
396$(common_javalib_jar) : $(my_src_jar) | $(ACP)
397 $(transform-prebuilt-to-target)
398
399else # ! prebuilt_module_is_dex_javalib
400
Ying Wange9dd9f22014-10-29 15:48:32 -0700401ifneq ($(filter %.aar, $(my_prebuilt_src_file)),)
402# This is .aar file, archive of classes.jar and Android resources.
403my_src_jar := $(intermediates.COMMON)/aar/classes.jar
404
405$(my_src_jar) : $(my_prebuilt_src_file)
406 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
407 $(hide) unzip -qo -d $(dir $@) $<
408 # Make sure the extracted classes.jar has a new timestamp.
409 $(hide) touch $@
410
Ying Wange9dd9f22014-10-29 15:48:32 -0700411endif
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800412
Dan Willemsen7f016152016-02-29 17:52:39 -0800413$(common_classes_jar) : $(my_src_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800414 $(transform-prebuilt-to-target)
415
Dan Willemsen7f016152016-02-29 17:52:39 -0800416$(common_javalib_jar) : $(common_classes_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800417 $(transform-prebuilt-to-target)
418
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900419$(call define-jar-to-toc-rule, $(common_classes_jar))
420
Colin Crosse18cb932014-02-13 15:04:18 -0800421# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
422$(built_module) : $(common_javalib_jar)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800423
424endif # ! prebuilt_module_is_dex_javalib
Ying Wang86e74b92016-02-22 15:54:27 -0800425endif # LOCAL_IS_HOST_MODULE is not set
Yohann Rousselccfa5c62016-01-19 16:08:34 +0100426
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800427ifneq ($(prebuilt_module_is_dex_javalib),true)
Yohann Rousselccfa5c62016-01-19 16:08:34 +0100428
Ying Wang86e74b92016-02-22 15:54:27 -0800429# We may be building classes.jack from a host jar for host dalvik Java library.
Yohann Rousselccfa5c62016-01-19 16:08:34 +0100430$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_FLAGS:=$(LOCAL_JACK_FLAGS)
Yohann Rousselc6383d62016-03-09 17:19:58 +0100431$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_MIN_SDK_VERSION := 1
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800432$(intermediates.COMMON)/classes.jack : $(my_src_jar) \
Shinichiro Hamaji4eaeef82016-04-07 18:56:42 +0900433 $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK_DEFAULT_ARGS) $(JACK) \
434 | setup-jack-server
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200435 $(transform-jar-to-jack)
436
Shinichiro Hamajif972a4a2015-12-09 18:06:20 +0900437# Update timestamps of .toc files for prebuilts so dependents will be
438# always rebuilt.
439$(intermediates.COMMON)/classes.dex.toc: $(intermediates.COMMON)/classes.jack
440 touch $@
441
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800442endif # ! prebuilt_module_is_dex_javalib
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200443endif # JAVA_LIBRARIES
444
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800445$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
Colin Crosse18cb932014-02-13 15:04:18 -0800446
447my_prebuilt_src_file :=