blob: 3f89d80a8b5ab4ae9e082f003ce9dc8e48884007 [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))
49 # Put the built targets of all shared libraries in a common directory
50 # to simplify the link line.
51 OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
Ying Wang6efe88b2016-03-01 20:14:52 -080052 ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),)
Ying Wangbfb52a22014-08-20 17:12:32 -070053 # Strip but not try to add debuglink
Ying Wang6efe88b2016-03-01 20:14:52 -080054 my_strip_module := no_debuglink
Ying Wangbfb52a22014-08-20 17:12:32 -070055 endif
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070056
Ying Wang6efe88b2016-03-01 20:14:52 -080057 ifeq ($(LOCAL_IS_HOST_MODULE)$(my_pack_module_relocations),)
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070058 # Do not pack relocations by default
Ying Wang6efe88b2016-03-01 20:14:52 -080059 my_pack_module_relocations := false
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070060 endif
Dan Albert52831d12015-11-12 15:27:49 -080061
62 ifeq ($(DISABLE_RELOCATION_PACKER),true)
Ying Wang6efe88b2016-03-01 20:14:52 -080063 my_pack_module_relocations := false
Dan Albert52831d12015-11-12 15:27:49 -080064 endif
Colin Crosse18cb932014-02-13 15:04:18 -080065endif
66
67ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
68 prebuilt_module_is_a_library := true
69else
70 prebuilt_module_is_a_library :=
71endif
72
73# Don't install static libraries by default.
74ifndef LOCAL_UNINSTALLABLE_MODULE
75ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
76 LOCAL_UNINSTALLABLE_MODULE := true
77endif
78endif
79
Ying Wangfbc5b9f2016-03-11 10:32:01 -080080ifeq (JAVA_LIBRARIES,$(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE)))
81 prebuilt_module_is_dex_javalib := true
82else
83 prebuilt_module_is_dex_javalib :=
84endif
85
Ying Wangaf9757e2014-07-17 21:24:42 -070086ifeq ($(LOCAL_MODULE_CLASS),APPS)
87LOCAL_BUILT_MODULE_STEM := package.apk
88LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
89endif
90
Ying Wang6efe88b2016-03-01 20:14:52 -080091ifneq ($(filter true no_debuglink,$(my_strip_module) $(my_pack_module_relocations)),)
Colin Crosse18cb932014-02-13 15:04:18 -080092 ifdef LOCAL_IS_HOST_MODULE
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070093 $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH))
Colin Crosse18cb932014-02-13 15:04:18 -080094 endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -080095 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070096 $(error Can strip/pack only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
Colin Crosse18cb932014-02-13 15:04:18 -080097 endif
98 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Dmitriy Ivanov64762c32015-04-24 15:33:14 -070099 $(error Cannot strip/pack scripts LOCAL_PATH=$(LOCAL_PATH))
Colin Crosse18cb932014-02-13 15:04:18 -0800100 endif
Ying Wang6efe88b2016-03-01 20:14:52 -0800101 # Set the arch-specific variables to set up the strip/pack rules.
102 LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module)
103 LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_pack_module_relocations)
Colin Crosse18cb932014-02-13 15:04:18 -0800104 include $(BUILD_SYSTEM)/dynamic_binary.mk
105 built_module := $(linked_module)
Ying Wangbfb52a22014-08-20 17:12:32 -0700106
Ying Wang6efe88b2016-03-01 20:14:52 -0800107else # my_strip_module and my_pack_module_relocations not true
Colin Crosse18cb932014-02-13 15:04:18 -0800108 include $(BUILD_SYSTEM)/base_rules.mk
109 built_module := $(LOCAL_BUILT_MODULE)
110
111ifdef prebuilt_module_is_a_library
112export_includes := $(intermediates)/export_includes
113$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800114$(export_includes) :
Colin Crosse18cb932014-02-13 15:04:18 -0800115 @echo Export includes file: $< -- $@
116 $(hide) mkdir -p $(dir $@) && rm -f $@
117ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
118 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
119 echo "-I $$d" >> $@; \
120 done
121else
122 $(hide) touch $@
123endif
124
125$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
126endif # prebuilt_module_is_a_library
127
128# The real dependency will be added after all Android.mks are loaded and the install paths
129# of the shared libraries are determined.
130ifdef LOCAL_INSTALLED_MODULE
131ifdef LOCAL_SHARED_LIBRARIES
Ying Wang7c877392014-10-07 13:03:29 -0700132my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
133# Extra shared libraries introduced by LOCAL_CXX_STL.
134include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wang58f462f2014-02-25 18:26:29 -0800135$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wang7c877392014-10-07 13:03:29 -0700136 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
Colin Crosse18cb932014-02-13 15:04:18 -0800137
138# We also need the LOCAL_BUILT_MODULE dependency,
139# since we use -rpath-link which points to the built module's path.
Ying Wang7c877392014-10-07 13:03:29 -0700140my_built_shared_libraries := \
Ying Wang58f462f2014-02-25 18:26:29 -0800141 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
Colin Crosse18cb932014-02-13 15:04:18 -0800142 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
Ying Wang7c877392014-10-07 13:03:29 -0700143 $(my_shared_libraries)))
144$(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries)
Colin Crosse18cb932014-02-13 15:04:18 -0800145endif
146endif
147
Ying Wang7c877392014-10-07 13:03:29 -0700148# We need to enclose the above export_includes and my_built_shared_libraries in
Ying Wang6efe88b2016-03-01 20:14:52 -0800149# "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk.
150endif # my_strip_module not true
Colin Crosse18cb932014-02-13 15:04:18 -0800151
Ying Wangf0534c22014-04-15 11:12:21 -0700152ifeq ($(LOCAL_MODULE_CLASS),APPS)
Colin Crosse18cb932014-02-13 15:04:18 -0800153PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
154
Ying Wang43f7a322014-11-17 16:56:04 -0800155# Select dpi-specific source
156ifdef LOCAL_DPI_VARIANTS
Ying Wang60686582014-12-10 12:40:09 -0800157my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI)))
Ying Wang43f7a322014-11-17 16:56:04 -0800158ifdef my_dpi
159ifdef LOCAL_DPI_FILE_STEM
160my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM)
161else
162my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk
163endif
164my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem))
165endif # my_dpi
166endif # LOCAL_DPI_VARIANTS
167
Ying Wang96bcad42014-04-17 13:38:04 -0700168rs_compatibility_jni_libs :=
169include $(BUILD_SYSTEM)/install_jni_libs.mk
170
Colin Crosse18cb932014-02-13 15:04:18 -0800171ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
172 # The magic string "EXTERNAL" means this package will be signed with
173 # the default dev key throughout the build process, but we expect
174 # the final package to be signed with a different key.
175 #
176 # This can be used for packages where we don't have access to the
177 # keys, but want the package to be predexopt'ed.
178 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
179 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
180
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900181 $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Colin Crosse18cb932014-02-13 15:04:18 -0800182 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
183 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
184endif
185ifeq ($(LOCAL_CERTIFICATE),)
Ying Wangf0534c22014-04-15 11:12:21 -0700186 # It is now a build error to add a prebuilt .apk without
187 # specifying a key for it.
188 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
Colin Crosse18cb932014-02-13 15:04:18 -0800189else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
190 # The magic string "PRESIGNED" means this package is already checked
191 # signed with its release key.
192 #
193 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
194 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
195 # but the dexpreopt process will not try to re-sign the app.
196 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
197 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
198else
199 # If this is not an absolute certificate, assign it to a generic one.
200 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
201 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
202 endif
203
204 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
205 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
206 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
207
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900208 $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Colin Crosse18cb932014-02-13 15:04:18 -0800209 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
210 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
211endif
212
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700213# Disable dex-preopt of prebuilts to save space, if requested.
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800214ifndef LOCAL_DEX_PREOPT
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700215ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
Colin Crosse18cb932014-02-13 15:04:18 -0800216LOCAL_DEX_PREOPT := false
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700217endif
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800218endif
Colin Crosse18cb932014-02-13 15:04:18 -0800219
220#######################################
221# defines built_odex along with rule to install odex
222include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
223#######################################
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800224ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
225# There is a replacement for the prebuilt .apk we can install without any processing.
226$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED) | $(ACP)
227 $(transform-prebuilt-to-target)
Ying Wang1fb01522015-05-01 14:02:26 -0700228
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800229else # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
230# Sign and align non-presigned .apks.
Ying Wang1fb01522015-05-01 14:02:26 -0700231# The embedded prebuilt jni to uncompress.
Ying Wang226eb922015-06-01 19:19:57 -0700232ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
233# For PRESIGNED apks we must uncompress every .so file:
234# even if the .so file isn't for the current TARGET_ARCH,
235# we can't strip the file.
236embedded_prebuilt_jni_libs := 'lib/*.so'
237endif
Ying Wang1fb01522015-05-01 14:02:26 -0700238ifndef embedded_prebuilt_jni_libs
239# No LOCAL_PREBUILT_JNI_LIBS, uncompress all.
240embedded_prebuilt_jni_libs := 'lib/*.so'
241endif
242$(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
243
Dan Willemsen7f016152016-02-29 17:52:39 -0800244$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(SIGNAPK_JAR) $(AAPT)
Colin Crosse18cb932014-02-13 15:04:18 -0800245 $(transform-prebuilt-to-target)
Ying Wang226eb922015-06-01 19:19:57 -0700246 $(uncompress-shared-libs)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800247ifdef LOCAL_DEX_PREOPT
248ifneq ($(BUILD_PLATFORM_ZIP),)
249 @# Keep a copy of apk with classes.dex unstripped
250 $(hide) cp -f $@ $(dir $@)package.dex.apk
251endif # BUILD_PLATFORM_ZIP
252endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700253ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
254 @# Only strip out files if we can re-sign the package.
Colin Crosse18cb932014-02-13 15:04:18 -0800255ifdef LOCAL_DEX_PREOPT
Ying Wang36142f62014-05-21 16:13:33 -0700256ifneq (nostripping,$(LOCAL_DEX_PREOPT))
257 $(call dexpreopt-remove-classes.dex,$@)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800258endif # LOCAL_DEX_PREOPT != nostripping
259endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700260 $(sign-package)
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800261 # No need for align-package because sign-package takes care of alignment
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800262else # LOCAL_CERTIFICATE == PRESIGNED
Colin Crosse18cb932014-02-13 15:04:18 -0800263 $(align-package)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800264endif # LOCAL_CERTIFICATE
265endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
Colin Crosse18cb932014-02-13 15:04:18 -0800266
Ying Wang36142f62014-05-21 16:13:33 -0700267###############################
268## Rule to build the odex file
269ifdef LOCAL_DEX_PREOPT
270$(built_odex) : $(my_prebuilt_src_file)
271 $(call dexpreopt-one-file,$<,$@)
272endif
273
Ying Wang00fe5872014-07-23 14:35:40 -0700274###############################
275## Install split apks.
276ifdef LOCAL_PACKAGE_SPLITS
277# LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
278built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
279installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
280
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800281# Rules to sign the split apks.
Ying Wang00fe5872014-07-23 14:35:40 -0700282my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
283ifneq (1,$(words $(my_src_dir)))
284$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
285endif
286my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
287
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900288$(built_apk_splits) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Ying Wang00fe5872014-07-23 14:35:40 -0700289$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
290$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
Dan Willemsen7f016152016-02-29 17:52:39 -0800291$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(AAPT)
Ying Wang00fe5872014-07-23 14:35:40 -0700292 $(copy-file-to-new-target)
293 $(sign-package)
Ying Wang00fe5872014-07-23 14:35:40 -0700294
295# Rules to install the split apks.
Dan Willemsen7f016152016-02-29 17:52:39 -0800296$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk
Ying Wang00fe5872014-07-23 14:35:40 -0700297 @echo "Install: $@"
298 $(copy-file-to-new-target)
299
300# Register the additional built and installed files.
301ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
302ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
303 $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
304
305# Make sure to install the splits when you run "make <module_name>".
306$(my_register_name): $(installed_apk_splits)
307
308endif # LOCAL_PACKAGE_SPLITS
309
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800310else ifeq ($(prebuilt_module_is_dex_javalib),true) # LOCAL_MODULE_CLASS != APPS
311# This is a target shared library, i.e. a jar with classes.dex.
312#######################################
313# defines built_odex along with rule to install odex
314include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
315#######################################
316ifdef LOCAL_DEX_PREOPT
317ifneq ($(dexpreopt_boot_jar_module),) # boot jar
318# boot jar's rules are defined in dex_preopt.mk
319dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
320$(built_module) : $(dexpreopted_boot_jar) | $(ACP)
321 $(call copy-file-to-target)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800322
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800323# For libart boot jars, we don't have .odex files.
324else # ! boot jar
325$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
326# Use pattern rule - we may have multiple built odex files.
327$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(my_prebuilt_src_file)
328 @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
329 $(call dexpreopt-one-file,$<,$@)
330
331$(built_module) : $(my_prebuilt_src_file) | $(ACP)
332 $(call copy-file-to-target)
333ifneq (nostripping,$(LOCAL_DEX_PREOPT))
334 $(call dexpreopt-remove-classes.dex,$@)
335endif
336endif # boot jar
337else # ! LOCAL_DEX_PREOPT
338$(built_module) : $(my_prebuilt_src_file) | $(ACP)
339 $(call copy-file-to-target)
340endif # LOCAL_DEX_PREOPT
341
342else # ! prebuilt_module_is_dex_javalib
Colin Crosse18cb932014-02-13 15:04:18 -0800343$(built_module) : $(my_prebuilt_src_file)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800344ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Colin Crosse18cb932014-02-13 15:04:18 -0800345 $(transform-prebuilt-to-target-strip-comments)
346else
Colin Crosse18cb932014-02-13 15:04:18 -0800347 $(transform-prebuilt-to-target)
Colin Crosse18cb932014-02-13 15:04:18 -0800348endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -0800349ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800350 $(hide) chmod +x $@
351endif
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800352endif # ! prebuilt_module_is_dex_javalib
Colin Crosse18cb932014-02-13 15:04:18 -0800353
Ying Wang86e74b92016-02-22 15:54:27 -0800354ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
355my_src_jar := $(my_prebuilt_src_file)
356ifeq ($(LOCAL_IS_HOST_MODULE),)
Colin Crosse18cb932014-02-13 15:04:18 -0800357# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
358# 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 -0700359common_classes_jar := $(intermediates.COMMON)/classes.jar
360common_javalib_jar := $(intermediates.COMMON)/javalib.jar
Colin Crosse18cb932014-02-13 15:04:18 -0800361
Ying Wange9dd9f22014-10-29 15:48:32 -0700362$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
363
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800364ifeq ($(prebuilt_module_is_dex_javalib),true)
365# For prebuilt shared Java library we don't have classes.jar.
366$(common_javalib_jar) : $(my_src_jar) | $(ACP)
367 $(transform-prebuilt-to-target)
368
369else # ! prebuilt_module_is_dex_javalib
370
Ying Wange9dd9f22014-10-29 15:48:32 -0700371ifneq ($(filter %.aar, $(my_prebuilt_src_file)),)
372# This is .aar file, archive of classes.jar and Android resources.
373my_src_jar := $(intermediates.COMMON)/aar/classes.jar
374
375$(my_src_jar) : $(my_prebuilt_src_file)
376 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
377 $(hide) unzip -qo -d $(dir $@) $<
378 # Make sure the extracted classes.jar has a new timestamp.
379 $(hide) touch $@
380
Ying Wange9dd9f22014-10-29 15:48:32 -0700381endif
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800382
Dan Willemsen7f016152016-02-29 17:52:39 -0800383$(common_classes_jar) : $(my_src_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800384 $(transform-prebuilt-to-target)
385
Dan Willemsen7f016152016-02-29 17:52:39 -0800386$(common_javalib_jar) : $(common_classes_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800387 $(transform-prebuilt-to-target)
388
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900389$(call define-jar-to-toc-rule, $(common_classes_jar))
390
Colin Crosse18cb932014-02-13 15:04:18 -0800391# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
392$(built_module) : $(common_javalib_jar)
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800393
394endif # ! prebuilt_module_is_dex_javalib
Ying Wang86e74b92016-02-22 15:54:27 -0800395endif # LOCAL_IS_HOST_MODULE is not set
Yohann Rousselccfa5c62016-01-19 16:08:34 +0100396
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800397ifneq ($(prebuilt_module_is_dex_javalib),true)
Yohann Rousselccfa5c62016-01-19 16:08:34 +0100398
Ying Wang86e74b92016-02-22 15:54:27 -0800399# We may be building classes.jack from a host jar for host dalvik Java library.
Yohann Rousselccfa5c62016-01-19 16:08:34 +0100400$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_FLAGS:=$(LOCAL_JACK_FLAGS)
Yohann Rousselc6383d62016-03-09 17:19:58 +0100401$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_MIN_SDK_VERSION := 1
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800402$(intermediates.COMMON)/classes.jack : $(my_src_jar) \
Shinichiro Hamaji4eaeef82016-04-07 18:56:42 +0900403 $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK_DEFAULT_ARGS) $(JACK) \
404 | setup-jack-server
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200405 $(transform-jar-to-jack)
406
Shinichiro Hamajif972a4a2015-12-09 18:06:20 +0900407# Update timestamps of .toc files for prebuilts so dependents will be
408# always rebuilt.
409$(intermediates.COMMON)/classes.dex.toc: $(intermediates.COMMON)/classes.jack
410 touch $@
411
Ying Wangfbc5b9f2016-03-11 10:32:01 -0800412endif # ! prebuilt_module_is_dex_javalib
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200413endif # JAVA_LIBRARIES
414
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800415$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
Colin Crosse18cb932014-02-13 15:04:18 -0800416
417my_prebuilt_src_file :=