blob: cd4802530a44b04a03fce2801e4101d991b99f0f [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
Chih-Hung Hsieh32427d62018-04-12 10:55:54 -07009include $(BUILD_SYSTEM)/use_lld_setup.mk
10
Colin Crosse18cb932014-02-13 15:04:18 -080011ifneq ($(LOCAL_PREBUILT_LIBS),)
Colin Cross84667692018-06-25 13:20:04 -070012$(call pretty-error,dont use LOCAL_PREBUILT_LIBS anymore)
Colin Crosse18cb932014-02-13 15:04:18 -080013endif
14ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
Colin Cross84667692018-06-25 13:20:04 -070015$(call pretty-error,dont use LOCAL_PREBUILT_EXECUTABLES anymore)
Colin Crosse18cb932014-02-13 15:04:18 -080016endif
17ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
Colin Cross84667692018-06-25 13:20:04 -070018$(call pretty-error,dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore)
Colin Crosse18cb932014-02-13 15:04:18 -080019endif
20
Ying Wang34d5f1b2014-05-16 10:38:43 -070021my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
22
Colin Crosse18cb932014-02-13 15:04:18 -080023ifdef LOCAL_PREBUILT_MODULE_FILE
Ying Wangc0adfb72014-02-27 14:10:53 -080024 my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
Dan Willemsen926ee442018-02-27 23:27:30 +000025else ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
26 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
27 LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) :=
28else ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix)
29 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
30 LOCAL_SRC_FILES_$(my_32_64_bit_suffix) :=
31else ifdef LOCAL_SRC_FILES
32 my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
33 LOCAL_SRC_FILES :=
34else ifdef LOCAL_REPLACE_PREBUILT_APK_INSTALLED
35 # This is handled specially below
Colin Crosse18cb932014-02-13 15:04:18 -080036else
Dan Willemsen926ee442018-02-27 23:27:30 +000037 $(call pretty-error,No source files specified)
Colin Crosse18cb932014-02-13 15:04:18 -080038endif
39
Colin Cross01e1b8f2016-10-27 22:10:55 +000040LOCAL_CHECKED_MODULE := $(my_prebuilt_src_file)
41
Ying Wangb6eb8dd2016-03-01 20:14:52 -080042my_strip_module := $(firstword \
43 $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
44 $(LOCAL_STRIP_MODULE))
Ying Wangb6eb8dd2016-03-01 20:14:52 -080045
Colin Crosse18cb932014-02-13 15:04:18 -080046ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
Ying Wangb6eb8dd2016-03-01 20:14:52 -080047 ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),)
Ying Wangbfb52a22014-08-20 17:12:32 -070048 # Strip but not try to add debuglink
Ying Wangb6eb8dd2016-03-01 20:14:52 -080049 my_strip_module := no_debuglink
Ying Wangbfb52a22014-08-20 17:12:32 -070050 endif
Colin Crosse18cb932014-02-13 15:04:18 -080051endif
52
53ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
54 prebuilt_module_is_a_library := true
55else
56 prebuilt_module_is_a_library :=
57endif
58
59# Don't install static libraries by default.
60ifndef LOCAL_UNINSTALLABLE_MODULE
61ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
62 LOCAL_UNINSTALLABLE_MODULE := true
63endif
64endif
65
Ying Wang09c306c2016-03-15 16:36:29 -070066ifeq (JAVA_LIBRARIES,$(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE)))
67 prebuilt_module_is_dex_javalib := true
68else
69 prebuilt_module_is_dex_javalib :=
70endif
71
Dario Freni924af7d2018-08-17 00:56:14 +010072# Run veridex on product, product_services and vendor modules.
David Brazdil825770e2018-07-31 11:31:30 +010073# We skip it for unbundled app builds where we cannot build veridex.
74module_run_appcompat :=
Jeongik Cha83c50322019-01-18 15:09:09 +090075ifeq (true,$(non_system_module))
David Brazdil825770e2018-07-31 11:31:30 +010076ifeq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK))) # ! unbundled app build
Adrian Roos21028b72019-01-15 18:30:51 +010077ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true)
David Brazdil825770e2018-07-31 11:31:30 +010078 module_run_appcompat := true
79endif
80endif
Adrian Roos21028b72019-01-15 18:30:51 +010081endif
David Brazdil825770e2018-07-31 11:31:30 +010082
Narayan Kamath7c205102017-08-07 12:31:17 +010083ifdef LOCAL_COMPRESSED_MODULE
84ifneq (true,$(LOCAL_COMPRESSED_MODULE))
85$(call pretty-error, Unknown value for LOCAL_COMPRESSED_MODULE $(LOCAL_COMPRESSED_MODULE))
Ying Wangaf9757e2014-07-17 21:24:42 -070086endif
Dan Willemsendc1ddfc2016-08-05 17:23:33 -070087endif
Ying Wangaf9757e2014-07-17 21:24:42 -070088
Narayan Kamath7c205102017-08-07 12:31:17 +010089ifeq ($(LOCAL_MODULE_CLASS),APPS)
90ifdef LOCAL_COMPRESSED_MODULE
91LOCAL_BUILT_MODULE_STEM := package.apk.gz
92else
93LOCAL_BUILT_MODULE_STEM := package.apk
94endif # LOCAL_COMPRESSED_MODULE
95
96ifndef LOCAL_INSTALLED_MODULE_STEM
97ifdef LOCAL_COMPRESSED_MODULE
Narayan Kamath6a4bd692017-08-14 10:53:50 +010098PACKAGES.$(LOCAL_MODULE).COMPRESSED := gz
Narayan Kamath7c205102017-08-07 12:31:17 +010099LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk.gz
100else
101LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
102endif # LOCAL_COMPRESSED_MODULE
103endif # LOCAL_INSTALLED_MODULE_STEM
104
105else # $(LOCAL_MODULE_CLASS) != APPS)
106ifdef LOCAL_COMPRESSED_MODULE
107$(error $(LOCAL_MODULE) : LOCAL_COMPRESSED_MODULE can only be defined for module class APPS)
108endif # LOCAL_COMPRESSED_MODULE
109endif
110
Colin Cross979f9f92018-06-25 12:33:35 -0700111ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module)),)
Colin Crosse18cb932014-02-13 15:04:18 -0800112 ifdef LOCAL_IS_HOST_MODULE
Colin Cross84667692018-06-25 13:20:04 -0700113 $(call pretty-error,Cannot strip/pack host module)
Colin Crosse18cb932014-02-13 15:04:18 -0800114 endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -0800115 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Colin Cross84667692018-06-25 13:20:04 -0700116 $(call pretty-error,Can strip/pack only shared libraries or executables)
Colin Crosse18cb932014-02-13 15:04:18 -0800117 endif
118 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Colin Cross84667692018-06-25 13:20:04 -0700119 $(call pretty-error,Cannot strip/pack scripts)
Colin Crosse18cb932014-02-13 15:04:18 -0800120 endif
Colin Cross979f9f92018-06-25 12:33:35 -0700121 # Set the arch-specific variables to set up the strip rules
Ying Wangb6eb8dd2016-03-01 20:14:52 -0800122 LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module)
Colin Crosse18cb932014-02-13 15:04:18 -0800123 include $(BUILD_SYSTEM)/dynamic_binary.mk
124 built_module := $(linked_module)
Ying Wangbfb52a22014-08-20 17:12:32 -0700125
Colin Cross979f9f92018-06-25 12:33:35 -0700126else # my_strip_module not true
Colin Crosse18cb932014-02-13 15:04:18 -0800127 include $(BUILD_SYSTEM)/base_rules.mk
128 built_module := $(LOCAL_BUILT_MODULE)
129
130ifdef prebuilt_module_is_a_library
131export_includes := $(intermediates)/export_includes
Dan Willemsen05909fa2017-03-19 13:22:45 -0700132export_cflags := $(foreach d,$(LOCAL_EXPORT_C_INCLUDE_DIRS),-I $(d))
Dan Willemsen05909fa2017-03-19 13:22:45 -0700133$(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags)
Dan Willemsenba6a1642016-09-29 12:08:29 -0700134$(export_includes): $(LOCAL_EXPORT_C_INCLUDE_DEPS)
Colin Crosse18cb932014-02-13 15:04:18 -0800135 @echo Export includes file: $< -- $@
136 $(hide) mkdir -p $(dir $@) && rm -f $@
Dan Willemsen05909fa2017-03-19 13:22:45 -0700137ifdef export_cflags
138 $(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >$@
Colin Crosse18cb932014-02-13 15:04:18 -0800139else
140 $(hide) touch $@
141endif
Dan Willemsen05909fa2017-03-19 13:22:45 -0700142export_cflags :=
Colin Crosse18cb932014-02-13 15:04:18 -0800143
Dan Albert975e3032017-12-19 11:26:05 -0800144include $(BUILD_SYSTEM)/allowed_ndk_types.mk
145
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700146ifdef LOCAL_SDK_VERSION
Dan Albert4297c392017-12-19 11:27:39 -0800147my_link_type := native:ndk:$(my_ndk_stl_family):$(my_ndk_stl_link_type)
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700148else ifdef LOCAL_USE_VNDK
Jiyong Parka3fb1582017-08-16 18:28:12 +0900149 _name := $(patsubst %.vendor,%,$(LOCAL_MODULE))
150 ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),)
151 ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),)
152 my_link_type := native:vndk
153 else
154 my_link_type := native:vndk_private
155 endif
156 else
157 my_link_type := native:vendor
158 endif
Jiyong Park5dc34752018-08-28 12:32:45 +0900159else ifneq ($(filter $(TARGET_RECOVERY_OUT)/%,$(LOCAL_MODULE_PATH)),)
160my_link_type := native:recovery
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700161else
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700162my_link_type := native:platform
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700163endif
Dan Willemsenb097fbe2016-06-07 14:25:14 -0700164
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700165# TODO: check dependencies of prebuilt files
166my_link_deps :=
167
168my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
169my_common :=
170include $(BUILD_SYSTEM)/link_type.mk
Colin Crosse18cb932014-02-13 15:04:18 -0800171endif # prebuilt_module_is_a_library
172
Logan Chien0e53d882018-11-06 17:32:40 +0800173# Check prebuilt ELF binaries.
174include $(BUILD_SYSTEM)/check_elf_file.mk
175
Colin Crosse18cb932014-02-13 15:04:18 -0800176# The real dependency will be added after all Android.mks are loaded and the install paths
177# of the shared libraries are determined.
178ifdef LOCAL_INSTALLED_MODULE
179ifdef LOCAL_SHARED_LIBRARIES
Ying Wang7c877392014-10-07 13:03:29 -0700180my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
181# Extra shared libraries introduced by LOCAL_CXX_STL.
182include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700183ifdef LOCAL_USE_VNDK
Colin Cross8fb525d2018-09-06 16:25:22 -0700184 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
185 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700186endif
Ying Wang58f462f2014-02-25 18:26:29 -0800187$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wang7c877392014-10-07 13:03:29 -0700188 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
Colin Crosse18cb932014-02-13 15:04:18 -0800189endif
190endif
191
Ying Wang7c877392014-10-07 13:03:29 -0700192# We need to enclose the above export_includes and my_built_shared_libraries in
Ying Wangb6eb8dd2016-03-01 20:14:52 -0800193# "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk.
194endif # my_strip_module not true
Colin Crosse18cb932014-02-13 15:04:18 -0800195
Dan Willemsen9f956652016-10-21 15:04:12 -0700196ifeq ($(NATIVE_COVERAGE),true)
Dan Willemsen0f909082017-02-10 00:07:17 -0800197ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE)))
198 $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).gcnodir))
199 ifneq ($(LOCAL_UNINSTALLABLE_MODULE),true)
200 ifdef LOCAL_IS_HOST_MODULE
201 my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
202 else
203 my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
204 endif
Dan Willemsenba9badf2017-11-20 12:45:48 -0800205 my_coverage_path := $(my_coverage_path)/$(patsubst %.so,%,$(my_installed_module_stem)).gcnodir
Dan Willemsen0f909082017-02-10 00:07:17 -0800206 $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path)))
207 $(LOCAL_BUILT_MODULE): $(my_coverage_path)
208 endif
209else
Ryan Campbell81c9d292016-09-12 13:56:50 -0700210# Coverage information is needed when static lib is a dependency of another
211# coverage-enabled module.
212ifeq (STATIC_LIBRARIES, $(LOCAL_MODULE_CLASS))
213GCNO_ARCHIVE := $(LOCAL_MODULE).gcnodir
214$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS :=
215$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES :=
Dan Willemsen9f956652016-10-21 15:04:12 -0700216$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix)
217$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
Ryan Campbell81c9d292016-09-12 13:56:50 -0700218$(intermediates)/$(GCNO_ARCHIVE) :
219 $(transform-o-to-static-lib)
220endif
Dan Willemsen9f956652016-10-21 15:04:12 -0700221endif
Dan Willemsen0f909082017-02-10 00:07:17 -0800222endif
Ryan Campbell81c9d292016-09-12 13:56:50 -0700223
Ying Wangf0534c22014-04-15 11:12:21 -0700224ifeq ($(LOCAL_MODULE_CLASS),APPS)
Colin Crosse18cb932014-02-13 15:04:18 -0800225PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
226
Dan Willemsen048f56d2016-06-18 20:43:51 -0700227my_extract_apk := $(strip $(LOCAL_EXTRACT_APK))
228
Ying Wang43f7a322014-11-17 16:56:04 -0800229# Select dpi-specific source
230ifdef LOCAL_DPI_VARIANTS
Ying Wang60686582014-12-10 12:40:09 -0800231my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI)))
Ying Wang43f7a322014-11-17 16:56:04 -0800232ifdef my_dpi
233ifdef LOCAL_DPI_FILE_STEM
234my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM)
235else
236my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk
237endif
238my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem))
Dan Willemsen048f56d2016-06-18 20:43:51 -0700239
240ifneq ($(strip $(LOCAL_EXTRACT_DPI_APK)),)
241my_extract_apk := $(subst %,$(my_dpi),$(LOCAL_EXTRACT_DPI_APK))
242endif # LOCAL_EXTRACT_DPI_APK
Ying Wang43f7a322014-11-17 16:56:04 -0800243endif # my_dpi
244endif # LOCAL_DPI_VARIANTS
245
Dan Willemsen048f56d2016-06-18 20:43:51 -0700246ifdef my_extract_apk
247my_extracted_apk := $(intermediates)/extracted.apk
248
249$(my_extracted_apk): PRIVATE_EXTRACT := $(my_extract_apk)
250$(my_extracted_apk): $(my_prebuilt_src_file)
251 @echo Extract APK: $@
252 $(hide) mkdir -p $(dir $@) && rm -f $@
253 $(hide) unzip -p $< $(PRIVATE_EXTRACT) >$@
254
255my_prebuilt_src_file := $(my_extracted_apk)
256my_extracted_apk :=
257my_extract_apk :=
Mathieu Chartier55eabd52017-09-15 13:40:48 -0700258ifeq ($(PRODUCT_ALWAYS_PREOPT_EXTRACTED_APK),true)
259# If the product property is set, always preopt for extracted modules to prevent executing out of
260# the APK.
261my_preopt_for_extracted_apk := true
262endif
Dan Willemsen048f56d2016-06-18 20:43:51 -0700263endif
264
Narayan Kamathbbcdc072017-08-22 15:47:08 +0100265dex_preopt_profile_src_file := $(my_prebuilt_src_file)
266
Ying Wang96bcad42014-04-17 13:38:04 -0700267rs_compatibility_jni_libs :=
268include $(BUILD_SYSTEM)/install_jni_libs.mk
269
Colin Crosse18cb932014-02-13 15:04:18 -0800270ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
271 # The magic string "EXTERNAL" means this package will be signed with
272 # the default dev key throughout the build process, but we expect
273 # the final package to be signed with a different key.
274 #
275 # This can be used for packages where we don't have access to the
276 # keys, but want the package to be predexopt'ed.
277 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
278 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
279
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900280 $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Colin Crosse18cb932014-02-13 15:04:18 -0800281 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
282 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
283endif
284ifeq ($(LOCAL_CERTIFICATE),)
Ying Wangf0534c22014-04-15 11:12:21 -0700285 # It is now a build error to add a prebuilt .apk without
286 # specifying a key for it.
287 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
Colin Crosse18cb932014-02-13 15:04:18 -0800288else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
289 # The magic string "PRESIGNED" means this package is already checked
290 # signed with its release key.
291 #
292 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
293 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
294 # but the dexpreopt process will not try to re-sign the app.
295 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
296 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
297else
298 # If this is not an absolute certificate, assign it to a generic one.
299 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
300 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
301 endif
302
303 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
304 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
305 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
306
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900307 $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Colin Crosse18cb932014-02-13 15:04:18 -0800308 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
309 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
310endif
311
Jeongik Chab2c4bb72018-12-17 14:45:15 +0900312include $(BUILD_SYSTEM)/app_certificate_validate.mk
313
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700314# Disable dex-preopt of prebuilts to save space, if requested.
Ying Wang09c306c2016-03-15 16:36:29 -0700315ifndef LOCAL_DEX_PREOPT
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700316ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
Colin Crosse18cb932014-02-13 15:04:18 -0800317LOCAL_DEX_PREOPT := false
Andreas Gampe5e0dbe02014-10-01 22:01:16 -0700318endif
Ying Wang09c306c2016-03-15 16:36:29 -0700319endif
Colin Crosse18cb932014-02-13 15:04:18 -0800320
Narayan Kamath7c205102017-08-07 12:31:17 +0100321# If the module is a compressed module, we don't pre-opt it because its final
322# installation location will be the data partition.
323ifdef LOCAL_COMPRESSED_MODULE
324LOCAL_DEX_PREOPT := false
325endif
326
Colin Cross6db5b0e2018-11-16 21:26:33 -0800327my_dex_jar := $(my_prebuilt_src_file)
328
Colin Crosse18cb932014-02-13 15:04:18 -0800329#######################################
330# defines built_odex along with rule to install odex
331include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
332#######################################
Ying Wang09c306c2016-03-15 16:36:29 -0700333ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
334# There is a replacement for the prebuilt .apk we can install without any processing.
335$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED)
336 $(transform-prebuilt-to-target)
Ying Wangb7d33c02016-03-15 16:28:57 -0700337
Ying Wang09c306c2016-03-15 16:36:29 -0700338else # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
339# Sign and align non-presigned .apks.
Ying Wang1fb01522015-05-01 14:02:26 -0700340# The embedded prebuilt jni to uncompress.
Ying Wang226eb922015-06-01 19:19:57 -0700341ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
342# For PRESIGNED apks we must uncompress every .so file:
343# even if the .so file isn't for the current TARGET_ARCH,
344# we can't strip the file.
Colin Cross0e8a2ee2018-10-09 10:17:55 -0700345embedded_prebuilt_jni_libs :=
Ying Wang226eb922015-06-01 19:19:57 -0700346endif
Ying Wang1fb01522015-05-01 14:02:26 -0700347ifndef embedded_prebuilt_jni_libs
348# No LOCAL_PREBUILT_JNI_LIBS, uncompress all.
Colin Cross0e8a2ee2018-10-09 10:17:55 -0700349embedded_prebuilt_jni_libs :=
Ying Wang1fb01522015-05-01 14:02:26 -0700350endif
351$(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
352
Narayan Kamath7c205102017-08-07 12:31:17 +0100353ifdef LOCAL_COMPRESSED_MODULE
354$(built_module) : $(MINIGZIP)
355endif
356
David Brazdil825770e2018-07-31 11:31:30 +0100357ifeq ($(module_run_appcompat),true)
Dan Willemsenb73ccb72018-09-17 14:36:37 -0700358$(built_module) : $(appcompat-files)
Dario Freni716e9b62018-07-31 15:29:13 +0100359$(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
Dario Freni1ecc9252018-07-13 16:44:28 +0100360endif
361
Colin Cross53c8f972018-09-28 16:19:42 -0700362ifneq ($(BUILD_PLATFORM_ZIP),)
363$(built_module) : .KATI_IMPLICIT_OUTPUTS := $(dir $(LOCAL_BUILT_MODULE))package.dex.apk
364endif
Dan Willemsen07b73572019-01-07 13:58:37 -0800365ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
Colin Cross6db5b0e2018-11-16 21:26:33 -0800366ifdef LOCAL_DEX_PREOPT
367$(built_module) : PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh
368$(built_module) : $(intermediates)/strip.sh
Colin Crossded0aec2019-01-17 16:22:04 -0800369$(built_module) : | $(DEXPREOPT_STRIP_DEPS)
Colin Cross6db5b0e2018-11-16 21:26:33 -0800370$(built_module) : .KATI_DEPFILE := $(built_module).d
371endif
Dan Willemsen07b73572019-01-07 13:58:37 -0800372endif
Colin Cross6db5b0e2018-11-16 21:26:33 -0800373$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR)
Colin Crosse18cb932014-02-13 15:04:18 -0800374 $(transform-prebuilt-to-target)
Colin Cross0e8a2ee2018-10-09 10:17:55 -0700375 $(uncompress-prebuilt-embedded-jni-libs)
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000376ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
Nicolas Geoffrayb06c30b2017-09-19 11:51:45 +0000377 $(uncompress-dexs)
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000378endif # LOCAL_UNCOMPRESS_DEX
Ying Wang09c306c2016-03-15 16:36:29 -0700379ifdef LOCAL_DEX_PREOPT
380ifneq ($(BUILD_PLATFORM_ZIP),)
381 @# Keep a copy of apk with classes.dex unstripped
382 $(hide) cp -f $@ $(dir $@)package.dex.apk
383endif # BUILD_PLATFORM_ZIP
384endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700385ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
386 @# Only strip out files if we can re-sign the package.
Dario Freni1ecc9252018-07-13 16:44:28 +0100387# Run appcompat before stripping the classes.dex file.
David Brazdil825770e2018-07-31 11:31:30 +0100388ifeq ($(module_run_appcompat),true)
Dario Freni716e9b62018-07-31 15:29:13 +0100389ifeq ($(LOCAL_USE_AAPT2),true)
390 $(call appcompat-header, aapt2)
391else
392 $(appcompat-header)
393endif
Dario Freni1ecc9252018-07-13 16:44:28 +0100394 $(run-appcompat)
David Brazdil825770e2018-07-31 11:31:30 +0100395endif # module_run_appcompat
Colin Crosse18cb932014-02-13 15:04:18 -0800396ifdef LOCAL_DEX_PREOPT
Dan Willemsen07b73572019-01-07 13:58:37 -0800397 mv -f $@ $@.tmp
398 $(PRIVATE_STRIP_SCRIPT) $@.tmp $@
Ying Wang09c306c2016-03-15 16:36:29 -0700399endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700400 $(sign-package)
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800401 # No need for align-package because sign-package takes care of alignment
Ying Wang09c306c2016-03-15 16:36:29 -0700402else # LOCAL_CERTIFICATE == PRESIGNED
Colin Crosse18cb932014-02-13 15:04:18 -0800403 $(align-package)
Ying Wang09c306c2016-03-15 16:36:29 -0700404endif # LOCAL_CERTIFICATE
Narayan Kamath7c205102017-08-07 12:31:17 +0100405ifdef LOCAL_COMPRESSED_MODULE
406 $(compress-package)
407endif # LOCAL_COMPRESSED_MODULE
Ying Wang09c306c2016-03-15 16:36:29 -0700408endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
Colin Crosse18cb932014-02-13 15:04:18 -0800409
Ying Wang36142f62014-05-21 16:13:33 -0700410
Ying Wang00fe5872014-07-23 14:35:40 -0700411###############################
412## Install split apks.
413ifdef LOCAL_PACKAGE_SPLITS
Narayan Kamath7c205102017-08-07 12:31:17 +0100414ifdef LOCAL_COMPRESSED_MODULE
415$(error $(LOCAL_MODULE): LOCAL_COMPRESSED_MODULE is not currently supported for split installs)
416endif # LOCAL_COMPRESSED_MODULE
417
Ying Wang00fe5872014-07-23 14:35:40 -0700418# LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
Dan Willemsenf72308a2017-05-15 23:38:04 -0700419built_apk_splits := $(addprefix $(intermediates)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
Ying Wang00fe5872014-07-23 14:35:40 -0700420installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
421
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800422# Rules to sign the split apks.
Ying Wang00fe5872014-07-23 14:35:40 -0700423my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
424ifneq (1,$(words $(my_src_dir)))
425$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
426endif
427my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
428
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900429$(built_apk_splits) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
Ying Wang00fe5872014-07-23 14:35:40 -0700430$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
431$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
Dan Willemsenf72308a2017-05-15 23:38:04 -0700432$(built_apk_splits) : $(intermediates)/%.apk : $(my_src_dir)/%.apk
Ying Wang00fe5872014-07-23 14:35:40 -0700433 $(copy-file-to-new-target)
434 $(sign-package)
Ying Wang00fe5872014-07-23 14:35:40 -0700435
436# Rules to install the split apks.
Dan Willemsenf72308a2017-05-15 23:38:04 -0700437$(installed_apk_splits) : $(my_module_path)/%.apk : $(intermediates)/%.apk
Ying Wang00fe5872014-07-23 14:35:40 -0700438 @echo "Install: $@"
439 $(copy-file-to-new-target)
440
441# Register the additional built and installed files.
442ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
443ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
Dan Willemsenf72308a2017-05-15 23:38:04 -0700444 $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(intermediates)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
Ying Wang00fe5872014-07-23 14:35:40 -0700445
446# Make sure to install the splits when you run "make <module_name>".
Colin Cross33886702016-09-20 16:01:28 -0700447$(my_all_targets): $(installed_apk_splits)
Ying Wang00fe5872014-07-23 14:35:40 -0700448
449endif # LOCAL_PACKAGE_SPLITS
450
Ying Wangda366352016-03-15 17:05:52 -0700451else ifeq ($(prebuilt_module_is_dex_javalib),true) # ! LOCAL_MODULE_CLASS != APPS
Colin Cross6db5b0e2018-11-16 21:26:33 -0800452my_dex_jar := $(my_prebuilt_src_file)
Ying Wang09c306c2016-03-15 16:36:29 -0700453# This is a target shared library, i.e. a jar with classes.dex.
454#######################################
455# defines built_odex along with rule to install odex
456include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
457#######################################
458ifdef LOCAL_DEX_PREOPT
459ifneq ($(dexpreopt_boot_jar_module),) # boot jar
460# boot jar's rules are defined in dex_preopt.mk
461dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
462$(built_module) : $(dexpreopted_boot_jar)
463 $(call copy-file-to-target)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800464
Ying Wang09c306c2016-03-15 16:36:29 -0700465# For libart boot jars, we don't have .odex files.
466else # ! boot jar
Ying Wang09c306c2016-03-15 16:36:29 -0700467
Colin Cross6db5b0e2018-11-16 21:26:33 -0800468$(built_module): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh
469$(built_module): $(intermediates)/strip.sh
Colin Crossded0aec2019-01-17 16:22:04 -0800470$(built_module): | $(DEXPREOPT_STRIP_DEPS)
Colin Cross6db5b0e2018-11-16 21:26:33 -0800471$(built_module): .KATI_DEPFILE := $(built_module).d
472$(built_module): $(my_prebuilt_src_file)
473 $(PRIVATE_STRIP_SCRIPT) $< $@
474
Ying Wang09c306c2016-03-15 16:36:29 -0700475endif # boot jar
476else # ! LOCAL_DEX_PREOPT
477$(built_module) : $(my_prebuilt_src_file)
478 $(call copy-file-to-target)
479endif # LOCAL_DEX_PREOPT
480
481else # ! prebuilt_module_is_dex_javalib
Tom Cherryfc977642018-06-13 14:51:05 -0700482ifneq ($(filter init%rc,$(notdir $(LOCAL_INSTALLED_MODULE)))$(filter %/etc/init,$(dir $(LOCAL_INSTALLED_MODULE))),)
483 $(eval $(call copy-init-script-file-checked,$(my_prebuilt_src_file),$(built_module)))
484else ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Colin Crosse18cb932014-02-13 15:04:18 -0800485$(built_module) : $(my_prebuilt_src_file)
486 $(transform-prebuilt-to-target-strip-comments)
487else
Tom Cherryfc977642018-06-13 14:51:05 -0700488$(built_module) : $(my_prebuilt_src_file)
Colin Crosse18cb932014-02-13 15:04:18 -0800489 $(transform-prebuilt-to-target)
Colin Crosse18cb932014-02-13 15:04:18 -0800490endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -0800491ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800492 $(hide) chmod +x $@
493endif
Ying Wang09c306c2016-03-15 16:36:29 -0700494endif # ! prebuilt_module_is_dex_javalib
Colin Crosse18cb932014-02-13 15:04:18 -0800495
Ying Wang8c89b4b2016-02-22 15:54:27 -0800496ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
497my_src_jar := $(my_prebuilt_src_file)
Colin Cross941b6822017-03-29 13:53:29 -0700498
499ifdef LOCAL_IS_HOST_MODULE
500# for host java libraries deps should be in the common dir, so we make a copy in
501# the common dir.
502common_classes_jar := $(intermediates.COMMON)/classes.jar
Nan Zhangb3ec5342017-08-31 21:43:04 +0000503common_header_jar := $(intermediates.COMMON)/classes-header.jar
Colin Cross941b6822017-03-29 13:53:29 -0700504
Colin Cross96476c12017-04-06 09:56:19 -0700505$(common_classes_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
Colin Crossd2e778f2017-04-14 15:14:33 -0700506$(common_classes_jar): PRIVATE_PREFIX := $(my_prefix)
Colin Cross941b6822017-03-29 13:53:29 -0700507
508$(common_classes_jar) : $(my_src_jar)
509 $(transform-prebuilt-to-target)
510
Colin Cross7dc90432017-09-26 16:17:24 -0700511ifneq ($(TURBINE_ENABLED),false)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000512$(common_header_jar) : $(my_src_jar)
513 $(transform-prebuilt-to-target)
Colin Cross7dc90432017-09-26 16:17:24 -0700514endif
Nan Zhangb3ec5342017-08-31 21:43:04 +0000515
Colin Cross941b6822017-03-29 13:53:29 -0700516else # !LOCAL_IS_HOST_MODULE
Colin Crosse18cb932014-02-13 15:04:18 -0800517# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
518# 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 -0700519common_classes_jar := $(intermediates.COMMON)/classes.jar
Nan Zhangb3ec5342017-08-31 21:43:04 +0000520common_header_jar := $(intermediates.COMMON)/classes-header.jar
Colin Cross950f1ef2017-04-05 15:30:42 -0700521common_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar
Ying Wange9dd9f22014-10-29 15:48:32 -0700522common_javalib_jar := $(intermediates.COMMON)/javalib.jar
Colin Crosse18cb932014-02-13 15:04:18 -0800523
Colin Crossd2e778f2017-04-14 15:14:33 -0700524$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
525$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_PREFIX := $(my_prefix)
Ying Wange9dd9f22014-10-29 15:48:32 -0700526
Dan Willemsen62dfb592016-07-08 21:33:05 -0700527ifeq ($(LOCAL_SDK_VERSION),system_current)
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700528my_link_type := java:system
Sundong Ahn5a44d1f2017-10-16 19:20:34 +0900529else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
530my_link_type := java:system
Jiyong Park5ebca302018-01-31 00:14:55 +0900531else ifeq ($(LOCAL_SDK_VERSION),core_current)
532my_link_type := java:core
Dan Willemsen62dfb592016-07-08 21:33:05 -0700533else ifneq ($(LOCAL_SDK_VERSION),)
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700534my_link_type := java:sdk
Dan Willemsen62dfb592016-07-08 21:33:05 -0700535else
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700536my_link_type := java:platform
Dan Willemsen62dfb592016-07-08 21:33:05 -0700537endif
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700538
539# TODO: check dependencies of prebuilt files
540my_link_deps :=
541
542my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
543my_common := COMMON
544include $(BUILD_SYSTEM)/link_type.mk
Dan Willemsen62dfb592016-07-08 21:33:05 -0700545
Ying Wang09c306c2016-03-15 16:36:29 -0700546ifeq ($(prebuilt_module_is_dex_javalib),true)
547# For prebuilt shared Java library we don't have classes.jar.
548$(common_javalib_jar) : $(my_src_jar)
549 $(transform-prebuilt-to-target)
550
551else # ! prebuilt_module_is_dex_javalib
552
Ying Wangdd71c852015-12-04 13:59:18 -0800553my_src_aar := $(filter %.aar, $(my_prebuilt_src_file))
554ifneq ($(my_src_aar),)
Ying Wange9dd9f22014-10-29 15:48:32 -0700555# This is .aar file, archive of classes.jar and Android resources.
Jeff Gastondb6557e2018-02-27 14:05:40 -0500556
557# run Jetifier if needed
558LOCAL_JETIFIER_INPUT_FILE := $(my_src_aar)
559include $(BUILD_SYSTEM)/jetifier.mk
560my_src_aar := $(LOCAL_JETIFIER_OUTPUT_FILE)
561
Ying Wange9dd9f22014-10-29 15:48:32 -0700562my_src_jar := $(intermediates.COMMON)/aar/classes.jar
Dan Willemsen1d646232017-11-17 13:11:26 -0800563my_src_proguard_options := $(intermediates.COMMON)/aar/proguard.txt
Colin Cross93fbe842018-06-12 14:02:41 -0700564my_src_android_manifest := $(intermediates.COMMON)/aar/AndroidManifest.xml
Ying Wange9dd9f22014-10-29 15:48:32 -0700565
Dan Willemsen1d646232017-11-17 13:11:26 -0800566$(my_src_jar) : .KATI_IMPLICIT_OUTPUTS := $(my_src_proguard_options)
Colin Cross93fbe842018-06-12 14:02:41 -0700567$(my_src_jar) : .KATI_IMPLICIT_OUTPUTS += $(my_src_android_manifest)
Ying Wangdd71c852015-12-04 13:59:18 -0800568$(my_src_jar) : $(my_src_aar)
Dan Willemsen7a1ad6c2017-04-27 23:10:47 -0700569 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) $(dir $@)/res
Ying Wange9dd9f22014-10-29 15:48:32 -0700570 $(hide) unzip -qo -d $(dir $@) $<
571 # Make sure the extracted classes.jar has a new timestamp.
572 $(hide) touch $@
Colin Cross93fbe842018-06-12 14:02:41 -0700573 # Make sure the proguard and AndroidManifest.xml files exist
574 # and have a new timestamp.
Dan Willemsen1d646232017-11-17 13:11:26 -0800575 $(hide) touch $(dir $@)/proguard.txt
Colin Cross93fbe842018-06-12 14:02:41 -0700576 $(hide) touch $(dir $@)/AndroidManifest.xml
Colin Cross8e921792018-06-07 16:44:07 -0700577
578my_prebuilt_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
579$(eval $(call copy-one-file,$(my_src_android_manifest),$(my_prebuilt_android_manifest)))
580$(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_prebuilt_android_manifest))
581
Jeff Gastondb6557e2018-02-27 14:05:40 -0500582else
583
584# run Jetifier if needed
585LOCAL_JETIFIER_INPUT_FILE := $(my_src_jar)
586include $(BUILD_SYSTEM)/jetifier.mk
587my_src_jar := $(LOCAL_JETIFIER_OUTPUT_FILE)
Ying Wange9dd9f22014-10-29 15:48:32 -0700588
Ying Wange9dd9f22014-10-29 15:48:32 -0700589endif
Ying Wang09c306c2016-03-15 16:36:29 -0700590
Dan Willemsen7f016152016-02-29 17:52:39 -0800591$(common_classes_jar) : $(my_src_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800592 $(transform-prebuilt-to-target)
593
Colin Cross7dc90432017-09-26 16:17:24 -0700594ifneq ($(TURBINE_ENABLED),false)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000595$(common_header_jar) : $(my_src_jar)
596 $(transform-prebuilt-to-target)
Colin Cross7dc90432017-09-26 16:17:24 -0700597endif
Nan Zhangb3ec5342017-08-31 21:43:04 +0000598
Colin Cross950f1ef2017-04-05 15:30:42 -0700599$(common_classes_pre_proguard_jar) : $(my_src_jar)
600 $(transform-prebuilt-to-target)
601
Dan Willemsen7f016152016-02-29 17:52:39 -0800602$(common_javalib_jar) : $(common_classes_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800603 $(transform-prebuilt-to-target)
604
Colin Cross20299032018-05-09 13:29:51 -0700605include $(BUILD_SYSTEM)/force_aapt2.mk
606
Dan Willemsenbb6393c2017-11-17 15:39:52 -0800607ifdef LOCAL_AAPT2_ONLY
608LOCAL_USE_AAPT2 := true
609endif
610
Colin Cross20299032018-05-09 13:29:51 -0700611ifeq ($(LOCAL_USE_AAPT2),true)
Ying Wangdd71c852015-12-04 13:59:18 -0800612ifneq ($(my_src_aar),)
Dan Willemsen1d646232017-11-17 13:11:26 -0800613
614$(intermediates.COMMON)/export_proguard_flags : $(my_src_proguard_options)
615 $(transform-prebuilt-to-target)
616
Dan Willemsen470e0e12017-04-27 22:28:06 -0700617LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
618ifeq ($(LOCAL_SDK_RES_VERSION),)
619 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
620endif
621
622framework_res_package_export :=
Dan Willemsen470e0e12017-04-27 22:28:06 -0700623# Please refer to package.mk
624ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
625ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),)
626framework_res_package_export := \
Anton Hansson66d47b82018-04-27 14:11:17 +0100627 $(call resolve-prebuilt-sdk-jar-path,$(LOCAL_SDK_RES_VERSION))
Dan Willemsen470e0e12017-04-27 22:28:06 -0700628else
629framework_res_package_export := \
630 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
Dan Willemsen470e0e12017-04-27 22:28:06 -0700631endif
632endif
633
Ying Wange295c3d2016-02-24 14:11:55 -0800634my_res_package := $(intermediates.COMMON)/package-res.apk
635
636# We needed only very few PRIVATE variables and aapt2.mk input variables. Reset the unnecessary ones.
637$(my_res_package): PRIVATE_AAPT2_CFLAGS :=
Dan Willemsene3c99012017-10-05 13:22:30 -0700638$(my_res_package): PRIVATE_AAPT_FLAGS := --static-lib --no-static-lib-packages --auto-add-overlay
Colin Cross93fbe842018-06-12 14:02:41 -0700639$(my_res_package): PRIVATE_ANDROID_MANIFEST := $(my_src_android_manifest)
Dan Willemsen470e0e12017-04-27 22:28:06 -0700640$(my_res_package): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
Ying Wange295c3d2016-02-24 14:11:55 -0800641$(my_res_package): PRIVATE_SOURCE_INTERMEDIATES_DIR :=
642$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE :=
643$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
644$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
Adam Lesinskie758f932016-02-26 11:13:43 -0800645$(my_res_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
646$(my_res_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
647$(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS :=
Colin Cross65c7cdf2018-02-20 14:31:33 -0800648$(my_res_package) : $(framework_res_package_export)
Colin Cross93fbe842018-06-12 14:02:41 -0700649$(my_res_package) : $(my_src_android_manifest)
Ying Wange295c3d2016-02-24 14:11:55 -0800650
651full_android_manifest :=
652my_res_resources :=
653my_overlay_resources :=
Dan Willemsen48845252017-04-27 21:25:34 -0700654my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res
Ying Wange295c3d2016-02-24 14:11:55 -0800655R_file_stamp :=
656proguard_options_file :=
657my_generated_res_dirs := $(intermediates.COMMON)/aar/res
658my_generated_res_dirs_deps := $(my_src_jar)
659include $(BUILD_SYSTEM)/aapt2.mk
660
661# Make sure my_res_package is created when you run mm/mmm.
662$(built_module) : $(my_res_package)
Ying Wangdd71c852015-12-04 13:59:18 -0800663endif # $(my_src_aar)
Ying Wange295c3d2016-02-24 14:11:55 -0800664endif # LOCAL_USE_AAPT2
Colin Crosse18cb932014-02-13 15:04:18 -0800665# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
666$(built_module) : $(common_javalib_jar)
Ying Wang09c306c2016-03-15 16:36:29 -0700667
Jiyong Park1cf8ee62018-05-22 15:39:59 +0900668my_exported_sdk_libs_file := $(intermediates.COMMON)/exported-sdk-libs
669$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS := $(LOCAL_EXPORT_SDK_LIBRARIES)
670$(my_exported_sdk_libs_file):
671 @echo "Export SDK libs $@"
672 $(hide) mkdir -p $(dir $@) && rm -f $@
Jiyong Parkbe4910a2018-07-14 15:06:48 +0900673 $(if $(PRIVATE_EXPORTED_SDK_LIBS),\
Jiyong Park1cf8ee62018-05-22 15:39:59 +0900674 $(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\
675 $(hide) touch $@)
676
Ying Wang09c306c2016-03-15 16:36:29 -0700677endif # ! prebuilt_module_is_dex_javalib
Ying Wang8c89b4b2016-02-22 15:54:27 -0800678endif # LOCAL_IS_HOST_MODULE is not set
Yohann Rousseld87cc992016-01-19 16:08:34 +0100679
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200680endif # JAVA_LIBRARIES
681
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800682$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
Colin Crosse18cb932014-02-13 15:04:18 -0800683
684my_prebuilt_src_file :=
Mathieu Chartier55eabd52017-09-15 13:40:48 -0700685my_preopt_for_extracted_apk :=