blob: 218fff9874af6e79e9b23bf16b00a63fbe225bad [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
Jaewoong Jung09bfe552019-03-18 14:25:00 -070042ifeq (APPS,$(LOCAL_MODULE_CLASS))
43include $(BUILD_SYSTEM)/app_prebuilt_internal.mk
44else
45#
46# Non-APPS prebuilt modules handling almost to the end of the file
47#
48
Ying Wangb6eb8dd2016-03-01 20:14:52 -080049my_strip_module := $(firstword \
50 $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
51 $(LOCAL_STRIP_MODULE))
Ying Wangb6eb8dd2016-03-01 20:14:52 -080052
Colin Crosse18cb932014-02-13 15:04:18 -080053ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
Ying Wangb6eb8dd2016-03-01 20:14:52 -080054 ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),)
Ying Wangbfb52a22014-08-20 17:12:32 -070055 # Strip but not try to add debuglink
Ying Wangb6eb8dd2016-03-01 20:14:52 -080056 my_strip_module := no_debuglink
Ying Wangbfb52a22014-08-20 17:12:32 -070057 endif
Colin Crosse18cb932014-02-13 15:04:18 -080058endif
59
60ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
61 prebuilt_module_is_a_library := true
62else
63 prebuilt_module_is_a_library :=
64endif
65
66# Don't install static libraries by default.
67ifndef LOCAL_UNINSTALLABLE_MODULE
68ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
69 LOCAL_UNINSTALLABLE_MODULE := true
70endif
71endif
72
Ying Wang09c306c2016-03-15 16:36:29 -070073ifeq (JAVA_LIBRARIES,$(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE)))
74 prebuilt_module_is_dex_javalib := true
75else
76 prebuilt_module_is_dex_javalib :=
77endif
78
Narayan Kamath7c205102017-08-07 12:31:17 +010079ifdef LOCAL_COMPRESSED_MODULE
80$(error $(LOCAL_MODULE) : LOCAL_COMPRESSED_MODULE can only be defined for module class APPS)
81endif # LOCAL_COMPRESSED_MODULE
Narayan Kamath7c205102017-08-07 12:31:17 +010082
Colin Cross979f9f92018-06-25 12:33:35 -070083ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module)),)
Colin Crosse18cb932014-02-13 15:04:18 -080084 ifdef LOCAL_IS_HOST_MODULE
Colin Cross84667692018-06-25 13:20:04 -070085 $(call pretty-error,Cannot strip/pack host module)
Colin Crosse18cb932014-02-13 15:04:18 -080086 endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -080087 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Colin Cross84667692018-06-25 13:20:04 -070088 $(call pretty-error,Can strip/pack only shared libraries or executables)
Colin Crosse18cb932014-02-13 15:04:18 -080089 endif
90 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Colin Cross84667692018-06-25 13:20:04 -070091 $(call pretty-error,Cannot strip/pack scripts)
Colin Crosse18cb932014-02-13 15:04:18 -080092 endif
Colin Cross979f9f92018-06-25 12:33:35 -070093 # Set the arch-specific variables to set up the strip rules
Ying Wangb6eb8dd2016-03-01 20:14:52 -080094 LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module)
Colin Crosse18cb932014-02-13 15:04:18 -080095 include $(BUILD_SYSTEM)/dynamic_binary.mk
96 built_module := $(linked_module)
Ying Wangbfb52a22014-08-20 17:12:32 -070097
Colin Cross979f9f92018-06-25 12:33:35 -070098else # my_strip_module not true
Colin Crosse18cb932014-02-13 15:04:18 -080099 include $(BUILD_SYSTEM)/base_rules.mk
100 built_module := $(LOCAL_BUILT_MODULE)
101
102ifdef prebuilt_module_is_a_library
103export_includes := $(intermediates)/export_includes
Dan Willemsen05909fa2017-03-19 13:22:45 -0700104export_cflags := $(foreach d,$(LOCAL_EXPORT_C_INCLUDE_DIRS),-I $(d))
Dan Willemsen05909fa2017-03-19 13:22:45 -0700105$(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags)
Dan Willemsenba6a1642016-09-29 12:08:29 -0700106$(export_includes): $(LOCAL_EXPORT_C_INCLUDE_DEPS)
Colin Crosse18cb932014-02-13 15:04:18 -0800107 @echo Export includes file: $< -- $@
108 $(hide) mkdir -p $(dir $@) && rm -f $@
Dan Willemsen05909fa2017-03-19 13:22:45 -0700109ifdef export_cflags
110 $(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >$@
Colin Crosse18cb932014-02-13 15:04:18 -0800111else
112 $(hide) touch $@
113endif
Dan Willemsen05909fa2017-03-19 13:22:45 -0700114export_cflags :=
Colin Crosse18cb932014-02-13 15:04:18 -0800115
Dan Albert975e3032017-12-19 11:26:05 -0800116include $(BUILD_SYSTEM)/allowed_ndk_types.mk
117
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700118ifdef LOCAL_SDK_VERSION
Dan Albert4297c392017-12-19 11:27:39 -0800119my_link_type := native:ndk:$(my_ndk_stl_family):$(my_ndk_stl_link_type)
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700120else ifdef LOCAL_USE_VNDK
Jiyong Parka3fb1582017-08-16 18:28:12 +0900121 _name := $(patsubst %.vendor,%,$(LOCAL_MODULE))
122 ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),)
123 ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),)
124 my_link_type := native:vndk
125 else
126 my_link_type := native:vndk_private
127 endif
128 else
129 my_link_type := native:vendor
130 endif
Jiyong Park5dc34752018-08-28 12:32:45 +0900131else ifneq ($(filter $(TARGET_RECOVERY_OUT)/%,$(LOCAL_MODULE_PATH)),)
132my_link_type := native:recovery
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700133else
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700134my_link_type := native:platform
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700135endif
Dan Willemsenb097fbe2016-06-07 14:25:14 -0700136
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700137# TODO: check dependencies of prebuilt files
138my_link_deps :=
139
140my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
141my_common :=
142include $(BUILD_SYSTEM)/link_type.mk
Colin Crosse18cb932014-02-13 15:04:18 -0800143endif # prebuilt_module_is_a_library
144
145# The real dependency will be added after all Android.mks are loaded and the install paths
146# of the shared libraries are determined.
147ifdef LOCAL_INSTALLED_MODULE
Logan Chien32911842019-01-31 12:05:12 +0800148ifdef LOCAL_IS_HOST_MODULE
149 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
150 my_system_shared_libraries :=
151 else
152 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
153 endif
154else
155 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
156 my_system_shared_libraries := libc libm libdl
157 else
158 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
159 my_system_shared_libraries := $(patsubst libc,libc libdl,$(my_system_shared_libraries))
160 endif
161endif
162
163my_shared_libraries := \
164 $(filter-out $(my_system_shared_libraries),$(LOCAL_SHARED_LIBRARIES)) \
165 $(my_system_shared_libraries)
166
167ifdef my_shared_libraries
Ying Wang7c877392014-10-07 13:03:29 -0700168# Extra shared libraries introduced by LOCAL_CXX_STL.
169include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700170ifdef LOCAL_USE_VNDK
Colin Cross8fb525d2018-09-06 16:25:22 -0700171 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
172 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
Dan Willemsen9d2b3282017-04-07 20:58:43 -0700173endif
Ying Wang58f462f2014-02-25 18:26:29 -0800174$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Ying Wang7c877392014-10-07 13:03:29 -0700175 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
Colin Crosse18cb932014-02-13 15:04:18 -0800176endif
Logan Chien32911842019-01-31 12:05:12 +0800177endif # my_shared_libraries
Colin Crosse18cb932014-02-13 15:04:18 -0800178
Ying Wang7c877392014-10-07 13:03:29 -0700179# We need to enclose the above export_includes and my_built_shared_libraries in
Ying Wangb6eb8dd2016-03-01 20:14:52 -0800180# "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk.
181endif # my_strip_module not true
Colin Crosse18cb932014-02-13 15:04:18 -0800182
Logan Chien6549cd02019-01-31 12:05:32 +0800183# Check prebuilt ELF binaries.
184include $(BUILD_SYSTEM)/check_elf_file.mk
185
Dan Willemsen9f956652016-10-21 15:04:12 -0700186ifeq ($(NATIVE_COVERAGE),true)
Dan Willemsen0f909082017-02-10 00:07:17 -0800187ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE)))
188 $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).gcnodir))
189 ifneq ($(LOCAL_UNINSTALLABLE_MODULE),true)
190 ifdef LOCAL_IS_HOST_MODULE
191 my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
192 else
193 my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
194 endif
Dan Willemsenba9badf2017-11-20 12:45:48 -0800195 my_coverage_path := $(my_coverage_path)/$(patsubst %.so,%,$(my_installed_module_stem)).gcnodir
Dan Willemsen0f909082017-02-10 00:07:17 -0800196 $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path)))
197 $(LOCAL_BUILT_MODULE): $(my_coverage_path)
198 endif
199else
Ryan Campbell81c9d292016-09-12 13:56:50 -0700200# Coverage information is needed when static lib is a dependency of another
201# coverage-enabled module.
202ifeq (STATIC_LIBRARIES, $(LOCAL_MODULE_CLASS))
203GCNO_ARCHIVE := $(LOCAL_MODULE).gcnodir
204$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS :=
205$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES :=
Dan Willemsen9f956652016-10-21 15:04:12 -0700206$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix)
207$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
Ryan Campbell81c9d292016-09-12 13:56:50 -0700208$(intermediates)/$(GCNO_ARCHIVE) :
209 $(transform-o-to-static-lib)
210endif
Dan Willemsen9f956652016-10-21 15:04:12 -0700211endif
Dan Willemsen0f909082017-02-10 00:07:17 -0800212endif
Ryan Campbell81c9d292016-09-12 13:56:50 -0700213
Jaewoong Jung09bfe552019-03-18 14:25:00 -0700214ifeq ($(prebuilt_module_is_dex_javalib),true)
Colin Cross6db5b0e2018-11-16 21:26:33 -0800215my_dex_jar := $(my_prebuilt_src_file)
Ying Wang09c306c2016-03-15 16:36:29 -0700216# This is a target shared library, i.e. a jar with classes.dex.
Colin Cross47e384c2019-02-11 14:25:13 -0800217
218ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),)
219 $(call pretty-error,Modules in PRODUCT_BOOT_JARS must be defined in Android.bp files)
220endif
221
Ying Wang09c306c2016-03-15 16:36:29 -0700222#######################################
223# defines built_odex along with rule to install odex
224include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
225#######################################
226ifdef LOCAL_DEX_PREOPT
Ying Wang09c306c2016-03-15 16:36:29 -0700227
Colin Cross6db5b0e2018-11-16 21:26:33 -0800228$(built_module): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh
229$(built_module): $(intermediates)/strip.sh
Colin Crossded0aec2019-01-17 16:22:04 -0800230$(built_module): | $(DEXPREOPT_STRIP_DEPS)
Colin Cross6db5b0e2018-11-16 21:26:33 -0800231$(built_module): .KATI_DEPFILE := $(built_module).d
232$(built_module): $(my_prebuilt_src_file)
233 $(PRIVATE_STRIP_SCRIPT) $< $@
234
Ying Wang09c306c2016-03-15 16:36:29 -0700235else # ! LOCAL_DEX_PREOPT
236$(built_module) : $(my_prebuilt_src_file)
237 $(call copy-file-to-target)
238endif # LOCAL_DEX_PREOPT
239
240else # ! prebuilt_module_is_dex_javalib
Tom Cherryfc977642018-06-13 14:51:05 -0700241ifneq ($(filter init%rc,$(notdir $(LOCAL_INSTALLED_MODULE)))$(filter %/etc/init,$(dir $(LOCAL_INSTALLED_MODULE))),)
242 $(eval $(call copy-init-script-file-checked,$(my_prebuilt_src_file),$(built_module)))
243else ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
Colin Crosse18cb932014-02-13 15:04:18 -0800244$(built_module) : $(my_prebuilt_src_file)
245 $(transform-prebuilt-to-target-strip-comments)
246else
Tom Cherryfc977642018-06-13 14:51:05 -0700247$(built_module) : $(my_prebuilt_src_file)
Colin Crosse18cb932014-02-13 15:04:18 -0800248 $(transform-prebuilt-to-target)
Colin Crosse18cb932014-02-13 15:04:18 -0800249endif
Dan Willemsen7fe992c2016-03-02 13:54:51 -0800250ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
Dan Willemsen08420cb2016-03-01 22:04:57 -0800251 $(hide) chmod +x $@
252endif
Ying Wang09c306c2016-03-15 16:36:29 -0700253endif # ! prebuilt_module_is_dex_javalib
Colin Crosse18cb932014-02-13 15:04:18 -0800254
Ying Wang8c89b4b2016-02-22 15:54:27 -0800255ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
256my_src_jar := $(my_prebuilt_src_file)
Colin Cross941b6822017-03-29 13:53:29 -0700257
258ifdef LOCAL_IS_HOST_MODULE
259# for host java libraries deps should be in the common dir, so we make a copy in
260# the common dir.
261common_classes_jar := $(intermediates.COMMON)/classes.jar
Nan Zhangb3ec5342017-08-31 21:43:04 +0000262common_header_jar := $(intermediates.COMMON)/classes-header.jar
Colin Cross941b6822017-03-29 13:53:29 -0700263
Colin Cross96476c12017-04-06 09:56:19 -0700264$(common_classes_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
Colin Crossd2e778f2017-04-14 15:14:33 -0700265$(common_classes_jar): PRIVATE_PREFIX := $(my_prefix)
Colin Cross941b6822017-03-29 13:53:29 -0700266
267$(common_classes_jar) : $(my_src_jar)
268 $(transform-prebuilt-to-target)
269
Colin Cross7dc90432017-09-26 16:17:24 -0700270ifneq ($(TURBINE_ENABLED),false)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000271$(common_header_jar) : $(my_src_jar)
272 $(transform-prebuilt-to-target)
Colin Cross7dc90432017-09-26 16:17:24 -0700273endif
Nan Zhangb3ec5342017-08-31 21:43:04 +0000274
Colin Cross941b6822017-03-29 13:53:29 -0700275else # !LOCAL_IS_HOST_MODULE
Colin Crosse18cb932014-02-13 15:04:18 -0800276# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
277# 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 -0700278common_classes_jar := $(intermediates.COMMON)/classes.jar
Nan Zhangb3ec5342017-08-31 21:43:04 +0000279common_header_jar := $(intermediates.COMMON)/classes-header.jar
Colin Cross950f1ef2017-04-05 15:30:42 -0700280common_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar
Ying Wange9dd9f22014-10-29 15:48:32 -0700281common_javalib_jar := $(intermediates.COMMON)/javalib.jar
Colin Crosse18cb932014-02-13 15:04:18 -0800282
Colin Crossd2e778f2017-04-14 15:14:33 -0700283$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
284$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_PREFIX := $(my_prefix)
Ying Wange9dd9f22014-10-29 15:48:32 -0700285
Dan Willemsen62dfb592016-07-08 21:33:05 -0700286ifeq ($(LOCAL_SDK_VERSION),system_current)
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700287my_link_type := java:system
Sundong Ahn5a44d1f2017-10-16 19:20:34 +0900288else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
289my_link_type := java:system
Jiyong Park5ebca302018-01-31 00:14:55 +0900290else ifeq ($(LOCAL_SDK_VERSION),core_current)
291my_link_type := java:core
Dan Willemsen62dfb592016-07-08 21:33:05 -0700292else ifneq ($(LOCAL_SDK_VERSION),)
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700293my_link_type := java:sdk
Dan Willemsen62dfb592016-07-08 21:33:05 -0700294else
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700295my_link_type := java:platform
Dan Willemsen62dfb592016-07-08 21:33:05 -0700296endif
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700297
298# TODO: check dependencies of prebuilt files
299my_link_deps :=
300
301my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
302my_common := COMMON
303include $(BUILD_SYSTEM)/link_type.mk
Dan Willemsen62dfb592016-07-08 21:33:05 -0700304
Ying Wang09c306c2016-03-15 16:36:29 -0700305ifeq ($(prebuilt_module_is_dex_javalib),true)
306# For prebuilt shared Java library we don't have classes.jar.
307$(common_javalib_jar) : $(my_src_jar)
308 $(transform-prebuilt-to-target)
309
310else # ! prebuilt_module_is_dex_javalib
311
Ying Wangdd71c852015-12-04 13:59:18 -0800312my_src_aar := $(filter %.aar, $(my_prebuilt_src_file))
313ifneq ($(my_src_aar),)
Ying Wange9dd9f22014-10-29 15:48:32 -0700314# This is .aar file, archive of classes.jar and Android resources.
Jeff Gastondb6557e2018-02-27 14:05:40 -0500315
316# run Jetifier if needed
317LOCAL_JETIFIER_INPUT_FILE := $(my_src_aar)
318include $(BUILD_SYSTEM)/jetifier.mk
319my_src_aar := $(LOCAL_JETIFIER_OUTPUT_FILE)
320
Ying Wange9dd9f22014-10-29 15:48:32 -0700321my_src_jar := $(intermediates.COMMON)/aar/classes.jar
Dan Willemsen1d646232017-11-17 13:11:26 -0800322my_src_proguard_options := $(intermediates.COMMON)/aar/proguard.txt
Colin Cross93fbe842018-06-12 14:02:41 -0700323my_src_android_manifest := $(intermediates.COMMON)/aar/AndroidManifest.xml
Ying Wange9dd9f22014-10-29 15:48:32 -0700324
Dan Willemsen1d646232017-11-17 13:11:26 -0800325$(my_src_jar) : .KATI_IMPLICIT_OUTPUTS := $(my_src_proguard_options)
Colin Cross93fbe842018-06-12 14:02:41 -0700326$(my_src_jar) : .KATI_IMPLICIT_OUTPUTS += $(my_src_android_manifest)
Ying Wangdd71c852015-12-04 13:59:18 -0800327$(my_src_jar) : $(my_src_aar)
Dan Willemsen7a1ad6c2017-04-27 23:10:47 -0700328 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) $(dir $@)/res
Ying Wange9dd9f22014-10-29 15:48:32 -0700329 $(hide) unzip -qo -d $(dir $@) $<
330 # Make sure the extracted classes.jar has a new timestamp.
331 $(hide) touch $@
Colin Cross93fbe842018-06-12 14:02:41 -0700332 # Make sure the proguard and AndroidManifest.xml files exist
333 # and have a new timestamp.
Dan Willemsen1d646232017-11-17 13:11:26 -0800334 $(hide) touch $(dir $@)/proguard.txt
Colin Cross93fbe842018-06-12 14:02:41 -0700335 $(hide) touch $(dir $@)/AndroidManifest.xml
Colin Cross8e921792018-06-07 16:44:07 -0700336
337my_prebuilt_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
338$(eval $(call copy-one-file,$(my_src_android_manifest),$(my_prebuilt_android_manifest)))
339$(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_prebuilt_android_manifest))
340
Jeff Gastondb6557e2018-02-27 14:05:40 -0500341else
342
343# run Jetifier if needed
344LOCAL_JETIFIER_INPUT_FILE := $(my_src_jar)
345include $(BUILD_SYSTEM)/jetifier.mk
346my_src_jar := $(LOCAL_JETIFIER_OUTPUT_FILE)
Ying Wange9dd9f22014-10-29 15:48:32 -0700347
Ying Wange9dd9f22014-10-29 15:48:32 -0700348endif
Ying Wang09c306c2016-03-15 16:36:29 -0700349
Dan Willemsen7f016152016-02-29 17:52:39 -0800350$(common_classes_jar) : $(my_src_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800351 $(transform-prebuilt-to-target)
352
Colin Cross7dc90432017-09-26 16:17:24 -0700353ifneq ($(TURBINE_ENABLED),false)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000354$(common_header_jar) : $(my_src_jar)
355 $(transform-prebuilt-to-target)
Colin Cross7dc90432017-09-26 16:17:24 -0700356endif
Nan Zhangb3ec5342017-08-31 21:43:04 +0000357
Colin Cross950f1ef2017-04-05 15:30:42 -0700358$(common_classes_pre_proguard_jar) : $(my_src_jar)
359 $(transform-prebuilt-to-target)
360
Dan Willemsen7f016152016-02-29 17:52:39 -0800361$(common_javalib_jar) : $(common_classes_jar)
Colin Crosse18cb932014-02-13 15:04:18 -0800362 $(transform-prebuilt-to-target)
363
Colin Cross20299032018-05-09 13:29:51 -0700364include $(BUILD_SYSTEM)/force_aapt2.mk
365
Dan Willemsenbb6393c2017-11-17 15:39:52 -0800366ifdef LOCAL_AAPT2_ONLY
367LOCAL_USE_AAPT2 := true
368endif
369
Colin Cross20299032018-05-09 13:29:51 -0700370ifeq ($(LOCAL_USE_AAPT2),true)
Ying Wangdd71c852015-12-04 13:59:18 -0800371ifneq ($(my_src_aar),)
Dan Willemsen1d646232017-11-17 13:11:26 -0800372
373$(intermediates.COMMON)/export_proguard_flags : $(my_src_proguard_options)
374 $(transform-prebuilt-to-target)
375
Dan Willemsen470e0e12017-04-27 22:28:06 -0700376LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
377ifeq ($(LOCAL_SDK_RES_VERSION),)
378 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
379endif
380
381framework_res_package_export :=
Dan Willemsen470e0e12017-04-27 22:28:06 -0700382# Please refer to package.mk
383ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
384ifneq ($(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))),)
385framework_res_package_export := \
Anton Hansson66d47b82018-04-27 14:11:17 +0100386 $(call resolve-prebuilt-sdk-jar-path,$(LOCAL_SDK_RES_VERSION))
Dan Willemsen470e0e12017-04-27 22:28:06 -0700387else
388framework_res_package_export := \
389 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
Dan Willemsen470e0e12017-04-27 22:28:06 -0700390endif
391endif
392
Ying Wange295c3d2016-02-24 14:11:55 -0800393my_res_package := $(intermediates.COMMON)/package-res.apk
394
395# We needed only very few PRIVATE variables and aapt2.mk input variables. Reset the unnecessary ones.
396$(my_res_package): PRIVATE_AAPT2_CFLAGS :=
Dan Willemsene3c99012017-10-05 13:22:30 -0700397$(my_res_package): PRIVATE_AAPT_FLAGS := --static-lib --no-static-lib-packages --auto-add-overlay
Colin Cross93fbe842018-06-12 14:02:41 -0700398$(my_res_package): PRIVATE_ANDROID_MANIFEST := $(my_src_android_manifest)
Dan Willemsen470e0e12017-04-27 22:28:06 -0700399$(my_res_package): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
Ying Wange295c3d2016-02-24 14:11:55 -0800400$(my_res_package): PRIVATE_SOURCE_INTERMEDIATES_DIR :=
401$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE :=
402$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
403$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
Adam Lesinskie758f932016-02-26 11:13:43 -0800404$(my_res_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
405$(my_res_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
406$(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS :=
Colin Cross65c7cdf2018-02-20 14:31:33 -0800407$(my_res_package) : $(framework_res_package_export)
Colin Cross93fbe842018-06-12 14:02:41 -0700408$(my_res_package) : $(my_src_android_manifest)
Ying Wange295c3d2016-02-24 14:11:55 -0800409
410full_android_manifest :=
411my_res_resources :=
412my_overlay_resources :=
Dan Willemsen48845252017-04-27 21:25:34 -0700413my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res
Ying Wange295c3d2016-02-24 14:11:55 -0800414R_file_stamp :=
415proguard_options_file :=
416my_generated_res_dirs := $(intermediates.COMMON)/aar/res
417my_generated_res_dirs_deps := $(my_src_jar)
418include $(BUILD_SYSTEM)/aapt2.mk
419
420# Make sure my_res_package is created when you run mm/mmm.
421$(built_module) : $(my_res_package)
Ying Wangdd71c852015-12-04 13:59:18 -0800422endif # $(my_src_aar)
Ying Wange295c3d2016-02-24 14:11:55 -0800423endif # LOCAL_USE_AAPT2
Colin Crosse18cb932014-02-13 15:04:18 -0800424# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
425$(built_module) : $(common_javalib_jar)
Ying Wang09c306c2016-03-15 16:36:29 -0700426
Jiyong Park1cf8ee62018-05-22 15:39:59 +0900427my_exported_sdk_libs_file := $(intermediates.COMMON)/exported-sdk-libs
428$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS := $(LOCAL_EXPORT_SDK_LIBRARIES)
429$(my_exported_sdk_libs_file):
430 @echo "Export SDK libs $@"
431 $(hide) mkdir -p $(dir $@) && rm -f $@
Jiyong Parkbe4910a2018-07-14 15:06:48 +0900432 $(if $(PRIVATE_EXPORTED_SDK_LIBS),\
Jiyong Park1cf8ee62018-05-22 15:39:59 +0900433 $(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\
434 $(hide) touch $@)
435
Ying Wang09c306c2016-03-15 16:36:29 -0700436endif # ! prebuilt_module_is_dex_javalib
Ying Wang8c89b4b2016-02-22 15:54:27 -0800437endif # LOCAL_IS_HOST_MODULE is not set
Yohann Rousseld87cc992016-01-19 16:08:34 +0100438
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200439endif # JAVA_LIBRARIES
440
Jaewoong Jung09bfe552019-03-18 14:25:00 -0700441endif # APPS
442
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -0800443$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
Colin Crosse18cb932014-02-13 15:04:18 -0800444
445my_prebuilt_src_file :=
Mathieu Chartier55eabd52017-09-15 13:40:48 -0700446my_preopt_for_extracted_apk :=