blob: 8a0682a9eb3fde5558a9bf2f5284aff2f9932337 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
Ying Wang3bbfddd2014-03-01 15:32:04 -08003# HACK: clear LOCAL_PATH from including last build target before calling
4# intermedites-dir-for
5LOCAL_PATH := $(BUILD_SYSTEM)
6
Bob Badourebdefc02022-02-12 15:39:22 -08007SYSTEM_NOTICE_DEPS :=
8VENDOR_NOTICE_DEPS :=
9UNMOUNTED_NOTICE_DEPS :=
Justin Yundd15ec12022-09-23 10:47:21 +090010UNMOUNTED_NOTICE_VENDOR_DEPS :=
Bob Badourebdefc02022-02-12 15:39:22 -080011ODM_NOTICE_DEPS :=
12OEM_NOTICE_DEPS :=
13PRODUCT_NOTICE_DEPS :=
14SYSTEM_EXT_NOTICE_DEPS :=
15VENDOR_DLKM_NOTICE_DEPS :=
16ODM_DLKM_NOTICE_DEPS :=
17SYSTEM_DLKM_NOTICE_DEPS :=
18
The Android Open Source Project88b60792009-03-03 19:28:42 -080019# -----------------------------------------------------------------
Joe Onorato964f4012023-05-06 12:29:01 -070020# Release Config Flags
21
22# Create a summary file of build flags for each partition
23# $(1): build flags json file
24# $(2): flag names
25define generate-partition-build-flag-file
26$(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1)))
27$(eval $(strip $(1)): PRIVATE_FLAG_NAMES := $(strip $(2)))
28$(strip $(1)):
29 mkdir -p $$(dir $$(PRIVATE_OUT))
30 ( \
31 echo '{' ; \
32 echo 'flags: [' ; \
33 $$(foreach flag, $$(PRIVATE_FLAG_NAMES), \
34 printf ' { "name": "%s", "value": "%s", ' \
35 '$$(flag)' \
36 '$$(_ALL_RELEASE_FLAGS.$$(flag).VALUE)' \
37 ; \
38 printf '"set": "%s", "default": "%s", "declared": "%s", }' \
39 '$$(_ALL_RELEASE_FLAGS.$$(flag).SET_IN)' \
40 '$$(_ALL_RELEASE_FLAGS.$$(flag).DEFAULT)' \
41 '$$(_ALL_RELEASE_FLAGS.$$(flag).DECLARED_IN)' \
42 ; \
43 printf '$$(if $$(filter $$(lastword $$(PRIVATE_FLAG_NAMES)),$$(flag)),,$$(comma))\n' ; \
44 ) \
45 echo "]" ; \
46 echo "}" \
47 ) >> $$(PRIVATE_OUT)
48endef
49
50$(foreach partition, $(_FLAG_PARTITIONS), \
51 $(eval BUILD_FLAG_SUMMARIES.$(partition) \
52 := $(TARGET_OUT_FLAGS)/$(partition)/etc/build_flags.json) \
53 $(eval $(call generate-partition-build-flag-file, \
54 $(BUILD_FLAG_SUMMARIES.$(partition)), \
55 $(_ALL_RELEASE_FLAGS.PARTITIONS.$(partition)) \
56 ) \
57 ) \
58)
59
60# TODO: Remove
61.PHONY: flag-files
62flag-files: $(foreach partition, $(_FLAG_PARTITIONS), \
63 $(TARGET_OUT_FLAGS)/$(partition)/etc/build_flags.json)
64
65# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -080066# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -070067# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080068# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
69# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080070# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070071# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070072#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070073#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070074define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070075$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
76 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080077 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
78$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
79 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
80 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
81 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
82 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
83 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
84 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
85 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
86 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
87 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
88 use vintf_compatibility_matrix / vintf_fragments instead!)) \
89 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
90 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
91 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
92 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
93 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
94 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
95 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
96 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
97 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
98)
Ying Wang68864102011-09-29 13:23:25 -070099endef
Yo Chiang0b49c032020-03-17 17:49:49 +0800100
Yo Chiang336883a2020-05-14 17:17:29 +0800101# Phony target to check PRODUCT_COPY_FILES copy pairs don't contain ELF files
102.PHONY: check-elf-prebuilt-product-copy-files
103check-elf-prebuilt-product-copy-files:
104
Yo Chiang0b49c032020-03-17 17:49:49 +0800105check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +0800106ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
107check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +0800108endif
109check_elf_prebuilt_product_copy_files_hint := \
110 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
111
Ying Wang619fccf2012-09-05 18:08:29 -0700112# filter out the duplicate <source file>:<dest file> pairs.
113unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800114$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -0700115 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
116 $(eval unique_product_copy_files_pairs += $(cf))))
117unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -0800118product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -0700119$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -0700120 $(eval _src := $(call word-colon,1,$(cf))) \
121 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -0700122 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -0800123 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -0800124 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -0700125 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -0700126 $(if $(filter %.xml,$(_dest)),\
127 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +0100128 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
129 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -0700130 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
131 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +0800132 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
133 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
134 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
135 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -0700136 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -0800137
138# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -0700139pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
140$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
141$(pcf_ignored_file):
142 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -0800143
Bob Badour5acd4362022-04-12 18:31:35 -0700144$(call declare-0p-target,$(pcf_ignored_file))
145
Bill Peckham315b98a2021-06-15 19:35:06 -0700146$(call dist-for-goals,droidcore-unbundled,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
Dan Willemsen7537fd02018-10-16 23:15:08 -0700147
148pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -0800149product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -0700150unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -0700151unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152
153# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800154# Returns the max allowed size for an image suitable for hash verification
155# (e.g., boot.img, recovery.img, etc).
156# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
157# $(1): partition size to flash the image
158define get-hash-image-max-size
159$(if $(1), \
160 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
161 $(eval _hash_meta_size := 69632), \
162 $(eval _hash_meta_size := 0)) \
163 $(1)-$(_hash_meta_size))
164endef
165
166# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800167# Define rules to copy headers defined in copy_headers.mk
168# If more than one makefile declared a header, print a warning,
169# then copy the last one defined. This matches the previous make
170# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700171has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800172$(foreach dest,$(ALL_COPIED_HEADERS), \
173 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800174 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800175 $(if $(call streq,$(_src),$(_srcs)),, \
176 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800177 $(warning _ Using $(_src)) \
178 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
179 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
180 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
181 $(warning _ Ignoring $(src)) \
182 $(warning __ from $(firstword $(_makefiles))) \
183 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
184 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800185 $(eval $(call copy-one-header,$(_src),$(dest))))
186all_copied_headers: $(ALL_COPIED_HEADERS)
187
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700188ifdef has_dup_copy_headers
189 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700190 $(error duplicate header copies are no longer allowed. For more information about headers, see: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers)
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700191endif
192
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800193$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
194
Dan Willemsen6f60f022016-02-23 13:40:07 -0800195# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800196# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100197ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800198gen := $(OUT_DOCS)/index.html
199ALL_DOCS += $(gen)
200$(gen): frameworks/base/docs/docs-redirect-index.html
201 @mkdir -p $(dir $@)
202 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700203endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800204
Dan Albert303e6032017-10-04 10:20:20 -0700205ndk_doxygen_out := $(OUT_NDK_DOCS)
206ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
207ndk_docs_src_dir := frameworks/native/docs
208ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
209ifneq ($(wildcard $(ndk_docs_src_dir)),)
210ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
211 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
212$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
213 @mkdir -p $(ndk_doxygen_out)
214 @echo "Generating NDK docs to $(ndk_doxygen_out)"
215 @( cat $(ndk_doxyfile); \
216 echo "INPUT=$(ndk_headers)"; \
217 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
218 ) | doxygen -
219
Bob Badour5acd4362022-04-12 18:31:35 -0700220$(call declare-1p-target,$(ndk_doxygen_out)/index.html,)
221
Dan Albert303e6032017-10-04 10:20:20 -0700222# Note: Not a part of the docs target because we don't have doxygen available.
223# You can run this target locally if you have doxygen installed.
224ndk-docs: $(ndk_doxygen_out)/index.html
225.PHONY: ndk-docs
226endif
227
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700228ifeq ($(HOST_OS),linux)
Colin Crossd60401a2019-04-18 14:46:48 -0700229$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Spandan Das10cd8572023-02-14 21:26:55 +0000230$(call dist-for-goals,droidcore,$(API_FINGERPRINT))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700231endif
Dan Willemsenad6a1542018-12-14 01:04:19 -0800232
Andres Moralesb8876e12015-05-06 20:44:22 -0700233INSTALLED_RECOVERYIMAGE_TARGET :=
Yifan Hong881df392020-10-09 14:29:39 -0700234# Build recovery image if
235# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
236# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
237# with recovery resources.
238# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
239# but not the final recovery image.
Chris Grossa784ef12019-04-22 11:09:57 -0700240ifdef BUILDING_RECOVERY_IMAGE
241ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong881df392020-10-09 14:29:39 -0700242ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -0700243INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
244endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700245endif
Yifan Hong881df392020-10-09 14:29:39 -0700246endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700247
Jiyong Parke1346862020-05-18 14:31:30 +0900248include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100249
250# ----------------------------------------------------------------
251
252# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800253# sdk-build.prop
254#
255# There are certain things in build.prop that we don't want to
256# ship with the sdk; remove them.
257
258# This must be a list of entire property keys followed by
259# "=" characters, without any internal spaces.
260sdk_build_prop_remove := \
261 ro.build.user= \
262 ro.build.host= \
263 ro.product.brand= \
264 ro.product.manufacturer= \
265 ro.product.device=
266# TODO: Remove this soon-to-be obsolete property
267sdk_build_prop_remove += ro.build.product=
268INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
269$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
270 @echo SDK buildinfo: $@
271 @mkdir -p $(dir $@)
272 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000273 $(sdk_build_prop_remove)))" $< > $@.tmp
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700274 $(hide) for x in $(strip $(sdk_build_prop_remove)); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000275 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800276 $(hide) mv $@.tmp $@
277
Bob Badour5acd4362022-04-12 18:31:35 -0700278$(call declare-0p-target,$(INSTALLED_SDK_BUILD_PROP_TARGET))
279
The Android Open Source Project88b60792009-03-03 19:28:42 -0800280# -----------------------------------------------------------------
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800281# declare recovery ramdisk files
282ifeq ($(BUILDING_RECOVERY_IMAGE),true)
283INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
284endif
285
286# -----------------------------------------------------------------
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800287# Declare vendor ramdisk fragments
288INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
289
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800290ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
291 ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
292 $(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \
293 BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set)
294 endif
295 INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery
296 VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT)
297 VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
298 BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY
299 .KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR
300endif
301
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800302# Validation check and assign default --ramdisk_type.
303$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
304 $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
305 $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
306 $(error Must not specify KERNEL_MODULE_DIRS for prebuilt vendor ramdisk fragment "$(vendor_ramdisk_fragment)": $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS))) \
307 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
308 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
309 $(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
310 $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
311 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
312)
313
314# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
315$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
316 $(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
317 $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
318 $(if $($(kmd_vrf)),$(error Kernel module directory "$(kmd)" belongs to multiple vendor ramdisk fragments: "$($(kmd_vrf))" "$(vendor_ramdisk_fragment)", each kernel module directory should belong to exactly one or none vendor ramdisk fragment)) \
319 $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
320 ) \
321)
322INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
323
Yi-Yo Chiang378b7792021-04-09 20:09:13 +0800324# Strip the list in case of any whitespace.
325INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \
326 $(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS))
327
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800328# Assign --ramdisk_name for each vendor ramdisk fragment.
329$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
330 $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
331 $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
332 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
333 $(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
334)
335
336# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700337# kernel modules
338
339# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
340DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
341
J. Avilaa2ceec62020-05-12 23:40:02 +0000342define copy-and-strip-kernel-module
343$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000344 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000345endef
346
Colin Cross4f60e362019-06-05 11:53:43 -0700347# $(1): modules list
348# $(2): output dir
349# $(3): mount point
350# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700351# $(5): module load list
352# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800353# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000354# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700355# $(9): module directory name
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800356# $(10): extra modules that might be dependency of modules in this partition, but should not be copied to output dir
357# $(11): mount point for extra modules
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800358# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700359define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700360 $(if $(9), \
361 $(eval _dir := $(9)/), \
362 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000363 $(foreach module,$(1), \
364 $(eval _src := $(module)) \
365 $(if $(8), \
366 $(eval _src := $(8)/$(notdir $(module))) \
367 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700368 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800369 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9),$(10),$(11))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700370 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
371 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
372 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
373 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700374endef
375
376# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700377# $(2): mount point
378# $(3): staging dir
379# $(4): module load list
380# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800381# $(6): module archive
382# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700383# $(8): module directory name
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800384# $(9): extra modules which should not be copied to output dir, but might be dependency of modules in this partition
385# $(10): mount point for extra modules
Steve Muckle810a0ba2019-11-13 13:29:02 -0800386# TODO(b/144844424): If a module archive is being used, this step (which
387# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
388# the output directory. This should be moved to a module with a
389# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
390# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700391define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700392$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: .KATI_IMPLICIT_OUTPUTS := $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.alias $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle474e4d02019-06-19 12:56:48 -0700393$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700394$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800395$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MODULES := $(strip $(9))
Steve Muckle474e4d02019-06-19 12:56:48 -0700396$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800397$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MOUNT_POINT := $(10)
Steve Muckle2335d762020-05-28 18:39:38 -0700398$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800399$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(10)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700400$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700401$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
Steve Muckle474e4d02019-06-19 12:56:48 -0700402$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800403$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
404$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
405$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700406 @echo depmod $$(PRIVATE_STAGING_DIR)
407 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700408 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800409 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700410 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800411 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700412 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800413 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
414 )
415 $(if $(1),\
416 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
417 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
418 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
419 done; \
420 )
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800421 # The ln -sf + find -delete sequence is to remove any modules in
422 # PRIVATE_EXTRA_MODULES which have same basename as MODULES in PRIVATE_MODULES
423 # Basically, it computes a set difference. When there is a duplicate module
424 # present in both directories, we want modules in PRIVATE_MODULES to take
425 # precedence. Since depmod does not provide any guarantee about ordering of
426 # dependency resolution, we achieve this by maually removing any duplicate
427 # modules with lower priority.
428 $(if $(9),\
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800429 mkdir -p $$(PRIVATE_EXTRA_MODULE_DIR); \
Kelvin Zhang21b6cad2022-12-06 16:03:30 -0800430 find $$(PRIVATE_EXTRA_MODULE_DIR) -maxdepth 1 -type f -name "*.ko" -delete; \
431 cp $$(PRIVATE_EXTRA_MODULES) $$(PRIVATE_EXTRA_MODULE_DIR); \
432 ln -sf $$(PRIVATE_MODULE_DIR)/*.ko $$(PRIVATE_EXTRA_MODULE_DIR); \
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800433 find $$(PRIVATE_EXTRA_MODULE_DIR) -type l -delete; \
434 )
Colin Cross4f60e362019-06-05 11:53:43 -0700435 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
436 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700437 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
438 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700439endef
440
Steve Muckle474e4d02019-06-19 12:56:48 -0700441# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700442# $(2): modules list
443# $(3): module load list
444# $(4): module load list filename
445# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700446define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700447 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
448 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700449endef
450
451# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700452# $(2): modules list
453# $(3): module load list
454# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700455define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700456$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
457$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
458 @echo load-list $$(@)
459 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700460endef
461
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800462# $(1): source options file
463# $(2): destination pathname
464# Returns a build rule that checks the syntax of and installs a kernel modules
465# options file. Strip and squeeze any extra space and blank lines.
466# For use via $(eval).
467define build-image-kernel-modules-options-file
468$(2): $(1)
469 @echo "libmodprobe options $$(@)"
470 $(hide) mkdir -p "$$(dir $$@)"
471 $(hide) rm -f "$$@"
472 $(hide) awk <"$$<" >"$$@" \
473 '/^#/ { print; next } \
474 NF == 0 { next } \
475 NF < 2 || $$$$1 != "options" \
476 { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
477 exit_status = 1; next } \
478 { $$$$1 = $$$$1; print } \
479 END { exit exit_status }'
480endef
481
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800482# $(1): source blocklist file
483# $(2): destination pathname
484# Returns a build rule that checks the syntax of and installs a kernel modules
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800485# blocklist file. Strip and squeeze any extra space and blank lines.
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800486# For use via $(eval).
487define build-image-kernel-modules-blocklist-file
488$(2): $(1)
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800489 @echo "libmodprobe blocklist $$(@)"
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800490 $(hide) mkdir -p "$$(dir $$@)"
491 $(hide) rm -f "$$@"
492 $(hide) awk <"$$<" >"$$@" \
493 '/^#/ { print; next } \
494 NF == 0 { next } \
495 NF != 2 || $$$$1 != "blocklist" \
496 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
497 exit_status = 1; next } \
498 { $$$$1 = $$$$1; print } \
499 END { exit exit_status }'
500endef
501
Steve Muckle2335d762020-05-28 18:39:38 -0700502# $(1): image name
503# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
504# $(3): mount point
505# $(4): module load filename
506# $(5): stripped staging directory
507# $(6): kernel module directory name (top is an out of band value for no directory)
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800508# $(7): list of extra modules that might be dependency of modules in this partition
509# $(8): mount point for extra modules. e.g. system
510
Steve Muckle2335d762020-05-28 18:39:38 -0700511define build-image-kernel-modules-dir
512$(if $(filter top,$(6)),\
513 $(eval _kver :=)$(eval _sep :=),\
514 $(eval _kver := $(6))$(eval _sep :=_))\
515$(if $(5),\
516 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
517 $(eval _stripped_staging_dir :=))\
518$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
519 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
520 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Kelvin Zhangb66b11e2022-12-05 13:04:42 -0800521 $(if $(filter false,$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver))),\
522 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) :=),) \
Wei Li49933362023-01-04 17:13:47 -0800523 $(eval _files := $(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver),$(7),$(8))) \
524 $(call copy-many-files,$(_files)) \
525 $(eval _modules := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)) ANDROID-GEN ANDROID-GEN ANDROID-GEN ANDROID-GEN) \
526 $(eval KERNEL_MODULE_COPY_FILES += $(join $(addsuffix :,$(_modules)),$(_files)))) \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800527$(if $(_kver), \
528 $(eval _dir := $(_kver)/), \
529 $(eval _dir :=)) \
530$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
531 $(eval $(call build-image-kernel-modules-options-file, \
532 $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
533 $(2)/lib/modules/$(_dir)modules.options)) \
534 $(2)/lib/modules/$(_dir)modules.options) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800535$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
536 $(eval $(call build-image-kernel-modules-blocklist-file, \
537 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800538 $(2)/lib/modules/$(_dir)modules.blocklist)) \
Wei Li49933362023-01-04 17:13:47 -0800539 $(eval ALL_KERNEL_MODULES_BLOCKLIST += $(2)/lib/modules/$(_dir)modules.blocklist) \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800540 $(2)/lib/modules/$(_dir)modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700541endef
542
543# $(1): kernel module directory name (top is an out of band value for no directory)
544define build-recovery-as-boot-load
545$(if $(filter top,$(1)),\
546 $(eval _kver :=)$(eval _sep :=),\
547 $(eval _kver := $(1))$(eval _sep :=_))\
548 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
549 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,ramdisk_module_list$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load,$(TARGET_RECOVERY_ROOT_OUT))))
550endef
551
552# $(1): kernel module directory name (top is an out of band value for no directory)
553define build-vendor-ramdisk-recovery-load
554$(if $(filter top,$(1)),\
555 $(eval _kver :=)$(eval _sep :=),\
556 $(eval _kver := $(1))$(eval _sep :=_))\
557 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
558 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_RAMDISK_OUT))))
559endef
560
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700561# $(1): kernel module directory name (top is an out of band value for no directory)
Isaac J. Manjarres3a7fe912023-01-25 17:28:59 -0800562define build-vendor-kernel-ramdisk-recovery-load
563$(if $(filter top,$(1)),\
564 $(eval _kver :=)$(eval _sep :=),\
565 $(eval _kver := $(1))$(eval _sep :=_))\
566 $(if $(BOARD_VENDOR_KERNEL_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
567 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_kernel_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_KERNEL_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_KERNEL_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_KERNEL_RAMDISK_OUT))))
568endef
569
570# $(1): kernel module directory name (top is an out of band value for no directory)
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700571define build-vendor-charger-load
572$(if $(filter top,$(1)),\
573 $(eval _kver :=)$(eval _sep :=),\
574 $(eval _kver := $(1))$(eval _sep :=_))\
575 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
576 $(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_OUT_VENDOR))))
577endef
578
Steve Mucklee1b10862019-07-10 10:49:37 -0700579ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
580 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
581 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700582 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700583 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
584endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700585
Steve Muckle69280d22019-07-11 12:23:38 -0700586ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
587 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700588endif
589
Steve Mucklee1b10862019-07-10 10:49:37 -0700590ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700591 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700592 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700593 endif
594endif
595
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800596ifneq ($(BOARD_DO_NOT_STRIP_RECOVERY_MODULES),true)
597 RECOVERY_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery_stripped)
598else
599 RECOVERY_STRIPPED_MODULE_STAGING_DIR :=
600endif
601
J. Avilaa2ceec62020-05-12 23:40:02 +0000602ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
603 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
604else
605 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
606endif
Colin Cross4f60e362019-06-05 11:53:43 -0700607
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700608ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
609 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
610else
611 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
612endif
613
Lucas Weif57333f2022-02-24 10:30:15 +0800614ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_KERNEL_RAMDISK_MODULES),true)
615 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_kernel_ramdisk_stripped)
616else
617 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
618endif
619
Steve Muckle2335d762020-05-28 18:39:38 -0700620BOARD_KERNEL_MODULE_DIRS += top
Kelvin Zhang395d3df2022-12-07 10:36:10 -0800621
622# Default to not generating modules.dep for kernel modules on system
623# side. We should only load these modules if they are depended by vendor
624# side modules.
625ifeq ($(BOARD_SYSTEM_KERNEL_MODULES_LOAD),)
626 BOARD_SYSTEM_KERNEL_MODULES_LOAD := false
627endif
628
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800629$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800630 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,$(RECOVERY_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800631 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800632 $(if $(vendor_ramdisk_fragment), \
633 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
634 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
635 $(eval ### else ###), \
636 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
637 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800638 $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
Lucas Weif57333f2022-02-24 10:30:15 +0800639 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_KERNEL_RAMDISK,$(TARGET_VENDOR_KERNEL_RAMDISK_OUT),,modules.load,$(VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800640 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
Isaac J. Manjarres3a7fe912023-01-25 17:28:59 -0800641 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-kernel-ramdisk-recovery-load,$(kmd))) \
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800642 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(kmd),$(BOARD_SYSTEM_KERNEL_MODULES),system)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800643 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
644 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(kmd))) \
Ramji Jiyani49b70b62022-12-01 00:55:10 +0000645 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,SYSTEM,$(if $(filter true,$(BOARD_USES_SYSTEM_DLKMIMAGE)),$(TARGET_OUT_SYSTEM_DLKM),$(TARGET_OUT_SYSTEM)),system,modules.load,,$(kmd))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700646 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800647 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
648 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(kmd)))))
Colin Cross4f60e362019-06-05 11:53:43 -0700649
Kelvin Zhang0dbfd702023-01-31 10:47:48 -0800650ifeq ($(BOARD_SYSTEM_KERNEL_MODULES),)
651ifneq ($(BOARD_SYSTEM_DLKM_SRC),)
652ifneq ($(wildcard $(BOARD_SYSTEM_DLKM_SRC)/*),)
Kelvin Zhang19961b52023-02-14 14:30:48 -0800653 SYSTEM_KERNEL_MODULES := $(shell find $(BOARD_SYSTEM_DLKM_SRC) -type f)
654 SRC_SYSTEM_KERNEL_MODULES := $(SYSTEM_KERNEL_MODULES)
655 DST_SYSTEM_KERNEL_MODULES := $(patsubst $(BOARD_SYSTEM_DLKM_SRC)/%,:$(TARGET_OUT_SYSTEM_DLKM)/%,$(SRC_SYSTEM_KERNEL_MODULES))
Kelvin Zhang0dbfd702023-01-31 10:47:48 -0800656 SYSTEM_KERNEL_MODULE_COPY_PAIRS := $(join $(SRC_SYSTEM_KERNEL_MODULES),$(DST_SYSTEM_KERNEL_MODULES))
657 ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(SYSTEM_KERNEL_MODULE_COPY_PAIRS))
658endif
659endif
660endif
661
662
Colin Cross4f60e362019-06-05 11:53:43 -0700663# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800664# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700665# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900666# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700667# $2 certificate
668# $3 private key
669# $4 compressed
670# $5 partition tag
671# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100672define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700673$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
674$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
675$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
676$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700677
678endef
679
Jaewoong Jung704b4542020-06-29 19:37:53 -0700680# -----------------------------------------------------------------
681# Merge an individual apkcerts output into the final apkcerts.txt output.
682# Use a macro to make it compatible with _apkcerts_write_line
683# $1 apkcerts file to be merged
684# $2 output file
685define _apkcerts_merge
686$(hide) cat $1 >> $2
687
688endef
689
The Android Open Source Project88b60792009-03-03 19:28:42 -0800690name := $(TARGET_PRODUCT)
691ifeq ($(TARGET_BUILD_TYPE),debug)
692 name := $(name)_debug
693endif
694name := $(name)-apkcerts-$(FILE_NAME_TAG)
695intermediates := \
696 $(call intermediates-dir-for,PACKAGING,apkcerts)
697APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700698all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
699$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800700# We don't need to really build all the modules.
701# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700702$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800703 @echo APK certs list: $@
704 @mkdir -p $(dir $@)
705 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700706 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700707 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
708 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
709 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700710 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700711 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Victor Hsieh89415a82022-09-09 14:16:33 -0700712 $(if $(filter true,$(PRODUCT_FSVERITY_GENERATE_METADATA)),\
713 $(call _apkcerts_write_line,BuildManifest,$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system,$@) \
714 $(if $(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),\
Victor Hsiehadc94a12022-09-20 11:46:09 -0700715 $(call _apkcerts_write_line,BuildManifestSystemExt,$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system_ext,$@)))
Ying Wangd9a88d52012-10-26 09:21:28 -0700716 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700717 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800718
Bob Badour5acd4362022-04-12 18:31:35 -0700719$(call declare-0p-target,$(APKCERTS_FILE))
720
The Android Open Source Project88b60792009-03-03 19:28:42 -0800721.PHONY: apkcerts-list
722apkcerts-list: $(APKCERTS_FILE)
723
Ying Wang15e487a2011-02-15 10:56:18 -0800724ifneq (,$(TARGET_BUILD_APPS))
725 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900726 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800727endif
Ying Wangefb21682010-07-23 16:42:13 -0700728
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900729
The Android Open Source Project88b60792009-03-03 19:28:42 -0800730# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700731# build system stats
732BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
733$(BUILD_SYSTEM_STATS):
734 @rm -f $@
735 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
736 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700737$(call declare-1p-target,$(BUILD_SYSTEM_STATS),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700738$(call dist-for-goals,droidcore-unbundled,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700739
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700740# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800741# build /product/etc/security/avb/system_other.avbpubkey if needed
742ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800743ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800744INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
745ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800746endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800747endif # BUILDING_SYSTEM_OTHER_IMAGE
748
749# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700750# Modules ready to be converted to Soong, ordered by how many
751# modules depend on them.
752SOONG_CONV := $(sort $(SOONG_CONV))
753SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
754$(SOONG_CONV_DATA):
755 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700756 @$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS))),$(sort $(SOONG_CONV.$(s).MAKEFILES)),$(sort $(SOONG_CONV.$(s).INSTALLED))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700757
Bob Badour5acd4362022-04-12 18:31:35 -0700758$(call declare-1p-target,$(SOONG_CONV_DATA),build)
759
Colin Crossfdea8932017-12-06 14:38:40 -0800760SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700761SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
762$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
763 @rm -f $@
764 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
Bob Badour5acd4362022-04-12 18:31:35 -0700765$(call declare-1p-target,$(SOONG_TO_CONVERT),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700766$(call dist-for-goals,droidcore-unbundled,$(SOONG_TO_CONVERT))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700767
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700768$(PRODUCT_OUT)/product_packages.txt:
769 @rm -f $@
770 echo "" > $@
771 $(foreach x,$(PRODUCT_PACKAGES),echo $(x) >> $@$(newline))
772
Joe Onorato02fb89a2020-06-27 00:10:23 -0700773MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700774PRODUCT_PACKAGES_TXT := $(PRODUCT_OUT)/product_packages.txt
Joe Onorato02fb89a2020-06-27 00:10:23 -0700775MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
776$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700777$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato02fb89a2020-06-27 00:10:23 -0700778 @rm -f $@
779 $(hide) $(MK2BP_CATALOG_SCRIPT) \
780 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700781 --product-packages=$(PRODUCT_PACKAGES_TXT) \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700782 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
783 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700784 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700785 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700786 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700787$(call declare-1p-target,$(MK2BP_REMAINING_HTML),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700788$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_HTML))
Joe Onorato02fb89a2020-06-27 00:10:23 -0700789
Joe Onorato31986072020-08-10 09:58:49 -0700790MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700791$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato31986072020-08-10 09:58:49 -0700792 @rm -f $@
793 $(hide) $(MK2BP_CATALOG_SCRIPT) \
794 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700795 --product-packages=$(PRODUCT_PACKAGES_TXT) \
796 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700797 --mode=csv \
798 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700799$(call declare-1p-target,$(MK2BP_REMAINING_CSV))
Bill Peckham315b98a2021-06-15 19:35:06 -0700800$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_CSV))
Joe Onorato31986072020-08-10 09:58:49 -0700801
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700802# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800803# Modules use -Wno-error, or added default -Wall -Werror
804WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
805$(WALL_WERROR):
806 @rm -f $@
807 echo "# Modules using -Wno-error" >> $@
808 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Yi Kongee99ddf2022-05-19 20:13:55 +0800809 echo "# Modules that allow warnings" >> $@
810 for m in $(sort $(SOONG_MODULES_WARNINGS_ALLOWED) $(MODULES_WARNINGS_ALLOWED)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800811
Bob Badour5acd4362022-04-12 18:31:35 -0700812$(call declare-0p-target,$(WALL_WERROR))
813
Bill Peckham315b98a2021-06-15 19:35:06 -0700814$(call dist-for-goals,droidcore-unbundled,$(WALL_WERROR))
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800815
816# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800817# Modules missing profile files
818PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
819$(PGO_PROFILE_MISSING):
820 @rm -f $@
821 echo "# Modules missing PGO profile files" >> $@
822 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
823
Bob Badour5acd4362022-04-12 18:31:35 -0700824$(call declare-0p-target,$(PGO_PROFILE_MISSING))
825
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800826$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
827
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000828CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
829$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
830 rm -f $@
831 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700832$(call declare-0p-target,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000833$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
834
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800835# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700836# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700837# for future OTA packages installed by this system. Actual product
838# deliverables will be re-signed by hand. We expect this file to
839# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700840DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700841
842
Jeff Browne33ba4c2011-07-11 22:11:46 -0700843# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800844# if they don't do anything.
845.PHONY: systemimage
846systemimage:
847
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800848# -----------------------------------------------------------------
849
850.PHONY: event-log-tags
851
Joe Onoratob7510532010-07-14 10:22:54 -0700852# Produce an event logs tag file for everything we know about, in order
853# to properly allocate numbers. Then produce a file that's filtered
854# for what's going to be installed.
855
856all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
857
Colin Crossdc8f8e42012-04-12 13:25:54 -0700858event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
859
Joe Onoratob7510532010-07-14 10:22:54 -0700860# Include tags from all packages that we know about
861all_event_log_tags_src := \
862 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
863
Dan Willemsena3f66322020-05-28 15:46:33 -0700864$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
865$(all_event_log_tags_file): $(all_event_log_tags_src) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700866 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900867 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700868
Bob Badour5acd4362022-04-12 18:31:35 -0700869$(call declare-0p-target,$(all_event_log_tags_file))
870
Doug Zongkera34fa952011-02-23 12:17:29 -0800871# Include tags from all packages included in this product, plus all
872# tags that are part of the system (ie, not in a vendor/ or device/
873# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800874event_log_tags_src := \
875 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800876 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800877 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800878 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
879 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800880
Dan Willemsena3f66322020-05-28 15:46:33 -0700881$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700882$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700883$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800884 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900885 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800886
Bob Badour2f66fd12022-03-09 17:30:24 -0800887$(eval $(call declare-0p-target,$(event_log_tags_file)))
888
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800889event-log-tags: $(event_log_tags_file)
890
891ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
892
Colin Cross79a76ec2022-03-21 15:06:11 -0700893# Initialize INSTALLED_FILES_OUTSIDE_IMAGES with the list of all device files,
894# files installed in images will be filtered out later.
895INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out \
896 $(PRODUCT_OUT)/apex/% \
Colin Cross41e93ea2022-03-25 17:31:49 -0700897 $(PRODUCT_OUT)/fake_packages/% \
Colin Cross79a76ec2022-03-21 15:06:11 -0700898 $(PRODUCT_OUT)/testcases/%, \
899 $(filter $(PRODUCT_OUT)/%,$(ALL_DEFAULT_INSTALLED_MODULES)))
Joe Onoratob7510532010-07-14 10:22:54 -0700900
The Android Open Source Project88b60792009-03-03 19:28:42 -0800901# #################################################################
902# Targets for boot/OS images
903# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800904ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
905 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000906 ifdef BOARD_PREBUILT_BOOTLOADER
907 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
908 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
909 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800910 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
911 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
912 else
913 INSTALLED_2NDBOOTLOADER_TARGET :=
914 endif
915else
916 INSTALLED_BOOTLOADER_MODULE :=
917 INSTALLED_2NDBOOTLOADER_TARGET :=
918endif # TARGET_NO_BOOTLOADER
919ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700920 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
921 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
922 $(PRODUCT_OUT)/$(k))
923 else
924 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
925 endif
Ying Wangc6349742014-01-13 16:14:20 -0800926else
927 INSTALLED_KERNEL_TARGET :=
928endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929
930# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700931# the root dir
Colin Cross79a76ec2022-03-21 15:06:11 -0700932INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_ROOT_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Tom Cherryd14b8952018-08-09 14:26:00 -0700933INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800934 $(ALL_DEFAULT_INSTALLED_MODULES))
935
Colin Cross79a76ec2022-03-21 15:06:11 -0700936
Luis Hector Chavezff489932018-07-03 15:41:40 -0700937INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
938INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
939$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700940$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700941 @echo Installed file list: $@
SzuWei Linc230b0b2021-12-30 13:48:01 +0800942 mkdir -p $(TARGET_ROOT_OUT)
Petri Gynther728e0bd2021-03-06 13:29:28 -0800943 mkdir -p $(dir $@)
944 rm -f $@
945 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
946 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700947
Bob Badoure9bdbc52022-03-10 11:31:07 -0800948$(call declare-0p-target,$(INSTALLED_FILES_FILE_ROOT))
Bob Badour5acd4362022-04-12 18:31:35 -0700949$(call declare-0p-target,$(INSTALLED_FILES_JSON_ROOT))
Bob Badoure9bdbc52022-03-10 11:31:07 -0800950
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800951#------------------------------------------------------------------
952# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700953ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800954INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700955ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800956$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800957 cat $^ > $@
958endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700959endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800960
Tom Cherryd14b8952018-08-09 14:26:00 -0700961# -----------------------------------------------------------------
962# the ramdisk
Colin Cross79a76ec2022-03-21 15:06:11 -0700963INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -0800964ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700965INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
Tom Cherryd14b8952018-08-09 14:26:00 -0700966 $(ALL_DEFAULT_INSTALLED_MODULES))
967
968INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
969INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
970$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700971$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700972 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800973 mkdir -p $(TARGET_RAMDISK_OUT)
974 mkdir -p $(dir $@)
975 rm -f $@
976 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
977 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700978
Bob Badourebdefc02022-02-12 15:39:22 -0800979$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -0700980$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -0800981
Joe Onorato64d85d02009-04-09 19:31:12 -0700982BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
983
J. Avila3f6560e2020-05-11 20:20:03 +0000984ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
985# -l enables the legacy format used by the Linux kernel
986COMPRESSION_COMMAND_DEPS := $(LZ4)
987COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
988RAMDISK_EXT := .lz4
989else
990COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
991COMPRESSION_COMMAND := $(MINIGZIP)
992RAMDISK_EXT := .gz
993endif
994
Vincent Donnefort4a5fd832022-12-22 13:48:55 +0000995# This file contains /dev nodes description added to the generic ramdisk
996RAMDISK_NODE_LIST := $(PRODUCT_OUT)/ramdisk_node_list
997
Joe Onorato64d85d02009-04-09 19:31:12 -0700998# We just build this directly to the install location.
999INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Inseob Kimadcdb2f2021-06-11 12:55:10 +09001000$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
Vincent Donnefort4a5fd832022-12-22 13:48:55 +00001001$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(RAMDISK_NODE_LIST) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08001002 $(call pretty,"Target ramdisk: $@")
Inseob Kimadcdb2f2021-06-11 12:55:10 +09001003 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
1004ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
1005 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
1006endif
Vincent Donnefort4a5fd832022-12-22 13:48:55 +00001007 $(hide) $(MKBOOTFS) -n $(RAMDISK_NODE_LIST) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08001008
Bob Badourebdefc02022-02-12 15:39:22 -08001009$(call declare-1p-container,$(INSTALLED_RAMDISK_TARGET),)
1010$(call declare-container-license-deps,$(INSTALLED_RAMDISK_TARGET),$(INTERNAL_RAMDISK_FILE),$(PRODUCT_OUT)/:/)
1011
Justin Yundd15ec12022-09-23 10:47:21 +09001012UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001013
Ying Wangad7fd292013-08-08 16:34:29 -07001014.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00001015ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -07001016 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +00001017 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001018
Dan Willemsen67495202019-01-16 12:42:05 -08001019endif # BUILDING_RAMDISK_IMAGE
1020
The Android Open Source Project88b60792009-03-03 19:28:42 -08001021# -----------------------------------------------------------------
1022# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -07001023
1024# This is defined here since we may be building recovery as boot
1025# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -07001026ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
1027 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
1028else
1029 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
1030endif
1031
Yifan Hong0674a6e2020-10-22 14:37:01 -07001032INTERNAL_PREBUILT_BOOTIMAGE :=
1033
1034my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
1035ifdef my_installed_prebuilt_gki_apex
1036 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
1037 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
1038 endif # len(my_installed_prebuilt_gki_apex) > 1
1039
1040 ifdef BOARD_PREBUILT_BOOTIMAGE
1041 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
1042 endif # BOARD_PREBUILT_BOOTIMAGE defined
1043
1044 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
1045 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
1046 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
Bob Badoura60beee2022-09-07 15:34:12 -07001047 $(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Yifan Hong0674a6e2020-10-22 14:37:01 -07001048
1049 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
1050
1051else # my_installed_prebuilt_gki_apex not defined
1052
Steve Muckle04b6f052020-08-09 14:36:56 -07001053# $1: boot image target
1054# returns the kernel used to make the bootimage
1055define bootimage-to-kernel
1056 $(if $(BOARD_KERNEL_BINARIES),\
1057 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
1058 $(INSTALLED_KERNEL_TARGET))
1059endef
1060
Steve Muckle903a1ca2020-05-07 17:32:10 -07001061ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
1062 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
1063endif
1064
1065# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08001066# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -07001067define get-bootimage-partition-size
Peter Collingbourne730200e2022-02-16 13:32:53 -08001068$(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
1069endef
1070
1071# $1: partition size
1072define get-partition-size-argument
1073 $(if $(1),--partition_size $(1),--dynamic_partition_size)
Steve Muckle903a1ca2020-05-07 17:32:10 -07001074endef
Chris Grossa784ef12019-04-22 11:09:57 -07001075
celeste wange3d43202022-08-12 08:36:37 +00001076ifndef BOARD_PREBUILT_BOOTIMAGE
1077
Chris Grossa784ef12019-04-22 11:09:57 -07001078ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001079INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -07001080 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001081
Bowgo Tsai85578e02022-04-19 10:50:59 +08001082# TODO(b/229701033): clean up BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK.
1083ifneq ($(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08001084 ifneq ($(BUILDING_INIT_BOOT_IMAGE),true)
1085 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
Devin Moore380d9e42021-11-04 19:01:19 +00001086 endif
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001087endif
1088
Steve Mucklee1b10862019-07-10 10:49:37 -07001089ifndef BUILDING_VENDOR_BOOT_IMAGE
1090ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1091 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1092endif
1093endif
1094
The Android Open Source Project88b60792009-03-03 19:28:42 -08001095INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
1096
Yifan Hong46aff092020-10-28 13:50:47 -07001097# kernel cmdline/base/pagesize in boot.
1098# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
1099# device-specific.
1100# - If not using GKI:
1101# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
1102# - Otherwise, put them in boot.
1103ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07001104 ifdef GENERIC_KERNEL_CMDLINE
1105 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1106 endif
Yifan Hong46aff092020-10-28 13:50:47 -07001107else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
1108 ifdef INTERNAL_KERNEL_CMDLINE
1109 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1110 endif
1111 ifdef BOARD_KERNEL_BASE
1112 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1113 endif
1114 ifdef BOARD_KERNEL_PAGESIZE
1115 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1116 endif
1117endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001118
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001119ifdef BOARD_GKI_SIGNING_KEY_PATH
1120 # GKI boot images will not set system version & SPL value in the header.
1121 # They can be set by the device manufacturer in the AVB properties instead.
1122 INTERNAL_MKBOOTIMG_VERSION_ARGS :=
1123else
1124 INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -07001125 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001126 --os_patch_level $(PLATFORM_SECURITY_PATCH)
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001127endif # BOARD_GKI_SIGNING_KEY_PATH
Sami Tolvanen3303d902016-03-15 16:49:30 +00001128
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001129# $(1): image target to certify
1130# $(2): out certificate target
1131# $(3): image name
1132# $(4): additional AVB arguments
1133define generate_generic_boot_image_certificate
1134 rm -rf "$(2)"
1135 mkdir -p "$(dir $(2))"
1136 $(GENERATE_GKI_CERTIFICATE) $(INTERNAL_GKI_CERTIFICATE_ARGS) \
1137 --additional_avb_args "$(4)" \
1138 --name "$(3)" --output "$(2)" "$(1)"
1139endef
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001140
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001141INTERNAL_GKI_CERTIFICATE_ARGS :=
1142INTERNAL_GKI_CERTIFICATE_DEPS :=
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001143ifdef BOARD_GKI_SIGNING_KEY_PATH
1144 ifndef BOARD_GKI_SIGNING_ALGORITHM
1145 $(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
1146 endif
1147
1148 INTERNAL_GKI_CERTIFICATE_ARGS := \
1149 --key "$(BOARD_GKI_SIGNING_KEY_PATH)" \
1150 --algorithm "$(BOARD_GKI_SIGNING_ALGORITHM)" \
1151 --avbtool "$(AVBTOOL)"
1152
1153 # Quote and pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string argument.
1154 ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
1155 INTERNAL_GKI_CERTIFICATE_ARGS += --additional_avb_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
1156 endif
1157
1158 INTERNAL_GKI_CERTIFICATE_DEPS := \
1159 $(GENERATE_GKI_CERTIFICATE) \
1160 $(BOARD_GKI_SIGNING_KEY_PATH) \
1161 $(AVBTOOL)
1162
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001163endif
1164
Chris Grossa784ef12019-04-22 11:09:57 -07001165# Define these only if we are building boot
1166ifdef BUILDING_BOOT_IMAGE
1167INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1168
The Android Open Source Project88b60792009-03-03 19:28:42 -08001169ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001170$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001171endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -04001172
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001173$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
1174
1175ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -04001176
Steve Muckle04b6f052020-08-09 14:36:56 -07001177# $1: boot image target
1178define build_boot_board_avb_enabled
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001179 $(eval kernel := $(call bootimage-to-kernel,$(1)))
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001180 $(MKBOOTIMG) --kernel $(kernel) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001181 $(if $(BOARD_GKI_SIGNING_KEY_PATH), \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001182 $(eval boot_signature := $(call intermediates-dir-for,PACKAGING,generic_boot)/$(notdir $(1)).boot_signature) \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001183 $(eval kernel_signature := $(call intermediates-dir-for,PACKAGING,generic_kernel)/$(notdir $(kernel)).boot_signature) \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001184 $(call generate_generic_boot_image_certificate,$(1),$(boot_signature),boot,$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)) $(newline) \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001185 $(call generate_generic_boot_image_certificate,$(kernel),$(kernel_signature),generic_kernel,$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)) $(newline) \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001186 cat $(kernel_signature) >> $(boot_signature) $(newline) \
1187 $(call assert-max-image-size,$(boot_signature),16 << 10) $(newline) \
1188 truncate -s $$(( 16 << 10 )) $(boot_signature) $(newline) \
1189 cat "$(boot_signature)" >> $(1))
Yifan Hongebe65f82020-10-15 14:48:07 -07001190 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot)))
Steve Muckle04b6f052020-08-09 14:36:56 -07001191 $(AVBTOOL) add_hash_footer \
1192 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001193 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) \
Steve Muckle04b6f052020-08-09 14:36:56 -07001194 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1195 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1196endef
1197
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001198$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001199 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001200 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -04001201
Bob Badoura60beee2022-09-07 15:34:12 -07001202$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08001203$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES) $(INTERNAL_GKI_CERTIFICATE_DEPS),$(PRODUCT_OUT)/:/)
1204
Justin Yundd15ec12022-09-23 10:47:21 +09001205UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001206
David Zeuthen0eb10972016-09-28 17:55:27 -04001207.PHONY: bootimage-nodeps
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001208bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001209 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001210 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001211
hungweichenb2dd6832022-08-08 09:16:30 +00001212else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # BOARD_AVB_ENABLE != true
David Riley17be3d32015-03-03 08:54:11 -08001213
Steve Muckle04b6f052020-08-09 14:36:56 -07001214# $1: boot image target
1215define build_boot_supports_vboot
1216 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
1217 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -07001218 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001219endef
1220
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001221$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001222 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001223 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -08001224
Bob Badoura60beee2022-09-07 15:34:12 -07001225$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08001226$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1227
Justin Yundd15ec12022-09-23 10:47:21 +09001228UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001229
David Riley17be3d32015-03-03 08:54:11 -08001230.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001231bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001232 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001233 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -08001234
1235else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001236
Steve Muckle04b6f052020-08-09 14:36:56 -07001237# $1: boot image target
1238define build_boot_novboot
1239 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -07001240 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001241endef
1242
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001243$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001244 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001245 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -07001246
Bob Badoura60beee2022-09-07 15:34:12 -07001247$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08001248$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1249
Justin Yundd15ec12022-09-23 10:47:21 +09001250UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001251
Ying Wangad7fd292013-08-08 16:34:29 -07001252.PHONY: bootimage-nodeps
1253bootimage-nodeps: $(MKBOOTIMG)
1254 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001255 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -07001256
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001257endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -07001258endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001259
Tao Baob1a2e352018-08-14 16:17:12 -07001260else # TARGET_NO_KERNEL == "true"
celeste wange3d43202022-08-12 08:36:37 +00001261INSTALLED_BOOTIMAGE_TARGET :=
1262endif # TARGET_NO_KERNEL
1263
1264else # BOARD_PREBUILT_BOOTIMAGE defined
Yifan Hong0674a6e2020-10-22 14:37:01 -07001265INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +09001266INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001267
1268ifeq ($(BOARD_AVB_ENABLE),true)
1269$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
1270 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
Peter Collingbournefd95f092023-03-24 11:34:24 -07001271 chmod +w $@
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001272 $(AVBTOOL) add_hash_footer \
1273 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001274 $(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001275 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1276 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001277
Bob Badoura60beee2022-09-07 15:34:12 -07001278$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",bool)
Bob Badourebdefc02022-02-12 15:39:22 -08001279$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_BOOTIMAGE),$(PRODUCT_OUT)/:/)
1280
Justin Yundd15ec12022-09-23 10:47:21 +09001281UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001282else
1283$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
1284 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1285endif # BOARD_AVB_ENABLE
1286
Tao Baob1a2e352018-08-14 16:17:12 -07001287endif # BOARD_PREBUILT_BOOTIMAGE
celeste wange3d43202022-08-12 08:36:37 +00001288
Yifan Hong0674a6e2020-10-22 14:37:01 -07001289endif # my_installed_prebuilt_gki_apex not defined
1290
1291my_apex_extracted_boot_image :=
1292my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001293
1294# -----------------------------------------------------------------
Devin Moore380d9e42021-11-04 19:01:19 +00001295# init boot image
1296ifeq ($(BUILDING_INIT_BOOT_IMAGE),true)
1297
1298INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1299$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_RAMDISK_TARGET)
1300
Yi-Yo Chiang8b0776d2022-06-30 17:33:29 +08001301INTERNAL_INIT_BOOT_IMAGE_ARGS := --ramdisk $(INSTALLED_RAMDISK_TARGET)
1302
Devin Moore380d9e42021-11-04 19:01:19 +00001303ifdef BOARD_KERNEL_PAGESIZE
1304 INTERNAL_INIT_BOOT_IMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1305endif
1306
1307ifeq ($(BOARD_AVB_ENABLE),true)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08001308$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
Devin Moore380d9e42021-11-04 19:01:19 +00001309 $(call pretty,"Target init_boot image: $@")
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001310 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output "$@"
Devin Moore380d9e42021-11-04 19:01:19 +00001311 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
1312 $(AVBTOOL) add_hash_footer \
1313 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001314 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001315 --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1316 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001317
1318$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1319$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_GENERIC_RAMDISK_BOOT_SIGNATURE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001320else
1321$(INSTALLED_INIT_BOOT_IMAGE_TARGET):
1322 $(call pretty,"Target init_boot image: $@")
1323 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output $@
1324 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
Bob Badourebdefc02022-02-12 15:39:22 -08001325
1326$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001327endif
1328
Justin Yundd15ec12022-09-23 10:47:21 +09001329UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001330
Devin Moore380d9e42021-11-04 19:01:19 +00001331else # BUILDING_INIT_BOOT_IMAGE is not true
1332
1333ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
1334INTERNAL_PREBUILT_INIT_BOOT_IMAGE := $(BOARD_PREBUILT_INIT_BOOT_IMAGE)
1335INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1336
1337ifeq ($(BOARD_AVB_ENABLE),true)
1338$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
1339 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
Peter Collingbournefd95f092023-03-24 11:34:24 -07001340 chmod +w $@
Devin Moore380d9e42021-11-04 19:01:19 +00001341 $(AVBTOOL) add_hash_footer \
1342 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001343 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore77ae07d2023-02-06 17:25:06 +00001344 --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
Devin Moore380d9e42021-11-04 19:01:19 +00001345 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001346
1347$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1348$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_PREBUILT_INIT_BOOT_IMAGE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001349else
1350$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE)
1351 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
Bob Badourebdefc02022-02-12 15:39:22 -08001352
1353$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001354endif # BOARD_AVB_ENABLE
1355
Justin Yundd15ec12022-09-23 10:47:21 +09001356UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001357
Devin Moore380d9e42021-11-04 19:01:19 +00001358else # BOARD_PREBUILT_INIT_BOOT_IMAGE not defined
1359INSTALLED_INIT_BOOT_IMAGE_TARGET :=
1360endif # BOARD_PREBUILT_INIT_BOOT_IMAGE
1361
1362endif # BUILDING_INIT_BOOT_IMAGE is not true
Ramji Jiyani10655232022-01-20 06:43:09 +00001363
1364# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001365# vendor boot image
Colin Cross79a76ec2022-03-21 15:06:11 -07001366INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Steve Mucklee1b10862019-07-10 10:49:37 -07001367ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1368
Steve Mucklee1b10862019-07-10 10:49:37 -07001369INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
Steve Mucklee1b10862019-07-10 10:49:37 -07001370 $(ALL_DEFAULT_INSTALLED_MODULES))
1371
Petri Gynther6a6d6212021-03-06 00:45:53 -08001372INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001373
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001374# Exclude recovery files in the default vendor ramdisk if including a standalone
1375# recovery ramdisk in vendor_boot.
Yifan Hong881df392020-10-09 14:29:39 -07001376ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001377ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
Yifan Hong881df392020-10-09 14:29:39 -07001378$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1379$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1380endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001381endif
Yifan Hong881df392020-10-09 14:29:39 -07001382
J. Avila3f6560e2020-05-11 20:20:03 +00001383$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001384 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001385
Petri Gynther828828b2021-03-04 11:04:03 -08001386INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1387$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08001388 @echo "Target vendor ramdisk: $@"
Petri Gynther828828b2021-03-04 11:04:03 -08001389 $(copy-file-to-target)
Petri Gynther828828b2021-03-04 11:04:03 -08001390
Bob Badourebdefc02022-02-12 15:39:22 -08001391$(call declare-1p-container,$(INSTALLED_VENDOR_RAMDISK_TARGET),)
1392$(call declare-container-license-deps,$(INSTALLED_VENDOR_RAMDISK_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
1393
1394VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_RAMDISK_TARGET)
1395
Petri Gynther6ff52012020-11-20 11:59:41 -08001396INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1397INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1398$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1399$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1400$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001401 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001402 mkdir -p $(dir $@)
1403 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001404 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1405 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001406
Bob Badourebdefc02022-02-12 15:39:22 -08001407$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07001408$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08001409
Steve Mucklee1b10862019-07-10 10:49:37 -07001410ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Lucas Weif57333f2022-02-24 10:30:15 +08001411 ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1412 # If we have vendor_kernel_boot partition, we migrate dtb image to that image
1413 # and allow dtb in vendor_boot to be empty.
1414 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1415 endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001416endif
1417ifdef BOARD_KERNEL_BASE
1418 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1419endif
1420ifdef BOARD_KERNEL_PAGESIZE
1421 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1422endif
1423ifdef INTERNAL_KERNEL_CMDLINE
1424 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1425endif
1426
Devin Moore50509012021-01-13 10:45:04 -08001427ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001428 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1429 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001430 rm -f $@
1431 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1432 printf "%s\n" $(param) >> $@;)
1433 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1434endif
1435
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001436# $(1): Build target name
1437# $(2): Staging dir to be compressed
1438# $(3): Build dependencies
1439define build-vendor-ramdisk-fragment-target
1440$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1441 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1442endef
1443
1444# $(1): Ramdisk name
1445define build-vendor-ramdisk-fragment
1446$(strip \
1447 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1448 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1449 $(build_target) \
1450)
1451endef
1452
1453# $(1): Ramdisk name
1454# $(2): Prebuilt file path
1455define build-prebuilt-vendor-ramdisk-fragment
1456$(strip \
1457 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1458 $(eval $(call copy-one-file,$(2),$(build_target))) \
1459 $(build_target) \
1460)
1461endef
1462
1463INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1464INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1465
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001466$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001467 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1468 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1469 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1470 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001471 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001472 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1473 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1474)
1475
Steve Mucklee1b10862019-07-10 10:49:37 -07001476INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1477$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001478$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001479ifeq ($(BOARD_AVB_ENABLE),true)
1480$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1481 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001482 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001483 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1484 $(AVBTOOL) add_hash_footer \
1485 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001486 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Steve Mucklee1b10862019-07-10 10:49:37 -07001487 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1488 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1489else
1490$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1491 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001492 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001493 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1494endif
Bob Badourebdefc02022-02-12 15:39:22 -08001495
1496$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
1497$(call declare-container-license-deps,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTB_IMAGE_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONDIG_TARGET),$(PRODUCT_OUT)/:/)
1498VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001499endif # BUILDING_VENDOR_BOOT_IMAGE
1500
1501# -----------------------------------------------------------------
Lucas Weif57333f2022-02-24 10:30:15 +08001502# vendor kernel boot image
1503ifeq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1504
1505INTERNAL_VENDOR_KERNEL_RAMDISK_FILES := $(filter $(TARGET_VENDOR_KERNEL_RAMDISK_OUT)/%, \
Lucas Weif57333f2022-02-24 10:30:15 +08001506 $(ALL_DEFAULT_INSTALLED_MODULES))
1507
1508INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_kernel_boot)/vendor_kernel_ramdisk.cpio$(RAMDISK_EXT)
1509
1510$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
1511 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
1512
1513INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_kernel_ramdisk.img
1514$(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1515 @echo "Target vendor kernel ramdisk: $@"
1516 $(copy-file-to-target)
1517
1518INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-kernel-ramdisk.txt
1519INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK:.txt=.json)
1520$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK)
1521$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1522$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
1523 @echo Installed file list: $@
1524 mkdir -p $(dir $@)
1525 rm -f $@
1526 $(FILESLIST) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) > $(@:.txt=.json)
1527 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
1528
Bob Badour5acd4362022-04-12 18:31:35 -07001529$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK))
1530$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK))
1531
Lucas Weif57333f2022-02-24 10:30:15 +08001532INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS := --vendor_ramdisk $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1533INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_kernel_boot.img
1534$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1535
1536ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1537 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1538 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
1539endif
1540ifdef BOARD_KERNEL_PAGESIZE
1541 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1542endif
1543
1544
1545ifeq ($(BOARD_AVB_ENABLE),true)
1546$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_KERNEL_BOOTIMAGE_KEY_PATH)
1547 $(call pretty,"Target vendor_kernel_boot image: $@")
1548 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1549 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1550 $(AVBTOOL) add_hash_footer \
1551 --image $@ \
1552 $(call get-partition-size-argument,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)) \
1553 --partition_name vendor_kernel_boot $(INTERNAL_AVB_VENDOR_KERNEL_BOOT_SIGNING_ARGS) \
1554 $(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)
1555else
1556$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):
1557 $(call pretty,"Target vendor_kernel_boot image: $@")
1558 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1559 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1560endif
Bob Badour5acd4362022-04-12 18:31:35 -07001561$(call declare-1p-container,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
1562ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1563$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),\
1564 $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET),\
1565 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1566else
1567$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET),$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1568endif
Lucas Weif57333f2022-02-24 10:30:15 +08001569endif # BUILDING_VENDOR_KERNEL_BOOT_IMAGE
1570
1571# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001572# NOTICE files
1573#
Steve Blockd14d3b42012-03-01 11:34:41 +00001574# We are required to publish the licenses for all code under BSD, GPL and
1575# Apache licenses (and possibly other more exotic ones as well). We err on the
1576# side of caution, so the licenses for other third-party code are included here
1577# too.
1578#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001579# This needs to be before the systemimage rules, because it adds to
1580# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1581# go into the systemimage.
1582
Steve Block495e5852012-02-29 19:18:08 +00001583.PHONY: notice_files
1584
Bob Badourebdefc02022-02-12 15:39:22 -08001585# Convert license metadata into xml notice file.
1586# $(1) - Output target notice filename
1587# $(2) - Product name
1588# $(3) - File title
1589# $(4) - License metadata file roots
1590# $(5) - Prefixes to strip
1591#
1592define xml-notice-rule
1593$(1): PRIVATE_PRODUCT := $(2)
1594$(1): PRIVATE_MESSAGE := $(3)
Bob Badour5acd4362022-04-12 18:31:35 -07001595$(1): PRIVATE_DEPS := $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001596$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badour5acd4362022-04-12 18:31:35 -07001597 OUT_DIR=$(OUT_DIR) $(XMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $$(PRIVATE_DEPS)
Bob Badourebdefc02022-02-12 15:39:22 -08001598
1599notice_files: $(1)
1600endef
1601
1602# Convert license metadata into text notice file.
1603# $(1) - Output target notice filename
1604# $(2) - Product name
1605# $(3) - File title
1606# $(4) - License metadata file roots
1607# $(5) - Prefixes to strip
1608#
1609define text-notice-rule
1610$(1): PRIVATE_PRODUCT := $(2)
1611$(1): PRIVATE_MESSAGE := $(3)
1612$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001613 OUT_DIR=$(OUT_DIR) $(TEXTNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001614
1615notice_files: $(1)
1616endef
1617
1618# Conversion license metadata into html notice file.
1619# $(1) - Output target notice filename
1620# $(2) - Product name
1621# $(3) - File title
1622# $(4) - License metadata file roots
1623# $(5) - Prefixes to strip
1624#
1625define html-notice-rule
1626$(1): PRIVATE_PRODUCT := $(2)
1627$(1): PRIVATE_MESSAGE := $(3)
1628$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001629 OUT_DIR=$(OUT_DIR) $(HTMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001630
1631notice_files: $(1)
1632endef
1633
Bob Badour6259a092022-03-23 23:28:40 -07001634$(KATI_obsolete_var combine-notice-files, To create notice files use xml-notice-rule, html-notice-rule, or text-notice-rule.)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001635
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001636# Notice file logic isn't relevant for TARGET_BUILD_APPS
1637ifndef TARGET_BUILD_APPS
1638
The Android Open Source Project88b60792009-03-03 19:28:42 -08001639# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1640# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1641# the src subdirectory.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001642kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001643
Bob Badour4b25c902020-01-28 13:23:39 -08001644# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1645# reasons--not to be flashed onto any device. Targets under these directories
1646# need no associated notice file on the device UI.
1647exclude_target_dirs := apex
1648
Steven Morelandae69e572017-12-15 14:49:55 -08001649# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001650ifneq ($(PRODUCT_NOTICE_SPLIT),true)
Bob Badourebdefc02022-02-12 15:39:22 -08001651#target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001652target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1653installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Bob Badour879cfa82021-04-15 10:41:38 -07001654
1655$(call declare-0p-target,$(target_notice_file_html_gz))
1656$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001657else
Bob Badourebdefc02022-02-12 15:39:22 -08001658# target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001659target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001660installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1661
1662target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001663target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1664installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001665
1666target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
Dario Freniadc972d2018-07-09 18:38:38 +01001667target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1668installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001669
Justin Yun6151e3f2019-06-25 15:58:13 +09001670target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
Justin Yun6151e3f2019-06-25 15:58:13 +09001671target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1672installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001673
Chris Gross15d96552019-07-16 14:38:43 -07001674target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
Chris Gross15d96552019-07-16 14:38:43 -07001675target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1676installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1677
Yifan Hong3d3f0302020-05-11 18:35:11 -07001678target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
Yifan Hong3d3f0302020-05-11 18:35:11 -07001679target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1680installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1681
Yifan Hongc83f9e92020-07-15 16:57:47 -07001682target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
Yifan Hongc83f9e92020-07-15 16:57:47 -07001683target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1684installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1685
Ramji Jiyani13a41372022-01-27 07:05:08 +00001686target_system_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.txt
Ramji Jiyani13a41372022-01-27 07:05:08 +00001687target_system_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.xml.gz
1688installed_system_dlkm_notice_xml_gz := $(TARGET_OUT_SYSTEM_DLKM)/etc/NOTICE.xml.gz
1689
Wei Li49933362023-01-04 17:13:47 -08001690ALL_INSTALLED_NOTICE_FILES := \
1691 $(installed_notice_html_or_xml_gz) \
1692 $(installed_vendor_notice_xml_gz) \
1693 $(installed_product_notice_xml_gz) \
1694 $(installed_system_ext_notice_xml_gz) \
1695 $(installed_odm_notice_xml_gz) \
1696 $(installed_vendor_dlkm_notice_xml_gz) \
1697 $(installed_odm_dlkm_notice_xml_gz) \
1698 $(installed_system_dlkm_notice_xml_gz) \
1699
1700# $1 installed file path, e.g. out/target/product/vsoc_x86_64/system_ext/etc/NOTICE.xml.gz
1701define is-notice-file
1702$(if $(findstring $1,$(ALL_INSTALLED_NOTICE_FILES)),Y)
1703endef
1704
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001705# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1706# being built. A notice xml file must depend on all modules that could potentially
1707# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001708license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001709# Only files copied to a system image need system image notices.
1710license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001711# Phonys/fakes don't have notice files (though their deps might)
1712license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001713# testcases are not relevant to the system image.
1714license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001715# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001716license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001717# system_other is relevant to system partition.
1718license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001719license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1720license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001721license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001722license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001723license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001724license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001725license_modules_odm_dlkm := $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001726license_modules_agg := $(license_modules_system) \
1727 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001728 $(license_modules_product) \
1729 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001730 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001731 $(license_modules_vendor_dlkm) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001732 $(license_modules_odm_dlkm) \
1733 $(license_modules_system_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001734# targets used for debug symbols only and do not get copied to the device
1735license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1736
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001737license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001738license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1739
1740# Identify the other targets we expect to have notices for:
1741# targets copied to the device but are not readable by the UI (e.g. must boot
1742# into a different partition to read or don't have an associated /etc
1743# directory) must have their notices built somewhere readable.
1744license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1745license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1746license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1747license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1748license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1749license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001750license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001751license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1752license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1753license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1754license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1755license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1756license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1757
1758# after removing targets in system images, targets reported in system images, and
1759# targets used for debug symbols that do not need notices, nothing must remain.
1760license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1761$(call maybe-print-list-and-error, $(license_modules_rest), \
1762 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001763
Chris Grossaad39b32019-06-13 09:43:26 -07001764# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1765# update its notice file, so include those notices in the system partition instead
1766ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001767license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001768system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1769system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001770else
Bob Badour4b25c902020-01-28 13:23:39 -08001771license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001772system_xml_directories := xml_system
1773system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001774endif
1775
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001776endif # PRODUCT_NOTICE_SPLIT
1777
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001778ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001779
Bob Badour56e0de52022-08-02 17:46:48 +00001780need_vendor_notice:=false
1781ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1782 need_vendor_notice:=true
1783endif
1784
1785ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
1786 need_vendor_notice:=true
1787endif
1788
1789ifdef BUILDING_VENDOR_IMAGE
1790 need_vendor_notice:=true
1791endif
1792
1793ifeq (true,$(need_vendor_notice))
1794ifneq (,$(installed_vendor_notice_xml_gz))
1795ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1796endif
1797endif
1798
1799need_vendor_notice:=
1800
1801ifdef BUILDING_ODM_IMAGE
1802ifneq (,$(installed_odm_notice_xml_gz))
1803ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
1804endif
1805endif
1806
1807ifdef BUILDING_PRODUCT_IMAGE
1808ifneq (,$(installed_product_notice_xml_gz))
1809ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1810endif
1811endif
1812
1813ifdef BUILDING_SYSTEM_EXT_IMAGE
1814ifneq (,$(installed_system_ext_notice_xml_gz))
1815ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1816endif
1817endif
1818
1819ifdef BUILDING_VENDOR_DLKM_IMAGE
1820ifneq (,$(installed_vendor_dlkm_notice_xml_gz)
1821ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
1822endif
1823endif
1824
1825ifdef BUILDING_ODM_DLKM_IMAGE
1826ifneq (,$(installed_odm_dlkm_notice_xml_gz))
1827ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
1828endif
1829endif
1830
1831ifdef BUILDING_SYSTEM_DLKM_IMAGE
1832ifneq (,$(installed_system_dlkm_notice_xml_gz))
1833ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_dlkm_notice_xml_gz)
1834endif
1835endif
1836
Ying Wang62c81f82013-08-22 20:02:03 -07001837endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001838
Bob Badoura60beee2022-09-07 15:34:12 -07001839# Presently none of the prebuilts etc. comply with policy to have a license text. Fake one here.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001840$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001841
Bob Badoura60beee2022-09-07 15:34:12 -07001842ifneq (,$(strip $(INSTALLED_KERNEL_TARGET)))
1843$(call declare-license-metadata,$(INSTALLED_KERNEL_TARGET),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
1844endif
Bob Badourebdefc02022-02-12 15:39:22 -08001845
Bob Badoura60beee2022-09-07 15:34:12 -07001846# No matter where it gets copied from, a copied linux kernel is licensed under "GPL 2.0 only"
1847$(eval $(call declare-copy-files-license-metadata,,:kernel,SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,kernel))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001848
Doug Zongker8678df42009-06-15 14:30:14 -07001849
The Android Open Source Project88b60792009-03-03 19:28:42 -08001850# #################################################################
1851# Targets for user images
1852# #################################################################
1853
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001854# These options tell the recovery updater/installer how to mount the partitions writebale.
1855# <fstype>=<fstype_opts>[|<fstype_opts>]...
1856# fstype_opts := <opt>[,<opt>]...
1857# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001858# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1859DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001860
Tao Baodba635a2019-06-24 10:39:54 -07001861INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001862 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001863 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001864 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001865
Bob Badour2f66fd12022-03-09 17:30:24 -08001866$(call declare-1p-target,$(MKE2FS_CONF),system/extras)
1867
Tao Baodba635a2019-06-24 10:39:54 -07001868ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1869INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001870endif
1871
Yifan Hongcfb917a2020-05-07 14:58:20 -07001872ifneq ($(filter \
1873 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1874 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1875 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1876 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1877 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1878 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001879 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001880 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001881 ,erofs),)
David Anderson94ad5bb2022-03-04 10:57:58 -08001882INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
David Andersonf54665f2022-03-04 14:42:18 -08001883ifeq ($(BOARD_EROFS_USE_LEGACY_COMPRESSION),true)
1884BOARD_EROFS_COMPRESSOR ?= "lz4"
1885else
Kelvin Zhang37d49292021-12-01 14:21:24 -08001886BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
Gao Xiang961041a2020-06-17 13:59:16 +08001887endif
David Andersonf54665f2022-03-04 14:42:18 -08001888endif
Gao Xiang961041a2020-06-17 13:59:16 +08001889
1890ifneq ($(filter \
1891 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1892 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1893 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1894 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1895 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1896 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1897 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001898 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001899 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001900INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1901endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001902
Tao Baodba635a2019-06-24 10:39:54 -07001903ifeq ($(BOARD_AVB_ENABLE),true)
1904INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1905endif
1906
1907# Get a colon-separated list of search paths.
1908INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1909
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001910# Collects file_contexts files from modules to be installed
1911$(call merge-fc-files, \
1912 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1913 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1914
Alex Klyubin092c9022017-03-13 13:28:34 -07001915SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001916
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001917INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1918
David Anderson707e6f52021-09-21 22:24:43 -07001919# $(1) the partition name (eg system)
1920# $(2) the image prop file
1921define add-common-flags-to-image-props
1922$(eval _var := $(call to-upper,$(1)))
1923$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
1924$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
1925endef
1926
1927# $(1) the partition name (eg system)
1928# $(2) the image prop file
1929define add-common-ro-flags-to-image-props
1930$(eval _var := $(call to-upper,$(1)))
David Anderson64b351b2021-10-13 00:20:43 -07001931$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001932$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESS_HINTS),$(hide) echo "$(1)_erofs_compress_hints=$(BOARD_$(_var)IMAGE_EROFS_COMPRESS_HINTS)" >> $(2))
David Anderson64b351b2021-10-13 00:20:43 -07001933$(if $(BOARD_$(_var)IMAGE_EROFS_PCLUSTER_SIZE),$(hide) echo "$(1)_erofs_pcluster_size=$(BOARD_$(_var)IMAGE_EROFS_PCLUSTER_SIZE)" >> $(2))
David Anderson707e6f52021-09-21 22:24:43 -07001934$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
1935$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
1936$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
1937$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
1938$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
1939$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
1940$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
1941$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
1942$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
1943$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
1944$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
1945$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
1946$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
1947$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
1948$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
1949$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
David Anderson5f4aa6c2021-09-23 17:03:14 -07001950$(if $(or $(_size), $(_reserved), $(_headroom)),,
1951 $(hide) echo "$(1)_disable_sparse=true" >> $(2))
David Anderson707e6f52021-09-21 22:24:43 -07001952$(call add-common-flags-to-image-props,$(1),$(2))
David Anderson9e95a022021-08-31 21:32:45 -07001953endef
1954
Ying Wangbd93d422011-10-28 17:02:30 -07001955# $(1): the path of the output dictionary file
Ramji Jiyani13a41372022-01-27 07:05:08 +00001956# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm system_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001957# $(3): additional "key=value" pairs to append to the dictionary file.
1958define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001959$(if $(filter $(2),system),\
Bowgo Tsai867ab662019-01-29 13:30:18 +08001960 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001961 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001962 $(call add-common-ro-flags-to-image-props,system,$(1))
Chris Gross203191b2020-05-30 02:39:12 +00001963)
1964$(if $(filter $(2),system_other),\
1965 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
David Anderson9e95a022021-08-31 21:32:45 -07001966 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
1967 $(hide) echo "system_other_disable_sparse=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001968)
Yifan Hong760d3c02018-05-30 11:16:46 -07001969$(if $(filter $(2),userdata),\
1970 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1971 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001972 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1973 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kim55c16dd2020-10-12 19:50:05 -07001974 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001975 $(call add-common-flags-to-image-props,userdata,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001976)
Yifan Hong760d3c02018-05-30 11:16:46 -07001977$(if $(filter $(2),cache),\
1978 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1979 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001980 $(call add-common-flags-to-image-props,cache,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001981)
1982$(if $(filter $(2),vendor),\
David Anderson707e6f52021-09-21 22:24:43 -07001983 $(call add-common-ro-flags-to-image-props,vendor,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001984)
1985$(if $(filter $(2),product),\
David Anderson707e6f52021-09-21 22:24:43 -07001986 $(call add-common-ro-flags-to-image-props,product,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001987)
Justin Yun6151e3f2019-06-25 15:58:13 +09001988$(if $(filter $(2),system_ext),\
David Anderson707e6f52021-09-21 22:24:43 -07001989 $(call add-common-ro-flags-to-image-props,system_ext,$(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001990)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001991$(if $(filter $(2),odm),\
David Anderson707e6f52021-09-21 22:24:43 -07001992 $(call add-common-ro-flags-to-image-props,odm,$(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001993)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001994$(if $(filter $(2),vendor_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001995 $(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001996)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001997$(if $(filter $(2),odm_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001998 $(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001999)
Ramji Jiyani13a41372022-01-27 07:05:08 +00002000$(if $(filter $(2),system_dlkm),\
2001 $(call add-common-ro-flags-to-image-props,system_dlkm,$(1))
2002)
Yifan Hong760d3c02018-05-30 11:16:46 -07002003$(if $(filter $(2),oem),\
2004 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
2005 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
2006 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
2007 $(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07002008 $(call add-common-flags-to-image-props,oem,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07002009)
Tao Bao3602eca2018-07-10 10:53:55 -07002010$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002011
Cole Faust8fc7bef2022-06-15 16:10:49 -07002012$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT2)),$(hide) echo "fs_type=ext2" >> $(1),
2013 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT3)),$(hide) echo "fs_type=ext3" >> $(1),
2014 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT4)),$(hide) echo "fs_type=ext4" >> $(1))))
2015
2016$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)),,$(hide) echo "extfs_sparse_flag=-s" >> $(1))
2017$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED)),,$(hide) echo "erofs_sparse_flag=-s" >> $(1))
2018$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)),,$(hide) echo "squashfs_sparse_flag=-s" >> $(1))
2019$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)),,$(hide) echo "f2fs_sparse_flag=-S" >> $(1))
David Anderson40a821f2021-09-22 18:02:01 -07002020$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00002021$(if $(BOARD_EROFS_COMPRESS_HINTS),$(hide) echo "erofs_default_compress_hints=$(BOARD_EROFS_COMPRESS_HINTS)" >> $(1))
David Anderson64b351b2021-10-13 00:20:43 -07002022$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
2023$(if $(BOARD_EROFS_SHARE_DUP_BLOCKS),$(hide) echo "erofs_share_dup_blocks=$(BOARD_EROFS_SHARE_DUP_BLOCKS)" >> $(1))
David Andersonf54665f2022-03-04 14:42:18 -08002024$(if $(BOARD_EROFS_USE_LEGACY_COMPRESSION),$(hide) echo "erofs_use_legacy_compression=$(BOARD_EROFS_USE_LEGACY_COMPRESSION)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07002025$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
2026$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
2027$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08002028$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002029$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
2030$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
2031$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09002032$(if $(PRODUCT_SYSTEM_EXT_VERITY_PARTITION),$(hide) echo "system_ext_verity_block_device=$(PRODUCT_SYSTEM_EXT_VERITY_PARTITION)" >> $(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002033$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002034$(if $(PRODUCT_ODM_DLKM_VERITY_PARTITION),$(hide) echo "odm_dlkm_verity_block_device=$(PRODUCT_ODM_DLKM_VERITY_PARTITION)" >> $(1))
Ramji Jiyani13a41372022-01-27 07:05:08 +00002035$(if $(PRODUCT_SYSTEM_DLKM_VERITY_PARTITION),$(hide) echo "system_dlkm_verity_block_device=$(PRODUCT_SYSTEM_DLKM_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002036$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
2037$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
2038$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
2039$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
2040$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07002041$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002042$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2043$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2044$(if $(BOARD_AVB_ENABLE),\
2045 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
2046 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
2047 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
2048 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08002049$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2050$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2051$(if $(BOARD_AVB_ENABLE),\
2052 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
2053 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08002054 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002055$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2056$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2057$(if $(BOARD_AVB_ENABLE),\
2058 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
2059 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
2060 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
2061 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002062$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2063$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2064$(if $(BOARD_AVB_ENABLE),\
2065 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
2066 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
2067 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
2068 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09002069$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07002070$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09002071 $(hide) echo "avb_system_ext_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
Dario Freni5f681e12018-05-29 13:09:01 +01002072$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09002073 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
2074 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
2075 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
2076 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002077$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2078$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2079$(if $(BOARD_AVB_ENABLE),\
2080 $(if $(BOARD_AVB_ODM_KEY_PATH),\
2081 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
2082 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
2083 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07002084$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2085$(if $(BOARD_AVB_ENABLE),\
2086 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2087$(if $(BOARD_AVB_ENABLE),\
2088 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
2089 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
2090 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
2091 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002092$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2093$(if $(BOARD_AVB_ENABLE),\
2094 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2095$(if $(BOARD_AVB_ENABLE),\
2096 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
2097 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
2098 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
2099 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Ramji Jiyani13a41372022-01-27 07:05:08 +00002100$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2101$(if $(BOARD_AVB_ENABLE),\
2102 $(hide) echo "avb_system_dlkm_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2103$(if $(BOARD_AVB_ENABLE),\
2104 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
2105 $(hide) echo "avb_system_dlkm_key_path=$(BOARD_AVB_SYSTEM_DLKM_KEY_PATH)" >> $(1)
2106 $(hide) echo "avb_system_dlkm_algorithm=$(BOARD_AVB_SYSTEM_DLKM_ALGORITHM)" >> $(1)
2107 $(hide) echo "avb_system_dlkm_rollback_index_location=$(BOARD_SYSTEM_SYSTEM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002108$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
2109 $(hide) echo "recovery_as_boot=true" >> $(1))
Bowgo Tsai85578e02022-04-19 10:50:59 +08002110$(if $(filter true,$(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK)),\
2111 $(hide) echo "gki_boot_image_without_ramdisk=true" >> $(1))
Tom Cherryd14b8952018-08-09 14:26:00 -07002112$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01002113$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
2114 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07002115$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
2116endef
2117
2118# $(1): the path of the output dictionary file
2119# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07002120PROP_DICTIONARY_IMAGES := oem
2121ifdef BUILDING_CACHE_IMAGE
2122 PROP_DICTIONARY_IMAGES += cache
2123endif
2124ifdef BUILDING_SYSTEM_IMAGE
2125 PROP_DICTIONARY_IMAGES += system
2126endif
Chris Gross203191b2020-05-30 02:39:12 +00002127ifdef BUILDING_SYSTEM_OTHER_IMAGE
2128 PROP_DICTIONARY_IMAGES += system_other
2129endif
Daniel Norman72c626f2019-05-13 15:58:14 -07002130ifdef BUILDING_USERDATA_IMAGE
2131 PROP_DICTIONARY_IMAGES += userdata
2132endif
2133ifdef BUILDING_VENDOR_IMAGE
2134 PROP_DICTIONARY_IMAGES += vendor
2135endif
2136ifdef BUILDING_PRODUCT_IMAGE
2137 PROP_DICTIONARY_IMAGES += product
2138endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002139ifdef BUILDING_SYSTEM_EXT_IMAGE
2140 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07002141endif
2142ifdef BUILDING_ODM_IMAGE
2143 PROP_DICTIONARY_IMAGES += odm
2144endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002145ifdef BUILDING_VENDOR_DLKM_IMAGE
2146 PROP_DICTIONARY_IMAGES += vendor_dlkm
2147endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07002148ifdef BUILDING_ODM_DLKM_IMAGE
2149 PROP_DICTIONARY_IMAGES += odm_dlkm
2150endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00002151ifdef BUILDING_SYSTEM_DLKM_IMAGE
2152 PROP_DICTIONARY_IMAGES += system_dlkm
2153endif
Yifan Hong760d3c02018-05-30 11:16:46 -07002154define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07002155 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07002156endef
2157
Yifan Hongbbcba1e2018-06-18 16:32:35 -07002158# $(1): the path of the input dictionary file, where each line has the format key=value
2159# $(2): the key to look up
2160define read-image-prop-dictionary
2161$$(grep '$(2)=' $(1) | cut -f2- -d'=')
2162endef
2163
The Android Open Source Project88b60792009-03-03 19:28:42 -08002164# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07002165# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07002166
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002167# Recovery image exists if we are building recovery, or building recovery as boot.
Colin Cross79a76ec2022-03-21 15:06:11 -07002168INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RECOVERY_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Chris Grossa784ef12019-04-22 11:09:57 -07002169ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002170
Ying Wang37526142015-03-10 12:02:57 -07002171INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
2172 $(ALL_DEFAULT_INSTALLED_MODULES))
2173
Tao Bao10fc9492018-08-14 12:17:48 -07002174INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
2175INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
2176
Colin Cross359f4212020-12-02 15:14:04 -08002177ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2178INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
2179endif
2180
Tao Bao10fc9492018-08-14 12:17:48 -07002181# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
2182# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
2183# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
2184# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08002185$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07002186
2187$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002188$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07002189 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002190 mkdir -p $(dir $@)
2191 rm -f $@
2192 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
2193 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07002194
Bob Badour5acd4362022-04-12 18:31:35 -07002195$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RECOVERY)))
2196$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RECOVERY)))
2197
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002198recovery_sepolicy := \
2199 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07002200 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002201 $(TARGET_RECOVERY_ROOT_OUT)/plat_service_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002202 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002203 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002204 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_service_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002205 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
2206 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002207 $(TARGET_RECOVERY_ROOT_OUT)/vendor_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002208 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08002209 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002210 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
2211 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002212 $(TARGET_RECOVERY_ROOT_OUT)/product_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002213 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08002214
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002215# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
2216# SELinux files
2217IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
2218
Steve Muckle04b6f052020-08-09 14:36:56 -07002219# if building multiple boot images from multiple kernels, use the first kernel listed
2220# for the recovery image
2221recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002222recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07002223recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08002224
Anton Hansson45a40da2019-01-18 14:06:34 +00002225# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
2226# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
2227# which get remapped to a bucket.
2228recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07002229ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
2230recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00002231# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07002232# ------160------240------320----------480------------640------
2233# mdpi hdpi xhdpi xxhdpi xxxhdpi
2234recovery_density := $(strip \
2235 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
2236 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
2237 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
2238 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07002239endif
2240
2241ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
2242recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
2243else
Doug Zongker25d55f82014-04-04 13:51:15 -07002244recovery_resources_common := $(recovery_resources_common)-xhdpi
2245endif
2246
Tao Baoe1e829e2018-08-29 20:36:00 -07002247# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
2248# Note that the font selected here can be overridden for a particular device by putting a font.png
2249# in its private recovery resources.
2250ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07002251recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08002252else
Dan Willemsen97672232020-05-27 00:09:16 -07002253recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08002254endif
2255
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002256
2257# We will only generate the recovery background text images if the variable
2258# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
2259# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
2260# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
2261# BoardConfig in order to use this feature.
2262ifeq ($(recovery_density),xxxhdpi)
2263TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
2264else ifeq ($(recovery_density),xxhdpi)
2265TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
2266endif
2267
2268ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
2269# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
2270ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
2271 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
2272else
2273 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
2274endif
2275
2276
Dan Willemsen97672232020-05-27 00:09:16 -07002277RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002278RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
2279RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
2280RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
2281RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
2282
xunchangcc57d312018-12-07 12:12:17 -08002283RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
2284RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
2285RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
2286RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
2287RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
2288
2289generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002290 $(RECOVERY_INSTALLING_TEXT_FILE) \
2291 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
2292 $(RECOVERY_ERASING_TEXT_FILE) \
2293 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08002294 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
2295 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
2296 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
2297 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
2298 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
2299 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002300
Dan Willemsen97672232020-05-27 00:09:16 -07002301resource_dir := bootable/recovery/tools/recovery_l10n/res/
2302resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002303image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08002304zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002305$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07002306$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002307$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
2308$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08002309$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002310$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08002311$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002312 recovery_installing \
2313 recovery_installing_security \
2314 recovery_erasing \
2315 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08002316 recovery_no_command
2317$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002318 recovery_cancel_wipe_data \
2319 recovery_factory_data_reset \
2320 recovery_try_again \
2321 recovery_wipe_data_menu_header \
2322 recovery_wipe_data_confirmation
2323$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07002324$(RECOVERY_INSTALLING_TEXT_FILE): $(image_generator_jar) $(resource_dir_deps) $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep) $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002325 # Prepares the font directory.
2326 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
2327 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08002328 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002329 @rm -rf $(dir $@)
2330 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08002331 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08002332 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08002333 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002334 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
2335 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
2336 --text_name $(text_name) \
2337 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2338 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002339 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002340 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002341else
2342RECOVERY_INSTALLING_TEXT_FILE :=
2343RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2344RECOVERY_ERASING_TEXT_FILE :=
2345RECOVERY_ERROR_TEXT_FILE :=
2346RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002347RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2348RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2349RECOVERY_TRY_AGAIN_TEXT_FILE :=
2350RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2351RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002352endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2353
Ying Wang9a175682015-08-06 11:47:47 -07002354ifndef TARGET_PRIVATE_RES_DIRS
2355TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2356endif
Doug Zongker4647f122009-07-02 09:00:54 -07002357recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002358 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002359recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002360
2361
Andrew Boiefa61ff02012-09-28 09:33:45 -07002362ifdef TARGET_RECOVERY_FSTAB
2363recovery_fstab := $(TARGET_RECOVERY_FSTAB)
Cole Faust64c2ddb2022-01-07 12:44:31 -08002364else ifdef TARGET_RECOVERY_FSTAB_GENRULE
2365# Specifies a soong genrule module that generates an fstab.
2366recovery_fstab := $(call intermediates-dir-for,ETC,$(TARGET_RECOVERY_FSTAB_GENRULE))/$(TARGET_RECOVERY_FSTAB_GENRULE)
Andrew Boiefa61ff02012-09-28 09:33:45 -07002367else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002368recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002369endif
Tao Baoc3c17532016-06-10 10:11:54 -07002370ifdef TARGET_RECOVERY_WIPE
2371recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002372else
Tao Baoc3c17532016-06-10 10:11:54 -07002373recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002374endif
Tao Bao8beab692015-07-22 12:33:18 -07002375
Tao Bao6d5d6232018-03-09 17:04:42 -08002376# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002377# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002378# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2379# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002380#
2381# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002382# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002383# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002384# b) We build a single image that contains boot and recovery both - no recovery image to install
2385# (BOARD_USES_RECOVERY_AS_BOOT = true);
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002386# c) We include the recovery DTBO image within recovery - not needing the resource file as we
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002387# do bsdiff because boot and recovery will contain different number of entries
2388# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002389# d) We include the recovery ACPIO image within recovery - not needing the resource file as we
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002390# do bsdiff because boot and recovery will contain different number of entries
2391# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002392# e) We build a single image that contains vendor_boot and recovery both - no recovery image to
Yifan Hongef7a9712020-10-20 13:17:42 -07002393# install
2394# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002395
Tom Cherry2929cad2018-09-20 11:04:37 -07002396ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002397 $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002398 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002399# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002400RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2401ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002402else
Tao Bao8beab692015-07-22 12:33:18 -07002403RECOVERY_RESOURCE_ZIP :=
2404endif
Doug Zongker4647f122009-07-02 09:00:54 -07002405
Tao Bao139c7272018-07-31 13:26:54 -07002406INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2407
2408$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002409 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2410 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2411 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2412 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2413 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2414 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2415 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2416 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2417
2418# Parses the given list of build variables and writes their values as build properties if defined.
2419# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2420# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2421# $(1): Map from the build variable names to property names
2422# $(2): Output file
2423define append-recovery-ui-properties
2424echo "#" >> $(2)
2425echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2426echo "#" >> $(2)
2427$(foreach prop,$(1), \
2428 $(eval _varname := $(call word-colon,1,$(prop))) \
2429 $(eval _propname := $(call word-colon,2,$(prop))) \
2430 $(eval _value := $($(_varname))) \
2431 $(if $(_value), \
2432 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2433endef
2434
2435$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002436 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002437 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2438 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2439 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002440 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002441 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002442 $(hide) mkdir -p $(dir $@)
2443 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002444 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002445 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002446 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002447 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002448 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002449 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2450
Bob Badour5acd4362022-04-12 18:31:35 -07002451$(call declare-1p-target,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),build)
2452$(call declare-license-deps,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),\
2453 $(INSTALLED_BUILD_PROP_TARGET) $(INSTALLED_VENDOR_BUILD_PROP_TARGET) $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2454 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET))
2455
Yifan Hong33fd5d42020-09-24 18:18:26 -07002456# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2457# On device with dedicated recovery partition, the file should come from the boot
2458# ramdisk.
2459ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2460INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2461$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2462 $(copy-file-to-target)
Bob Badour5acd4362022-04-12 18:31:35 -07002463
2464$(call declare-1p-target,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),build)
2465$(call declare-license-deps,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),$(INSTALLED_RAMDISK_BUILD_PROP_TARGET))
Yifan Hong33fd5d42020-09-24 18:18:26 -07002466endif
2467
Yifan Hongc56931c2020-10-28 16:35:19 -07002468INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002469
Yifan Hong78860162020-10-28 14:15:21 -07002470ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002471INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002472# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002473ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002474ifdef INTERNAL_KERNEL_CMDLINE
2475 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002476endif # INTERNAL_KERNEL_CMDLINE != ""
2477endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002478ifdef BOARD_KERNEL_BASE
2479 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2480endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002481ifdef BOARD_KERNEL_PAGESIZE
2482 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2483endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002484ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002485ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2486 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2487else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002488 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2489endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002490endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002491ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2492 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2493endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002494ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2495 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2496endif
Yifan Hong3941a872020-10-28 16:33:06 -07002497endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002498ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2499 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2500endif
Doug Zongker4647f122009-07-02 09:00:54 -07002501
Yifan Hong881df392020-10-09 14:29:39 -07002502$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002503 $(INTERNAL_ROOT_FILES) \
2504 $(INSTALLED_RAMDISK_TARGET) \
2505 $(INTERNAL_RECOVERYIMAGE_FILES) \
2506 $(recovery_sepolicy) \
2507 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2508 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002509 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002510 $(recovery_resource_deps) \
2511 $(recovery_fstab)
2512 # Making recovery image
2513 mkdir -p $(TARGET_RECOVERY_OUT)
2514 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2515 # Copying baseline ramdisk...
2516 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2517 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2518 # Modifying ramdisk contents...
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002519 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init
Steve Muckleb3dda772020-03-11 16:03:07 -07002520 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2521 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2522 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2523 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2524 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2525 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2526 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2527 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2528 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2529 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2530 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2531 $(foreach item,$(recovery_fstab), \
2532 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2533 $(if $(strip $(recovery_wipe)), \
2534 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2535 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2536 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002537 $(hide) touch $@
2538
2539$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002540 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002541
Ying Wang747b9f12015-01-30 14:05:22 -08002542# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002543# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002544define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002545 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002546 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002547 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002548 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002549 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002550 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002551 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002552 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2553 $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +08002554 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002555 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot))), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002556 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002557 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2558 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002559 $(AVBTOOL) add_hash_footer --image $(1) $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS),\
2560 $(AVBTOOL) add_hash_footer --image $(1) $(call get-partition-size-argument,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)) --partition_name recovery $(INTERNAL_AVB_RECOVERY_SIGNING_ARGS) $(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)))
Ying Wang747b9f12015-01-30 14:05:22 -08002561endef
2562
Dan Willemsend120ac62020-06-12 02:39:34 +00002563recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002564ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002565 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002566endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002567ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002568 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002569endif
Tao Baof4866c72018-08-22 14:35:09 -07002570ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002571 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2572 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2573 else
2574 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2575 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002576endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002577ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002578 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002579endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002580ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002581 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002582endif
Tao Baof4866c72018-08-22 14:35:09 -07002583
Dan Willemsend120ac62020-06-12 02:39:34 +00002584ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002585$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002586$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002587 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002588 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Bob Badourebdefc02022-02-12 15:39:22 -08002589
Bob Badoura60beee2022-09-07 15:34:12 -07002590$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",bool)
Bob Badourebdefc02022-02-12 15:39:22 -08002591$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2592
Justin Yundd15ec12022-09-23 10:47:21 +09002593UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BOOTIMAGE_TARGET)
Tao Baof4866c72018-08-22 14:35:09 -07002594endif # BOARD_USES_RECOVERY_AS_BOOT
2595
Dan Willemsend120ac62020-06-12 02:39:34 +00002596$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002597 $(call build-recoveryimage-target, $@, \
2598 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002599
Tao Bao4594d0e2015-12-22 09:47:46 -08002600ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002601$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002602 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002603 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2604 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002605endif
Doug Zongker56588872012-08-20 15:38:58 -07002606
Bob Badourebdefc02022-02-12 15:39:22 -08002607
2608$(call declare-1p-container,$(INSTALLED_RECOVERYIMAGE_TARGET),)
2609$(call declare-container-license-deps,$(INSTALLED_RECOVERYIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2610
Justin Yundd15ec12022-09-23 10:47:21 +09002611UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_RECOVERYIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002612
Ying Wang747b9f12015-01-30 14:05:22 -08002613.PHONY: recoveryimage-nodeps
2614recoveryimage-nodeps:
2615 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002616 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2617 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002618
Chris Grossa784ef12019-04-22 11:09:57 -07002619else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002620RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002621endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002622
2623.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002624recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002625
Jiyong Park03eb0612017-10-04 21:22:41 +09002626ifneq ($(BOARD_NAND_PAGE_SIZE),)
2627$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002628endif
2629
Jiyong Park03eb0612017-10-04 21:22:41 +09002630ifneq ($(BOARD_NAND_SPARE_SIZE),)
2631$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002632endif
2633
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002634
Doug Zongker4647f122009-07-02 09:00:54 -07002635# -----------------------------------------------------------------
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002636# Build debug ramdisk and debug boot image.
Colin Cross79a76ec2022-03-21 15:06:11 -07002637INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002638ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
2639
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002640INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002641 $(ALL_DEFAULT_INSTALLED_MODULES))
2642
2643# Directories to be picked into the debug ramdisk.
2644# As these directories are all merged into one single cpio archive, the order
2645# matters. If there are multiple files with the same pathname, then the last one
2646# wins.
2647#
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002648# ramdisk-debug.img will merge the content from either ramdisk.img or
2649# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
2650# is set or not.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002651ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002652 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT)
2653 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002654else # BOARD_USES_RECOVERY_AS_BOOT == true
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002655 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT)
2656 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002657endif # BOARD_USES_RECOVERY_AS_BOOT != true
2658
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002659INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT)
2660INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES)
2661
2662# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
2663INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2664INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2665$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2666$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS)
2667$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2668 @echo "Installed file list: $@"
2669 $(hide) rm -f $@
2670 $(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT)
2671 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
2672 $(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2673 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2674
Bob Badourebdefc02022-02-12 15:39:22 -08002675$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_DEBUG_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07002676$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_DEBUG_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08002677
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002678ifdef BUILDING_DEBUG_BOOT_IMAGE
2679
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002680# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002681# the debug ramdisk, which is the original ramdisk plus additional
2682# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2683# When /force_debuggable is present, /init will load userdebug sepolicy
2684# and property files to allow adb root, if the device is unlocked.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002685INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
Bowgo Tsai0013f552019-03-20 17:59:52 +08002686
Bowgo Tsai610286a2021-04-23 11:31:32 +08002687$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002688$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2689 @echo "Target debug ramdisk: $@"
2690 $(hide) rm -f $@
2691 $(hide) mkdir -p $(dir $@)
2692 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002693
Bob Badourebdefc02022-02-12 15:39:22 -08002694$(call declare-1p-container,$(INSTALLED_DEBUG_RAMDISK_TARGET),)
2695$(call declare-container-license-deps,$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2696
Justin Yundd15ec12022-09-23 10:47:21 +09002697UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002698
Bowgo Tsai0013f552019-03-20 17:59:52 +08002699.PHONY: ramdisk_debug-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002700ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002701 @echo "make $@: ignoring dependencies"
2702 $(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET)
2703 $(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS)
2704 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002705
2706# -----------------------------------------------------------------
2707# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2708#
2709# Note: it's intentional to skip signing for boot-debug.img, because it
2710# can only be used if the device is unlocked with verification error.
Steve Muckleb3dda772020-03-11 16:03:07 -07002711ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002712 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002713 $(PRODUCT_OUT)/$(k).img)
2714else
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002715 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
Steve Muckleb3dda772020-03-11 16:03:07 -07002716endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002717
2718# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002719$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002720ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002721 INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_RECOVERYIMAGE_ARGS))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002722else
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002723 INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_BOOTIMAGE_ARGS))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002724endif
2725
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002726# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2727# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2728# Using a test key to sign boot-debug.img to continue booting with the mismatched
2729# public key, if the device is unlocked.
2730ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002731$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002732endif
2733
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002734BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2735INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2736# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002737# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002738define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002739$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),$(2))))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002740$(AVBTOOL) add_hash_footer \
2741 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002742 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),$(2)))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002743 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2744 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002745$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002746endef
2747
Steve Muckleb3dda772020-03-11 16:03:07 -07002748# $(1): output file
2749define build-debug-bootimage-target
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002750 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002751 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002752 $(BOARD_MKBOOTIMG_ARGS) --output $1
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002753 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
Steve Muckleb3dda772020-03-11 16:03:07 -07002754endef
2755
Bowgo Tsai0013f552019-03-20 17:59:52 +08002756# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002757$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002758 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002759 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002760
Bob Badoura60beee2022-09-07 15:34:12 -07002761$(call declare-container-license-metadata,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08002762$(call declare-container-license-deps,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(INSTALLED_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2763
Justin Yundd15ec12022-09-23 10:47:21 +09002764UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002765
Bowgo Tsai0013f552019-03-20 17:59:52 +08002766.PHONY: bootimage_debug-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002767bootimage_debug-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002768 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002769 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002770
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002771endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002772
Bowgo Tsai6a683672020-02-14 19:00:15 +08002773# -----------------------------------------------------------------
2774# vendor debug ramdisk
2775# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Colin Cross79a76ec2022-03-21 15:06:11 -07002776INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002777ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2778
Bowgo Tsai610286a2021-04-23 11:31:32 +08002779INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
Bowgo Tsai610286a2021-04-23 11:31:32 +08002780 $(ALL_DEFAULT_INSTALLED_MODULES))
2781
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002782# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk.
2783INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT)
2784INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002785
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002786# Exclude recovery files in the default vendor ramdisk if including a standalone
2787# recovery ramdisk in vendor_boot.
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002788ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002789 ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2790 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT)
2791 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
2792 endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true
2793endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002794
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002795INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT)
2796INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
2797
2798# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created.
2799INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2800INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2801$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2802$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS)
2803$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2804 @echo "Installed file list: $@"
2805 $(hide) rm -f $@
2806 $(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2807 $(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2808 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2809
Bob Badour5acd4362022-04-12 18:31:35 -07002810$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK))
2811$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK))
Bob Badourebdefc02022-02-12 15:39:22 -08002812
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002813INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
2814
Bowgo Tsai610286a2021-04-23 11:31:32 +08002815$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002816$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2817 $(hide) rm -f $@
2818 $(hide) mkdir -p $(dir $@)
2819 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002820
Petri Gyntherd7946d12021-03-10 12:38:15 -08002821INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2822$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002823 @echo "Target debug vendor ramdisk: $@"
Petri Gyntherd7946d12021-03-10 12:38:15 -08002824 $(copy-file-to-target)
Petri Gyntherd7946d12021-03-10 12:38:15 -08002825
Bob Badourebdefc02022-02-12 15:39:22 -08002826$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),)
2827$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2828
2829VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2830
Bowgo Tsai6a683672020-02-14 19:00:15 +08002831# -----------------------------------------------------------------
2832# vendor_boot-debug.img.
2833INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2834
2835# The util to sign vendor_boot-debug.img with a test key.
2836BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2837INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2838# $(1): the vendor bootimage to sign
2839define test-key-sign-vendor-bootimage
2840$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2841$(AVBTOOL) add_hash_footer \
2842 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002843 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsai6a683672020-02-14 19:00:15 +08002844 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2845 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2846$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2847endef
2848
2849ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2850$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2851endif
2852
2853# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002854$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002855$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002856 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002857 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002858 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2859 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2860
Bob Badourebdefc02022-02-12 15:39:22 -08002861$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),)
2862$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2863
2864VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
2865
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002866endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai6a683672020-02-14 19:00:15 +08002867
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002868# Appends a few test harness specific properties into the adb_debug.prop.
2869ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2870ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2871
2872INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES)))
2873INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2874$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET)
2875 $(hide) rm -f $@
2876 $(hide) mkdir -p $(dir $@)
2877ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET
2878 $(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@
2879endif
2880 $(hide) echo "" >> $@
2881 $(hide) echo "#" >> $@
2882 $(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@
2883 $(hide) echo "#" >> $@
2884 $(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \
2885 echo "$(line)" >> $@;)
2886
Bob Badour2f66fd12022-03-09 17:30:24 -08002887$(call declare-1p-target,$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET))
2888
Colin Cross79a76ec2022-03-21 15:06:11 -07002889INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002890INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
2891 $(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002892 $(ALL_DEFAULT_INSTALLED_MODULES))
2893
2894# The order is important here. The test harness ramdisk staging directory has to
2895# come last so that it can override the adb_debug.prop in the debug ramdisk
2896# staging directory.
2897INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2898INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
2899
2900ifdef BUILDING_DEBUG_BOOT_IMAGE
2901
Bowgo Tsai0013f552019-03-20 17:59:52 +08002902# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002903# The test harness ramdisk, which is based off debug_ramdisk, plus a
2904# few additional test-harness-specific properties in adb_debug.prop.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002905INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002906
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002907$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS)
2908$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2909 @echo "Target test harness ramdisk: $@"
2910 $(hide) rm -f $@
2911 $(hide) mkdir -p $(dir $@)
2912 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002913
Bob Badourebdefc02022-02-12 15:39:22 -08002914$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),)
2915$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS),$(PRODUCT_OUT)/:/)
2916
Justin Yundd15ec12022-09-23 10:47:21 +09002917UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002918
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002919.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002920ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002921 @echo "make $@: ignoring dependencies"
2922 $(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2923 $(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS)
2924 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002925
2926# -----------------------------------------------------------------
2927# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2928#
2929# Note: it's intentional to skip signing for boot-test-harness.img, because it
2930# can only be used if the device is unlocked with verification error.
Steve Muckle4866bd62020-04-02 11:31:08 -07002931ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2932 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2933 $(PRODUCT_OUT)/$(k).img)
2934else
2935 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2936endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002937
2938# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002939$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002940INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2941
2942# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2943# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2944# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2945# public key, if the device is unlocked.
2946ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2947$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2948endif
2949
Steve Muckle4866bd62020-04-02 11:31:08 -07002950# $(1): output file
2951define build-boot-test-harness-target
2952 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002953 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002954 $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002955 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002956endef
2957
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002958# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002959$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002960 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002961 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002962
Bob Badourebdefc02022-02-12 15:39:22 -08002963$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),)
2964$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2965
Justin Yundd15ec12022-09-23 10:47:21 +09002966UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002967
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002968.PHONY: bootimage_test_harness-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002969bootimage_test_harness-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002970 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002971 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002972
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002973endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002974
Bowgo Tsai87f60012021-07-29 23:35:33 +08002975# -----------------------------------------------------------------
2976# vendor test harness ramdisk, which is a vendor ramdisk combined with
2977# a test harness ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002978ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai87f60012021-07-29 23:35:33 +08002979
2980INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
2981
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002982# The order is important here. The test harness ramdisk staging directory has to
2983# come last so that it can override the adb_debug.prop in the debug ramdisk
2984# staging directory.
2985INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2986INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002987
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002988$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002989$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002990 $(hide) rm -f $@
2991 $(hide) mkdir -p $(dir $@)
2992 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai87f60012021-07-29 23:35:33 +08002993
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002994INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
2995$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2996 @echo "Target test harness vendor ramdisk: $@"
2997 $(copy-file-to-target)
2998
Bob Badourebdefc02022-02-12 15:39:22 -08002999$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),)
3000$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
3001
3002VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
3003
Bowgo Tsai87f60012021-07-29 23:35:33 +08003004# -----------------------------------------------------------------
3005# vendor_boot-test-harness.img.
3006INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
3007
3008ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
3009$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
3010endif
3011
3012# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
3013$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
3014$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
3015$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
3016 $(call pretty,"Target vendor_boot test harness image: $@")
3017 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
3018 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
3019 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
3020
Bob Badourebdefc02022-02-12 15:39:22 -08003021$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),)
3022$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
3023
3024VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
3025
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08003026endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
3027
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08003028endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
3029
Wei Lie64367c2023-03-29 17:40:36 -07003030PARTITION_COMPAT_SYMLINKS :=
Colin Crossbd382142020-08-26 15:08:57 -07003031# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
3032# $1: from location (e.g $(TARGET_OUT)/vendor)
3033# $2: destination location (e.g. /vendor)
3034# $3: partition image name (e.g. vendor.img)
3035define create-partition-compat-symlink
3036$(eval \
3037$1:
3038 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
3039 mkdir -p $(dir $1)
3040 if [ -d $1 ] && [ ! -h $1 ]; then \
3041 echo 'Non-symlink $1 detected!' 1>&2; \
3042 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
3043 exit 1; \
3044 fi
3045 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00003046$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07003047)
Wei Lie64367c2023-03-29 17:40:36 -07003048$(eval PARTITION_COMPAT_SYMLINKS += $1)
Colin Crossbd382142020-08-26 15:08:57 -07003049$1
3050endef
3051
3052
Inseob Kim135c1f12022-01-06 17:22:07 +09003053# FSVerity metadata generation
3054# Generate fsverity metadata files (.fsv_meta) and build manifest
Victor Hsieh89415a82022-09-09 14:16:33 -07003055# (<partition>/etc/security/fsverity/BuildManifest<suffix>.apk) BEFORE filtering systemimage,
3056# vendorimage, odmimage, productimage files below.
3057ifeq ($(PRODUCT_FSVERITY_GENERATE_METADATA),true)
Inseob Kim135c1f12022-01-06 17:22:07 +09003058
Victor Hsieh89415a82022-09-09 14:16:33 -07003059fsverity-metadata-targets-patterns := \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08003060 $(TARGET_OUT)/framework/% \
Inseob Kim135c1f12022-01-06 17:22:07 +09003061 $(TARGET_OUT)/etc/boot-image.prof \
3062 $(TARGET_OUT)/etc/dirty-image-objects \
Nicolas Geoffray13f28212022-03-18 17:28:14 +00003063 $(TARGET_OUT)/etc/preloaded-classes \
Victor Hsieh89415a82022-09-09 14:16:33 -07003064 $(TARGET_OUT)/etc/classpaths/%.pb \
3065
3066ifdef BUILDING_SYSTEM_EXT_IMAGE
3067fsverity-metadata-targets-patterns += $(TARGET_OUT_SYSTEM_EXT)/framework/%
3068endif
Victor Hsieh89415a82022-09-09 14:16:33 -07003069
3070# Generate fsv_meta
3071fsverity-metadata-targets := $(sort $(filter \
3072 $(fsverity-metadata-targets-patterns), \
Colin Crossa1de5df2022-03-21 14:31:31 -07003073 $(ALL_DEFAULT_INSTALLED_MODULES)))
Inseob Kim135c1f12022-01-06 17:22:07 +09003074
3075define fsverity-generate-metadata
Bob Badour2cd35362022-12-01 17:58:57 -08003076$(call declare-0p-target,$(1).fsv_meta)
3077
Inseob Kim135c1f12022-01-06 17:22:07 +09003078$(1).fsv_meta: PRIVATE_SRC := $(1)
3079$(1).fsv_meta: PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
3080$(1).fsv_meta: $(HOST_OUT_EXECUTABLES)/fsverity_metadata_generator $(HOST_OUT_EXECUTABLES)/fsverity $(1)
3081 $$< --fsverity-path $$(PRIVATE_FSVERITY) --signature none \
3082 --hash-alg sha256 --output $$@ $$(PRIVATE_SRC)
3083endef
3084
3085$(foreach f,$(fsverity-metadata-targets),$(eval $(call fsverity-generate-metadata,$(f))))
3086ALL_DEFAULT_INSTALLED_MODULES += $(addsuffix .fsv_meta,$(fsverity-metadata-targets))
3087
Inseob Kim135c1f12022-01-06 17:22:07 +09003088FSVERITY_APK_KEY_PATH := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Victor Hsieh89415a82022-09-09 14:16:33 -07003089FSVERITY_APK_MANIFEST_TEMPLATE_PATH := system/security/fsverity/AndroidManifest.xml
3090
3091# Generate and install BuildManifest<suffix>.apk for the given partition
3092# $(1): path of the output APK
3093# $(2): partition name
3094define fsverity-generate-and-install-manifest-apk
3095fsverity-metadata-targets-$(2) := $(filter $(PRODUCT_OUT)/$(2)/%,\
3096 $(fsverity-metadata-targets))
3097$(1): PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
3098$(1): PRIVATE_AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
3099$(1): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
3100$(1): PRIVATE_VERSION_CODE := $(PLATFORM_SDK_VERSION)
3101$(1): PRIVATE_VERSION_NAME := $(APPS_DEFAULT_VERSION_NAME)
3102$(1): PRIVATE_APKSIGNER := $(HOST_OUT_EXECUTABLES)/apksigner
3103$(1): PRIVATE_MANIFEST := $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH)
3104$(1): PRIVATE_FRAMEWORK_RES := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
3105$(1): PRIVATE_KEY := $(FSVERITY_APK_KEY_PATH)
3106$(1): PRIVATE_INPUTS := $$(fsverity-metadata-targets-$(2))
3107$(1): PRIVATE_ASSETS := $(call intermediates-dir-for,ETC,build_manifest-$(2))/assets
3108$(1): $(HOST_OUT_EXECUTABLES)/fsverity_manifest_generator \
Inseob Kim135c1f12022-01-06 17:22:07 +09003109 $(HOST_OUT_EXECUTABLES)/fsverity $(HOST_OUT_EXECUTABLES)/aapt2 \
Victor Hsieh89415a82022-09-09 14:16:33 -07003110 $(HOST_OUT_EXECUTABLES)/apksigner $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH) \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08003111 $(FSVERITY_APK_KEY_PATH).x509.pem $(FSVERITY_APK_KEY_PATH).pk8 \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09003112 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk \
Victor Hsieh89415a82022-09-09 14:16:33 -07003113 $$(fsverity-metadata-targets-$(2))
3114 rm -rf $$(PRIVATE_ASSETS)
3115 mkdir -p $$(PRIVATE_ASSETS)
Victor Hsieh89415a82022-09-09 14:16:33 -07003116 $$< --fsverity-path $$(PRIVATE_FSVERITY) \
3117 --base-dir $$(PRODUCT_OUT) \
3118 --output $$(PRIVATE_ASSETS)/build_manifest.pb \
3119 $$(PRIVATE_INPUTS)
Victor Hsieh89415a82022-09-09 14:16:33 -07003120 $$(PRIVATE_AAPT2) link -o $$@ \
3121 -A $$(PRIVATE_ASSETS) \
3122 -I $$(PRIVATE_FRAMEWORK_RES) \
3123 --min-sdk-version $$(PRIVATE_MIN_SDK_VERSION) \
3124 --version-code $$(PRIVATE_VERSION_CODE) \
3125 --version-name $$(PRIVATE_VERSION_NAME) \
3126 --manifest $$(PRIVATE_MANIFEST) \
3127 --rename-manifest-package com.android.security.fsverity_metadata.$(2)
3128 $$(PRIVATE_APKSIGNER) sign --in $$@ \
3129 --cert $$(PRIVATE_KEY).x509.pem \
3130 --key $$(PRIVATE_KEY).pk8
Inseob Kim135c1f12022-01-06 17:22:07 +09003131
Wei Li49933362023-01-04 17:13:47 -08003132$(1).idsig: $(1)
3133
3134ALL_DEFAULT_INSTALLED_MODULES += $(1) $(1).idsig
Inseob Kim135c1f12022-01-06 17:22:07 +09003135
Victor Hsieh89415a82022-09-09 14:16:33 -07003136endef # fsverity-generate-and-install-manifest-apk
3137
3138$(eval $(call fsverity-generate-and-install-manifest-apk, \
3139 $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk,system))
Wei Li49933362023-01-04 17:13:47 -08003140ALL_FSVERITY_BUILD_MANIFEST_APK += $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk.idsig
Victor Hsieh89415a82022-09-09 14:16:33 -07003141ifdef BUILDING_SYSTEM_EXT_IMAGE
3142 $(eval $(call fsverity-generate-and-install-manifest-apk, \
3143 $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk,system_ext))
Wei Li49933362023-01-04 17:13:47 -08003144 ALL_FSVERITY_BUILD_MANIFEST_APK += $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk.idsig
Victor Hsieh89415a82022-09-09 14:16:33 -07003145endif
Victor Hsieh89415a82022-09-09 14:16:33 -07003146
3147endif # PRODUCT_FSVERITY_GENERATE_METADATA
3148
3149
3150# -----------------------------------------------------------------
3151# system image
Inseob Kim135c1f12022-01-06 17:22:07 +09003152
Colin Cross79a76ec2022-03-21 15:06:11 -07003153INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen37a19862018-10-31 16:31:46 -07003154INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Dan Willemsena3f66322020-05-28 15:46:33 -07003155 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07003156
Colin Crossbd382142020-08-26 15:08:57 -07003157# Create symlink /system/vendor to /vendor if necessary.
3158ifdef BOARD_USES_VENDORIMAGE
Wei Lie64367c2023-03-29 17:40:36 -07003159 _vendor_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
3160 INTERNAL_SYSTEMIMAGE_FILES += $(_vendor_symlink)
3161 ALL_DEFAULT_INSTALLED_MODULES += $(_vendor_symlink)
Colin Crossbd382142020-08-26 15:08:57 -07003162endif
3163
3164# Create symlink /system/product to /product if necessary.
3165ifdef BOARD_USES_PRODUCTIMAGE
Wei Lie64367c2023-03-29 17:40:36 -07003166 _product_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
3167 INTERNAL_SYSTEMIMAGE_FILES += $(_product_symlink)
3168 ALL_DEFAULT_INSTALLED_MODULES += $(_product_symlink)
Colin Crossbd382142020-08-26 15:08:57 -07003169endif
3170
3171# Create symlink /system/system_ext to /system_ext if necessary.
3172ifdef BOARD_USES_SYSTEM_EXTIMAGE
Wei Lie64367c2023-03-29 17:40:36 -07003173 _systemext_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
3174 INTERNAL_SYSTEMIMAGE_FILES += $(_systemext_symlink)
3175 ALL_DEFAULT_INSTALLED_MODULES += $(_systemext_symlink)
Colin Crossbd382142020-08-26 15:08:57 -07003176endif
3177
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003178# -----------------------------------------------------------------
3179# system_dlkm partition image
3180
3181# Create symlinks for system_dlkm on devices with a system_dlkm partition:
3182# /system/lib/modules -> /system_dlkm/lib/modules
3183#
3184# On devices with a system_dlkm partition,
3185# - /system/lib/modules is a symlink to a directory that stores system DLKMs.
3186# - The system_dlkm partition is mounted at /system_dlkm at runtime.
Ramji Jiyani13a41372022-01-27 07:05:08 +00003187ifdef BOARD_USES_SYSTEM_DLKMIMAGE
Wei Lie64367c2023-03-29 17:40:36 -07003188 _system_dlkm_lib_modules_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/lib/modules,/system_dlkm/lib/modules,system_dlkm.img)
3189 INTERNAL_SYSTEMIMAGE_FILES += $(_system_dlkm_lib_modules_symlink)
3190 ALL_DEFAULT_INSTALLED_MODULES += $(_system_dlkm_lib_modules_symlink)
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003191endif
3192
Ying Wang82cceba2012-08-13 15:03:00 -07003193FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003194
3195# ASAN libraries in the system image - add dependency.
3196ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07003197ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07003198 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
3199 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
3200 endif
3201endif
3202
Tom Cherryd14b8952018-08-09 14:26:00 -07003203FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07003204
Ying Wange5e8c5f2011-09-09 16:35:53 -07003205# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08003206ifdef BUILDING_SYSTEM_IMAGE
3207
Kiyoung Kim36481e02020-11-16 10:50:05 +09003208# Install system linker configuration
3209# Collect all available stub libraries installed in system and install with predefined linker configuration
Kiyoung Kim0c079592022-12-01 10:15:10 +09003210# Also append LLNDK libraries in the APEX as required libs
Kiyoung Kim36481e02020-11-16 10:50:05 +09003211SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
Colin Crossd4a054f2022-03-15 15:07:07 -07003212SYSTEM_LINKER_CONFIG_SOURCE := $(call intermediates-dir-for,ETC,system_linker_config)/system_linker_config
3213$(SYSTEM_LINKER_CONFIG): PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE := $(SYSTEM_LINKER_CONFIG_SOURCE)
Jooyung Han49bf6912023-03-09 16:36:37 +09003214$(SYSTEM_LINKER_CONFIG): $(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE) | conv_linker_config
3215 @echo Creating linker config: $@
3216 @mkdir -p $(dir $@)
3217 @rm -f $@
Colin Crossd4a054f2022-03-15 15:07:07 -07003218 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE) \
Jooyung Han49bf6912023-03-09 16:36:37 +09003219 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
Kiyoung Kim0c079592022-12-01 10:15:10 +09003220 $(HOST_OUT_EXECUTABLES)/conv_linker_config append --source $@ --output $@ --key requireLibs \
Jooyung Han49bf6912023-03-09 16:36:37 +09003221 --value "$(foreach lib,$(LLNDK_MOVED_TO_APEX_LIBRARIES), $(lib).so)"
Kiyoung Kim36481e02020-11-16 10:50:05 +09003222
Bob Badour2f66fd12022-03-09 17:30:24 -08003223$(call declare-1p-target,$(SYSTEM_LINKER_CONFIG),)
Colin Crossd4a054f2022-03-15 15:07:07 -07003224$(call declare-license-deps,$(SYSTEM_LINKER_CONFIG),$(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE))
Bob Badour2f66fd12022-03-09 17:30:24 -08003225
Kiyoung Kim36481e02020-11-16 10:50:05 +09003226FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
Wei Li49933362023-01-04 17:13:47 -08003227ALL_DEFAULT_INSTALLED_MODULES += $(SYSTEM_LINKER_CONFIG)
Kiyoung Kim36481e02020-11-16 10:50:05 +09003228
Ying Wange5e8c5f2011-09-09 16:35:53 -07003229# installed file list
3230# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
3231# We put installed-files.txt ahead of image itself in the dependency graph
3232# so that we can get the size stat even if the build fails due to too large
3233# system image.
3234INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07003235INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
3236$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003237$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003238 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003239 mkdir -p $(dir $@)
3240 rm -f $@
3241 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
3242 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07003243
Bob Badourebdefc02022-02-12 15:39:22 -08003244$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE)))
Bob Badour5acd4362022-04-12 18:31:35 -07003245$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON)))
Bob Badourebdefc02022-02-12 15:39:22 -08003246
Ying Wange5e8c5f2011-09-09 16:35:53 -07003247.PHONY: installed-file-list
3248installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08003249
Ying Wange5e8c5f2011-09-09 16:35:53 -07003250systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003251 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003252BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
3253
The Android Open Source Project88b60792009-03-03 19:28:42 -08003254# $(1): output file
3255define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07003256 @echo "Target system fs image: $(1)"
3257 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003258 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07003259 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003260 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003261 $(BUILD_IMAGE) \
3262 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
3263 || ( mkdir -p $${DIST_DIR}; \
3264 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
3265 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08003266endef
3267
Dan Willemsen6b72c732019-06-12 21:33:38 +00003268ifeq ($(BOARD_AVB_ENABLE),true)
3269$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
3270endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07003271$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003272 $(call build-systemimage-target,$@)
3273
Bob Badour879cfa82021-04-15 10:41:38 -07003274$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
Bob Badourebdefc02022-02-12 15:39:22 -08003275$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:/)
Bob Badour879cfa82021-04-15 10:41:38 -07003276
Tao Baoe9d61b02018-08-20 21:09:07 -07003277INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07003278SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003279
Tao Baoe9d61b02018-08-20 21:09:07 -07003280# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
3281# compatibility, in case device-specific Makefiles still refer to the old name.
3282INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
3283
Doug Zongker73ef8252009-07-23 15:12:53 -07003284# The system partition needs room for the recovery image as well. We
3285# now store the recovery image as a binary patch using the boot image
3286# as the source (since they are very similar). Generate the patch so
3287# we can see how big it's going to be, and include that in the system
3288# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07003289ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07003290ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07003291ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08003292ifneq (,$(filter true,$(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08003293diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
3294else
3295diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
3296endif
Doug Zongker73ef8252009-07-23 15:12:53 -07003297intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
3298RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08003299$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
3300$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00003301 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07003302 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003303 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07003304 @echo "Construct recovery from boot"
3305 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07003306 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07003307else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
3308RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07003309endif # BOARD_USES_FULL_RECOVERY_IMAGE
3310endif # INSTALLED_RECOVERYIMAGE_TARGET
3311endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07003312
Yifan Hong9a3cad92020-04-27 19:06:59 -07003313$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003314 @echo "Install system fs image: $@"
3315 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003316 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003317
Bob Badour879cfa82021-04-15 10:41:38 -07003318$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
3319$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
3320
Tao Baoe9d61b02018-08-20 21:09:07 -07003321systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003322
Bob Badourebdefc02022-02-12 15:39:22 -08003323SYSTEM_NOTICE_DEPS += $(INSTALLED_SYSTEMIMAGE_TARGET)
Bob Badour879cfa82021-04-15 10:41:38 -07003324
The Android Open Source Project88b60792009-03-03 19:28:42 -08003325.PHONY: systemimage-nodeps snod
3326systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07003327 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003328 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07003329 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00003330 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08003331ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00003332 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08003333endif
3334
Dan Willemsen67495202019-01-16 12:42:05 -08003335endif # BUILDING_SYSTEM_IMAGE
3336
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07003337.PHONY: sync syncsys sync_system
3338sync syncsys sync_system: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07003339
Ying Wang3a61eeb2016-03-11 10:32:01 -08003340# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07003341# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07003342.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07003343platform:
3344 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07003345
3346.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07003347platform-java:
3348 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07003349
Ying Wang3a61eeb2016-03-11 10:32:01 -08003350# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003351# data partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003352INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_DATA)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003353INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003354 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003355
Dan Willemsen67495202019-01-16 12:42:05 -08003356ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07003357userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003358 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07003359BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
3360
Ying Wangbd93d422011-10-28 17:02:30 -07003361define build-userdataimage-target
3362 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
3363 @mkdir -p $(TARGET_OUT_DATA)
3364 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003365 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003366 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003367 $(BUILD_IMAGE) \
3368 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
3369 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
3370 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07003371endef
3372
Joe Onorato64d85d02009-04-09 19:31:12 -07003373# We just build this directly to the install location.
3374INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003375INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
3376 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003377 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003378$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003379 $(build-userdataimage-target)
3380
Bob Badourebdefc02022-02-12 15:39:22 -08003381$(call declare-1p-container,$(INSTALLED_USERDATAIMAGE_TARGET),)
3382$(call declare-container-license-deps,$(INSTALLED_USERDATAIMAGE_TARGET),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS),$(PRODUCT_OUT)/:/)
3383
Justin Yundd15ec12022-09-23 10:47:21 +09003384UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_USERDATAIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003385
The Android Open Source Project88b60792009-03-03 19:28:42 -08003386.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07003387userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003388 $(build-userdataimage-target)
3389
Dan Willemsen67495202019-01-16 12:42:05 -08003390endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07003391
Andreas Gampe039b5c72017-03-24 16:06:31 -07003392# ASAN libraries in the system image - build rule.
3393ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
3394 $(TARGET_OUT_SHARED_LIBRARIES) \
3395 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
3396 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
3397 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07003398# Extra options: Enforce the system user for the files to avoid having to change ownership.
3399ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07003400# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
3401# enough space.
3402$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07003403 tar cfj $(ASAN_IN_SYSTEM_INSTALLED) $(ASAN_SYSTEM_INSTALL_OPTIONS) -C $(TARGET_OUT_DATA)/.. $(ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL) >/dev/null
Andreas Gampe039b5c72017-03-24 16:06:31 -07003404
The Android Open Source Project88b60792009-03-03 19:28:42 -08003405# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04003406# partition table image
3407ifdef BOARD_BPT_INPUT_FILES
3408
3409BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003410BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04003411
3412INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
3413 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003414 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04003415 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
3416
3417ifdef BOARD_BPT_DISK_SIZE
3418INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
3419endif
3420
3421define build-bptimage-target
3422 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
3423 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
3424endef
3425
3426INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003427$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
3428 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
3429
David Zeuthen25328622016-04-08 15:08:03 -04003430$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
3431 $(build-bptimage-target)
3432
Bob Badourebdefc02022-02-12 15:39:22 -08003433$(call declare-1p-container,$(INSTALLED_BPTIMAGE_TARGET),)
3434$(call declare-container-license-deps,$(INSTALLED_BPTIMAGE_TARGET),$(BOARD_BPT_INPUT_FILES),$(PRODUCT_OUT)/:/)
3435
Justin Yundd15ec12022-09-23 10:47:21 +09003436UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BPTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003437
David Zeuthen25328622016-04-08 15:08:03 -04003438.PHONY: bptimage-nodeps
3439bptimage-nodeps:
3440 $(build-bptimage-target)
3441
3442endif # BOARD_BPT_INPUT_FILES
3443
3444# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07003445# cache partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003446INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_CACHE)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003447ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003448INTERNAL_CACHEIMAGE_FILES := \
3449 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
3450
3451cacheimage_intermediates := \
3452 $(call intermediates-dir-for,PACKAGING,cache)
3453BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
3454
3455define build-cacheimage-target
3456 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
3457 @mkdir -p $(TARGET_OUT_CACHE)
3458 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003459 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003460 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003461 $(BUILD_IMAGE) \
3462 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
3463 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
3464 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07003465endef
3466
3467# We just build this directly to the install location.
3468INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003469$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07003470 $(build-cacheimage-target)
3471
Bob Badourebdefc02022-02-12 15:39:22 -08003472$(call declare-1p-container,$(INSTALLED_CACHEIMAGE_TARGET),)
3473$(call declare-container-license-deps,$(INSTALLED_CACHEIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES),$(PRODUCT_OUT)/:/)
3474
Justin Yundd15ec12022-09-23 10:47:21 +09003475UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_CACHEIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003476
Ying Wang9f8e8db2011-11-04 11:37:01 -07003477.PHONY: cacheimage-nodeps
3478cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3479 $(build-cacheimage-target)
3480
Dan Willemsen67495202019-01-16 12:42:05 -08003481else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07003482# we need to ignore the broken cache link when doing the rsync
3483IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08003484endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003485
David Zeuthen0eb10972016-09-28 17:55:27 -04003486# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07003487# system_other partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003488INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_OTHER)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003489ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003490ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07003491# Marker file to identify that odex files are installed
3492INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
3493ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
3494$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
3495 $(hide) touch $@
Bob Badour2f66fd12022-03-09 17:30:24 -08003496
3497$(call declare-0p-target,$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER))
Alex Light4e358ab2016-06-16 14:47:10 -07003498endif
3499
Alex Light4e358ab2016-06-16 14:47:10 -07003500INTERNAL_SYSTEMOTHERIMAGE_FILES := \
3501 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003502 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07003503
Colin Cross6db5b0e2018-11-16 21:26:33 -08003504# system_other dex files are installed as a side-effect of installing system image files
3505INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
3506
Alex Light4e358ab2016-06-16 14:47:10 -07003507INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07003508INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
3509$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003510$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07003511 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003512 mkdir -p $(dir $@)
3513 rm -f $@
3514 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
3515 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07003516
Bob Badourebdefc02022-02-12 15:39:22 -08003517$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEMOTHER)))
Bob Badour5acd4362022-04-12 18:31:35 -07003518$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEMOTHER)))
Bob Badourebdefc02022-02-12 15:39:22 -08003519
Bowgo Tsai867ab662019-01-29 13:30:18 +08003520# Determines partition size for system_other.img.
3521ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
3522ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
3523INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
3524endif
3525endif
3526
3527ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
3528INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
3529endif
3530
Alex Light4e358ab2016-06-16 14:47:10 -07003531systemotherimage_intermediates := \
3532 $(call intermediates-dir-for,PACKAGING,system_other)
3533BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
3534
3535# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
3536define build-systemotherimage-target
3537 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
3538 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
3539 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003540 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003541 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003542 $(BUILD_IMAGE) \
3543 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
3544 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
3545 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07003546endef
3547
3548# We just build this directly to the install location.
3549INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003550ifneq (true,$(SANITIZE_LITE))
3551# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07003552$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
3553 $(build-systemotherimage-target)
Bob Badourebdefc02022-02-12 15:39:22 -08003554
3555$(call declare-1p-container,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),)
3556$(call declare-container-license-deps,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES),$(PRODUCT_OUT)/:/)
3557
3558UNMOUNTED_NOTICE_DEPS += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003559endif
Alex Light4e358ab2016-06-16 14:47:10 -07003560
3561.PHONY: systemotherimage-nodeps
3562systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3563 $(build-systemotherimage-target)
3564
Dan Willemsen67495202019-01-16 12:42:05 -08003565endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003566
3567
3568# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07003569# vendor partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003570INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003571ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07003572INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07003573 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003574 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07003575
Ying Wang8da19e32015-09-15 14:22:12 -07003576
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003577# Create symlink /vendor/odm to /odm if necessary.
3578ifdef BOARD_USES_ODMIMAGE
Wei Lie64367c2023-03-29 17:40:36 -07003579 _odm_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
3580 INTERNAL_VENDORIMAGE_FILES += $(_odm_symlink)
3581 ALL_DEFAULT_INSTALLED_MODULES += $(_odm_symlink)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003582endif
3583
Yifan Honge51dff22020-06-23 17:26:57 -07003584# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
3585# /vendor/lib/modules -> /vendor_dlkm/lib/modules
3586#
3587# On devices with a vendor_dlkm partition,
3588# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
3589# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
3590# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3591# are hidden.
3592# On devices without a vendor_dlkm partition,
3593# - /vendor/lib/modules stores vendor DLKMs directly.
3594# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
3595# See system/core/rootdir/Android.mk for a list of created symlinks.
3596# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
3597# are not guaranteed to exist on all devices.
3598ifdef BOARD_USES_VENDOR_DLKMIMAGE
Wei Lie64367c2023-03-29 17:40:36 -07003599 _vendor_dlkm_lib_modules_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/lib/modules,/vendor_dlkm/lib/modules,vendor_dlkm.img)
3600 INTERNAL_VENDORIMAGE_FILES += $(_vendor_dlkm_lib_modules_symlink)
3601 ALL_DEFAULT_INSTALLED_MODULES += $(_vendor_dlkm_lib_modules_symlink)
Yifan Honge51dff22020-06-23 17:26:57 -07003602endif
3603
Jooyung Han8c119032023-03-04 08:32:34 +09003604# Install vendor/etc/linker.config.pb with PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS and STUB_LIBRARIES
Jooyung Handa2d4a22023-01-09 16:26:23 +09003605vendor_linker_config_file := $(TARGET_OUT_VENDOR)/etc/linker.config.pb
3606$(vendor_linker_config_file): private_linker_config_fragments := $(PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS)
Jooyung Han63975d72023-03-07 18:25:02 +09003607$(vendor_linker_config_file): $(INTERNAL_VENDORIMAGE_FILES) $(PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS) | $(HOST_OUT_EXECUTABLES)/conv_linker_config
Jooyung Han49bf6912023-03-09 16:36:37 +09003608 @echo Creating linker config: $@
3609 @mkdir -p $(dir $@)
3610 @rm -f $@
Jooyung Handa2d4a22023-01-09 16:26:23 +09003611 $(HOST_OUT_EXECUTABLES)/conv_linker_config proto \
3612 --source $(call normalize-path-list,$(private_linker_config_fragments)) \
3613 --output $@
Jooyung Han8c119032023-03-04 08:32:34 +09003614 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $@ \
3615 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT_VENDOR)"
Jooyung Handa2d4a22023-01-09 16:26:23 +09003616$(call define declare-0p-target,$(vendor_linker_config_file),)
3617INTERNAL_VENDORIMAGE_FILES += $(vendor_linker_config_file)
Wei Li49933362023-01-04 17:13:47 -08003618ALL_DEFAULT_INSTALLED_MODULES += $(vendor_linker_config_file)
Jooyung Handa2d4a22023-01-09 16:26:23 +09003619
Colin Crossbd382142020-08-26 15:08:57 -07003620INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
3621INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3622$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
3623$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3624 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003625 mkdir -p $(dir $@)
3626 rm -f $@
3627 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
3628 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07003629
Bob Badour5acd4362022-04-12 18:31:35 -07003630$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR))
3631$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR))
Bob Badourebdefc02022-02-12 15:39:22 -08003632
Ying Wanga0febe52013-03-20 11:02:05 -07003633vendorimage_intermediates := \
3634 $(call intermediates-dir-for,PACKAGING,vendor)
3635BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003636define build-vendorimage-target
3637 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3638 @mkdir -p $(TARGET_OUT_VENDOR)
3639 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003640 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003641 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003642 $(BUILD_IMAGE) \
3643 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3644 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003645 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003646endef
3647
3648# We just build this directly to the install location.
3649INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003650$(INSTALLED_VENDORIMAGE_TARGET): \
3651 $(INTERNAL_USERIMAGES_DEPS) \
3652 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003653 $(INSTALLED_FILES_FILE_VENDOR) \
3654 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003655 $(build-vendorimage-target)
3656
Bob Badourebdefc02022-02-12 15:39:22 -08003657VENDOR_NOTICE_DEPS += $(INSTALLED_VENDORIMAGE_TARGET)
3658
Bob Badour5acd4362022-04-12 18:31:35 -07003659$(call declare-container-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08003660$(call declare-container-license-deps,$(INSTALLED_VENDORIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(RECOVERY_FROM_BOOT_PATH),$(PRODUCT_OUT)/:/)
3661
Steven Morelanda2e734d2017-03-07 12:10:09 -08003662.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003663vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003664 $(build-vendorimage-target)
3665
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07003666.PHONY: sync_vendor
3667sync sync_vendor: $(INTERNAL_VENDORIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07003668
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003669else ifdef BOARD_PREBUILT_VENDORIMAGE
3670INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3671$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
Bob Badour5acd4362022-04-12 18:31:35 -07003672$(if $(strip $(ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC)),,\
3673 $(if $(strip $(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
Bob Badourba337242022-05-27 19:40:41 -07003674 $(call declare-copy-target-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_PREBUILT_VENDORIMAGE)),\
Bob Badour5acd4362022-04-12 18:31:35 -07003675 $(call declare-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)))
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003676endif
Ying Wanga0febe52013-03-20 11:02:05 -07003677
Ying Wang9f8e8db2011-11-04 11:37:01 -07003678# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003679# product partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003680INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_PRODUCT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003681ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003682INTERNAL_PRODUCTIMAGE_FILES := \
3683 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003684 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003685
3686INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003687INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3688$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003689$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003690 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003691 mkdir -p $(dir $@)
3692 rm -f $@
3693 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3694 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003695
Bob Badour5acd4362022-04-12 18:31:35 -07003696$(call declare-0p-target,$(INSTALLED_FILES_FILE_PRODUCT))
3697$(call declare-0p-target,$(INSTALLED_FILES_JSON_PRODUCT))
Bob Badourebdefc02022-02-12 15:39:22 -08003698
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003699productimage_intermediates := \
3700 $(call intermediates-dir-for,PACKAGING,product)
3701BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3702define build-productimage-target
3703 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3704 @mkdir -p $(TARGET_OUT_PRODUCT)
3705 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003706 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003707 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003708 $(BUILD_IMAGE) \
3709 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3710 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3711 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003712endef
3713
3714# We just build this directly to the install location.
3715INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003716$(INSTALLED_PRODUCTIMAGE_TARGET): \
3717 $(INTERNAL_USERIMAGES_DEPS) \
3718 $(INTERNAL_PRODUCTIMAGE_FILES) \
3719 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003720 $(build-productimage-target)
3721
Bob Badourebdefc02022-02-12 15:39:22 -08003722PRODUCT_NOTICE_DEPS += $(INSTALLED_PRODUCTIMAGE_TARGET)
3723
3724$(call declare-1p-container,$(INSTALLED_PRODUCTIMAGE_TARGET),)
3725$(call declare-container-license-deps,$(INSTALLED_PRODUCTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT),$(PRODUCT_OUT)/:/)
3726
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003727.PHONY: productimage-nodeps pnod
3728productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3729 $(build-productimage-target)
3730
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07003731.PHONY: sync_product
3732sync sync_product: $(INTERNAL_PRODUCTIMAGE_FILES)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003733
3734else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3735INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3736$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3737endif
3738
3739# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003740# system_ext partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003741INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_EXT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Justin Yun6151e3f2019-06-25 15:58:13 +09003742ifdef BUILDING_SYSTEM_EXT_IMAGE
3743INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3744 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003745 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003746
Justin Yun6151e3f2019-06-25 15:58:13 +09003747INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3748INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3749$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3750$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003751 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003752 mkdir -p $(dir $@)
3753 rm -f $@
3754 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3755 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003756
Bob Badour5acd4362022-04-12 18:31:35 -07003757$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_EXT))
3758$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_EXT))
Bob Badourebdefc02022-02-12 15:39:22 -08003759
Justin Yun6151e3f2019-06-25 15:58:13 +09003760system_extimage_intermediates := \
3761 $(call intermediates-dir-for,PACKAGING,system_ext)
3762BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3763define build-system_extimage-target
3764 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3765 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3766 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3767 $(call generate-image-prop-dictionary, $(system_extimage_intermediates)/system_ext_image_info.txt,system_ext, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003768 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003769 $(BUILD_IMAGE) \
3770 $(TARGET_OUT_SYSTEM_EXT) \
3771 $(system_extimage_intermediates)/system_ext_image_info.txt \
3772 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3773 $(TARGET_OUT)
3774 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003775endef
3776
3777# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003778INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003779$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3780 $(INTERNAL_USERIMAGES_DEPS) \
3781 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3782 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003783 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003784
Bob Badourebdefc02022-02-12 15:39:22 -08003785SYSTEM_EXT_NOTICE_DEPS += $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
3786
3787$(call declare-1p-container,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),)
3788$(call declare-container-license-deps,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_EXT),$(PRODUCT_OUT)/:/)
3789
Justin Yun6151e3f2019-06-25 15:58:13 +09003790.PHONY: systemextimage-nodeps senod
3791systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3792 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003793
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07003794.PHONY: sync_system_ext
3795sync sync_system_ext: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003796
Justin Yun6151e3f2019-06-25 15:58:13 +09003797else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3798INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3799$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003800endif
3801
3802# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003803# odm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003804INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003805ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003806INTERNAL_ODMIMAGE_FILES := \
3807 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003808 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003809
Colin Crossbd382142020-08-26 15:08:57 -07003810# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3811# /odm/lib/modules -> /odm_dlkm/lib/modules
3812#
3813# On devices with a odm_dlkm partition,
3814# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3815# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3816# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3817# are hidden.
3818# On devices without a odm_dlkm partition,
3819# - /odm/lib/modules stores odm DLKMs directly.
3820# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3821# See system/core/rootdir/Android.mk for a list of created symlinks.
3822# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3823# are not guaranteed to exist on all devices.
3824ifdef BOARD_USES_ODM_DLKMIMAGE
Wei Lie64367c2023-03-29 17:40:36 -07003825 _odm_dlkm_lib_modules_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3826 INTERNAL_ODMIMAGE_FILES += $(_odm_dlkm_lib_modules_symlink)
3827 ALL_DEFAULT_INSTALLED_MODULES += $(_odm_dlkm_lib_modules_symlink)
Colin Crossbd382142020-08-26 15:08:57 -07003828endif
3829
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003830INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3831INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3832$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003833$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003834 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003835 mkdir -p $(dir $@)
3836 rm -f $@
3837 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3838 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003839
Bob Badour5acd4362022-04-12 18:31:35 -07003840$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM))
3841$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM))
Bob Badourebdefc02022-02-12 15:39:22 -08003842
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003843odmimage_intermediates := \
3844 $(call intermediates-dir-for,PACKAGING,odm)
3845BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3846define build-odmimage-target
3847 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3848 @mkdir -p $(TARGET_OUT_ODM)
3849 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003850 $(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
3851 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003852 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003853 $(BUILD_IMAGE) \
3854 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3855 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3856 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003857endef
3858
3859# We just build this directly to the install location.
3860INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003861$(INSTALLED_ODMIMAGE_TARGET): \
3862 $(INTERNAL_USERIMAGES_DEPS) \
3863 $(INTERNAL_ODMIMAGE_FILES) \
3864 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003865 $(build-odmimage-target)
3866
Bob Badourebdefc02022-02-12 15:39:22 -08003867ODM_NOTICE_DEPS += $(INSTALLED_ODMIMAGE_TARGET)
3868
3869$(call declare-1p-container,$(INSTALLED_ODMIMAGE_TARGET),)
3870$(call declare-container-license-deps,$(INSTALLED_ODMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM),$(PRODUCT_OUT)/:/)
3871
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003872.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003873odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003874 $(build-odmimage-target)
3875
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07003876.PHONY: sync_odm
3877sync sync_odm: $(INTERNAL_ODMIMAGE_FILES)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003878
3879else ifdef BOARD_PREBUILT_ODMIMAGE
3880INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3881$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3882endif
3883
3884# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003885# vendor_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003886INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003887ifdef BUILDING_VENDOR_DLKM_IMAGE
3888INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3889 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003890 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003891
3892INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3893INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3894$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3895$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3896 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003897 mkdir -p $(dir $@)
3898 rm -f $@
3899 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3900 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003901
Bob Badour5acd4362022-04-12 18:31:35 -07003902$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DLKM))
3903$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003904
Yifan Hongcfb917a2020-05-07 14:58:20 -07003905vendor_dlkmimage_intermediates := \
3906 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3907BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3908define build-vendor_dlkmimage-target
3909 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3910 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3911 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003912 $(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
3913 vendor_dlkm, skip_fsck=true)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003914 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3915 $(BUILD_IMAGE) \
3916 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3917 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3918 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3919endef
3920
3921# We just build this directly to the install location.
3922INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3923$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3924 $(INTERNAL_USERIMAGES_DEPS) \
3925 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3926 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3927 $(build-vendor_dlkmimage-target)
3928
Bob Badourebdefc02022-02-12 15:39:22 -08003929VENDOR_DLKM_NOTICE_DEPS += $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
3930
3931$(call declare-1p-container,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),)
3932$(call declare-container-license-deps,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR_DLKM),$(PRODUCT_OUT)/:/)
3933
Yifan Hongcfb917a2020-05-07 14:58:20 -07003934.PHONY: vendor_dlkmimage-nodeps vdnod
3935vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3936 $(build-vendor_dlkmimage-target)
3937
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07003938.PHONY: sync_vendor_dlkm
3939sync sync_vendor_dlkm: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003940
3941else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3942INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3943$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3944endif
3945
3946# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003947# odm_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003948INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003949ifdef BUILDING_ODM_DLKM_IMAGE
3950INTERNAL_ODM_DLKMIMAGE_FILES := \
3951 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003952 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003953
3954INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3955INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3956$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3957$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3958 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003959 mkdir -p $(dir $@)
3960 rm -f $@
3961 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3962 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003963
Bob Badour5acd4362022-04-12 18:31:35 -07003964$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM_DLKM))
3965$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003966
Yifan Hongf496f1b2020-07-15 16:52:59 -07003967odm_dlkmimage_intermediates := \
3968 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3969BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3970define build-odm_dlkmimage-target
3971 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3972 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3973 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003974 $(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
3975 odm_dlkm, skip_fsck=true)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003976 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3977 $(BUILD_IMAGE) \
3978 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3979 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3980 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3981endef
3982
3983# We just build this directly to the install location.
3984INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3985$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3986 $(INTERNAL_USERIMAGES_DEPS) \
3987 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3988 $(INSTALLED_FILES_FILE_ODM_DLKM)
3989 $(build-odm_dlkmimage-target)
3990
Bob Badourebdefc02022-02-12 15:39:22 -08003991ODM_DLKM_NOTICE_DEPS += $(INSTALLED_ODM_DLKMIMAGE_TARGET)
3992
3993$(call declare-1p-container,$(INSTALLED_ODM_DLKMIMAGE_TARGET),)
3994$(call declare-container-license-deps,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM_DLKM),$(PRODUCT_OUT)/:/)
3995
Yifan Hongf496f1b2020-07-15 16:52:59 -07003996.PHONY: odm_dlkmimage-nodeps odnod
3997odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3998 $(build-odm_dlkmimage-target)
3999
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07004000.PHONY: sync_odm_dlkm
4001sync sync_odm_dlkm: $(INTERNAL_ODM_DLKMIMAGE_FILES)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004002
4003else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4004INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
4005$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
4006endif
4007
Ramji Jiyani13a41372022-01-27 07:05:08 +00004008# -----------------------------------------------------------------
4009# system_dlkm partition image
4010
Colin Cross79a76ec2022-03-21 15:06:11 -07004011INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Ramji Jiyani13a41372022-01-27 07:05:08 +00004012ifdef BUILDING_SYSTEM_DLKM_IMAGE
4013
4014INTERNAL_SYSTEM_DLKMIMAGE_FILES := \
4015 $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,\
4016 $(ALL_DEFAULT_INSTALLED_MODULES))
4017
4018INSTALLED_FILES_FILE_SYSTEM_DLKM := $(PRODUCT_OUT)/installed-files-system_dlkm.txt
4019INSTALLED_FILES_JSON_SYSTEM_DLKM := $(INSTALLED_FILES_FILE_SYSTEM_DLKM:.txt=.json)
4020$(INSTALLED_FILES_FILE_SYSTEM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_DLKM)
4021$(INSTALLED_FILES_FILE_SYSTEM_DLKM): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
4022 @echo Installed file list: $@
4023 mkdir -p $(dir $@)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004024 rm -f $@
4025 $(FILESLIST) $(TARGET_OUT_SYSTEM_DLKM) > $(@:.txt=.json)
4026 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
4027
Bob Badour5acd4362022-04-12 18:31:35 -07004028$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_DLKM))
4029$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08004030
Ramji Jiyani13a41372022-01-27 07:05:08 +00004031system_dlkmimage_intermediates := \
4032 $(call intermediates-dir-for,PACKAGING,system_dlkm)
4033BUILT_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
4034define build-system_dlkmimage-target
4035 $(call pretty,"Target system_dlkm fs image: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)")
4036 @mkdir -p $(TARGET_OUT_SYSTEM_DLKM)
4037 @mkdir -p $(system_dlkmimage_intermediates) && rm -rf $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt
4038 $(call generate-image-prop-dictionary, $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt, \
4039 system_dlkm, skip_fsck=true)
4040 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
4041 $(BUILD_IMAGE) \
4042 $(TARGET_OUT_SYSTEM_DLKM) $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt \
4043 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(TARGET_OUT)
4044 $(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
4045endef
4046
4047# We just build this directly to the install location.
4048INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
4049$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): \
4050 $(INTERNAL_USERIMAGES_DEPS) \
4051 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
4052 $(INSTALLED_FILES_FILE_SYSTEM_DLKM)
4053 $(build-system_dlkmimage-target)
4054
Bob Badour56e0de52022-08-02 17:46:48 +00004055SYSTEM_DLKM_NOTICE_DEPS += $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
4056
4057$(call declare-1p-container,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),)
4058$(call declare-container-license-deps,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_DLKM),$(PRODUCT_OUT)/:/)
4059
Ramji Jiyani13a41372022-01-27 07:05:08 +00004060.PHONY: system_dlkmimage-nodeps sdnod
4061system_dlkmimage-nodeps sdnod: | $(INTERNAL_USERIMAGES_DEPS)
4062 $(build-system_dlkmimage-target)
4063
Peter Kalauskasdf6fdee2023-04-28 11:45:07 -07004064.PHONY: sync_system_dlkm
4065sync sync_system_dlkm: $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004066
4067else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
4068INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
4069$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_DLKMIMAGE),$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)))
4070endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004071
4072# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07004073# dtbo image
4074ifdef BOARD_PREBUILT_DTBOIMAGE
4075INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
4076
4077ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004078$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07004079 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
Peter Collingbournefd95f092023-03-24 11:34:24 -07004080 chmod +w $@
Yueyao Zhu211c9012017-04-27 00:34:50 -07004081 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00004082 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08004083 $(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
Anton Hansson6d814982018-11-26 18:12:05 +00004084 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
4085 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08004086
4087$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_TARGET),)
4088$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_TARGET),$(BOARD_PREBUILT_DTBOIMAGE),$(PRODUCT_OUT)/:/)
4089
Justin Yundd15ec12022-09-23 10:47:21 +09004090UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07004091else
4092$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
4093 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
4094endif
4095
Tao Bao0da43472018-08-22 22:53:41 -07004096endif # BOARD_PREBUILT_DTBOIMAGE
4097
Andrew Scull9b103e42020-11-29 14:04:28 +00004098# -----------------------------------------------------------------
4099# Protected VM firmware image
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02004100ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Pierre-Clément Tosiadbf4da2022-09-09 15:57:58 +01004101
4102.PHONY: pvmfwimage
4103pvmfwimage: $(INSTALLED_PVMFWIMAGE_TARGET)
4104
Andrew Scull9b103e42020-11-29 14:04:28 +00004105INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00004106INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01004107INSTALLED_PVMFW_BINARY_TARGET := $(call module-installed-files,pvmfw_bin)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01004108INTERNAL_PVMFWIMAGE_FILES := $(call module-target-built-files,pvmfw_img)
Pierre-Clément Tosi615f0812022-10-26 16:05:16 +01004109INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,pvmfw_embedded_key)
Jiyong Parke219f002022-12-16 14:30:03 +09004110INTERNAL_PVMFW_SYMBOL := $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/pvmfw
Bob Badourebdefc02022-02-12 15:39:22 -08004111
4112$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01004113$(call declare-container-license-deps,$(INSTALLED_PVMFWIMAGE_TARGET),$(INTERNAL_PVMFWIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badourebdefc02022-02-12 15:39:22 -08004114
Justin Yundd15ec12022-09-23 10:47:21 +09004115UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_PVMFWIMAGE_TARGET)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01004116
Jiyong Parke219f002022-12-16 14:30:03 +09004117# Place the unstripped pvmfw image to the symbols directory
4118$(INTERNAL_PVMFWIMAGE_FILES): |$(INTERNAL_PVMFW_SYMBOL)
4119
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01004120$(eval $(call copy-one-file,$(INTERNAL_PVMFWIMAGE_FILES),$(INSTALLED_PVMFWIMAGE_TARGET)))
Andrew Scull9b103e42020-11-29 14:04:28 +00004121
Andrew Scullbbc930b2022-02-17 22:34:27 +00004122$(INSTALLED_PVMFWIMAGE_TARGET): $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)
4123
4124$(eval $(call copy-one-file,$(INTERNAL_PVMFW_EMBEDDED_AVBKEY),$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)))
4125
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02004126endif # BOARD_USES_PVMFWIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00004127
Tao Bao0da43472018-08-22 22:53:41 -07004128# Returns a list of image targets corresponding to the given list of partitions. For example, it
4129# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
4130# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09004131# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07004132define images-for-partitions
Bowgo Tsai4f62aa02022-01-04 14:21:39 +08004133$(strip $(foreach item,$(1),\
4134 $(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
4135 $(if $(filter $(item),init_boot),$(INSTALLED_INIT_BOOT_IMAGE_TARGET),\
Ramji Jiyani13a41372022-01-27 07:05:08 +00004136 $(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))))
Tao Bao0da43472018-08-22 22:53:41 -07004137endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07004138
4139# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07004140# custom images
4141INSTALLED_CUSTOMIMAGES_TARGET :=
4142
4143ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4144INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
4145
4146# Sign custom image.
4147# $(1): the prebuilt custom image.
4148# $(2): the mount point of the prebuilt custom image.
4149# $(3): the signed custom image target.
4150define sign_custom_image
4151$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
4152 @echo Target custom image: $(3)
4153 mkdir -p $(dir $(3))
4154 cp $(1) $(3)
4155ifeq ($(BOARD_AVB_ENABLE),true)
4156 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
4157 $(AVBTOOL) add_hashtree_footer \
4158 --image $(3) \
4159 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
4160 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08004161 $(call get-partition-size-argument,$(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE)) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004162 --partition_name $(2) \
4163 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
4164 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
4165endif
4166INSTALLED_CUSTOMIMAGES_TARGET += $(3)
4167endef
4168
4169$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4170 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
4171 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
4172endif
4173
4174# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004175# vbmeta image
4176ifeq ($(BOARD_AVB_ENABLE),true)
4177
4178BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004179AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004180
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004181ifdef BOARD_AVB_KEY_PATH
4182$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
4183else
4184# If key path isn't specified, use the 4096-bit test key.
4185BOARD_AVB_ALGORITHM := SHA256_RSA4096
4186BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
4187endif
4188
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004189# AVB signing for system_other.img.
4190ifdef BUILDING_SYSTEM_OTHER_IMAGE
4191ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
4192$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
4193else
4194# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
4195BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
4196BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
4197endif
4198
Bowgo Tsaie4544b12019-02-27 10:15:51 +08004199$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
4200 @echo Extracting system_other avb key: $@
4201 @rm -f $@
4202 @mkdir -p $(dir $@)
4203 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08004204
Bob Badourebdefc02022-02-12 15:39:22 -08004205$(eval $(call declare-0p-target,$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET),))
4206
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004207ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
4208BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
4209endif
4210
4211BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
4212endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
4213
Tao Bao744c4c72018-08-20 21:09:07 -07004214INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07004215 $(BOARD_AVB_VBMETA_SYSTEM) \
Kelvin Zhangb81b4e32023-01-10 10:37:56 -08004216 $(BOARD_AVB_VBMETA_VENDOR) \
4217 $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))))
Tao Bao744c4c72018-08-20 21:09:07 -07004218
4219# Not allowing the same partition to appear in multiple groups.
4220ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07004221 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07004222endif
4223
cfig1aeef722019-09-20 22:45:06 +08004224# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
4225# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
4226# details.
Yifan Hong65afc072020-04-17 10:08:10 -07004227ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08004228ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4229$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07004230 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08004231 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
4232endif
4233endif
4234
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004235# Appends os version as a AVB property descriptor.
4236SYSTEM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4237BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
4238 --prop com.android.build.system.os_version:$(SYSTEM_OS_VERSION)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004239
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004240PRODUCT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4241BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
4242 --prop com.android.build.product.os_version:$(PRODUCT_OS_VERSION)
4243
4244SYSTEM_EXT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4245BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
4246 --prop com.android.build.system_ext.os_version:$(SYSTEM_EXT_OS_VERSION)
4247
4248INIT_BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4249BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4250 --prop com.android.build.init_boot.os_version:$(INIT_BOOT_OS_VERSION)
4251
4252BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4253BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4254 --prop com.android.build.boot.os_version:$(BOOT_OS_VERSION)
4255
4256VENDOR_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4257BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4258 --prop com.android.build.vendor.os_version:$(VENDOR_OS_VERSION)
4259
4260ODM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4261BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4262 --prop com.android.build.odm.os_version:$(ODM_OS_VERSION)
4263
4264VENDOR_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4265BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4266 --prop com.android.build.vendor_dlkm.os_version:$(VENDOR_DLKM_OS_VERSION)
4267
4268ODM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4269BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4270 --prop com.android.build.odm_dlkm.os_version:$(ODM_DLKM_OS_VERSION)
4271
4272SYSTEM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4273BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4274 --prop com.android.build.system_dlkm.os_version:$(SYSTEM_DLKM_OS_VERSION)
4275
4276# Appends fingerprint and security patch level as a AVB property descriptor.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004277BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004278 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004279 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
4280
4281BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004282 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004283 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
4284
Justin Yun6151e3f2019-06-25 15:58:13 +09004285BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004286 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004287 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004288
Bowgo Tsai9b548012019-05-14 16:57:03 +08004289BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsai8c7f8202022-02-22 14:47:45 +08004290 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004291
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004292BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004293 --prop com.android.build.init_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004294
Tao Bao19b02fe2019-10-09 00:04:28 -07004295BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
4296 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4297
Lucas Weif57333f2022-02-24 10:30:15 +08004298BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS += \
4299 --prop com.android.build.vendor_kernel_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4300
Tao Bao19b02fe2019-10-09 00:04:28 -07004301BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
4302 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4303
Bowgo Tsai9b548012019-05-14 16:57:03 +08004304BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004305 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004306
4307BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004308 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004309
Yifan Hongcfb917a2020-05-07 14:58:20 -07004310BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004311 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004312
Yifan Hongf496f1b2020-07-15 16:52:59 -07004313BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004314 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004315
Ramji Jiyani13a41372022-01-27 07:05:08 +00004316BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004317 --prop com.android.build.system_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004318
Tao Bao19b02fe2019-10-09 00:04:28 -07004319BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
4320 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4321
Andrew Scull9b103e42020-11-29 14:04:28 +00004322BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4323 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4324
Bowgo Tsai9b548012019-05-14 16:57:03 +08004325# The following vendor- and odm-specific images needs explicit SPL set per board.
Devin Moore380d9e42021-11-04 19:01:19 +00004326# TODO(b/210875415) Is this security_patch property used? Should it be removed from
4327# boot.img when there is no platform ramdisk included in it?
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004328ifdef BOOT_SECURITY_PATCH
4329BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4330 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004331endif
4332
4333ifdef INIT_BOOT_SECURITY_PATCH
4334BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4335 --prop com.android.build.init_boot.security_patch:$(INIT_BOOT_SECURITY_PATCH)
4336else ifdef BOOT_SECURITY_PATCH
Devin Moore380d9e42021-11-04 19:01:19 +00004337BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4338 --prop com.android.build.init_boot.security_patch:$(BOOT_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004339endif
4340
4341ifdef VENDOR_SECURITY_PATCH
4342BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4343 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
4344endif
4345
4346ifdef ODM_SECURITY_PATCH
4347BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4348 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
4349endif
4350
Yifan Hongcfb917a2020-05-07 14:58:20 -07004351ifdef VENDOR_DLKM_SECURITY_PATCH
4352BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4353 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
4354endif
4355
Yifan Hongf496f1b2020-07-15 16:52:59 -07004356ifdef ODM_DLKM_SECURITY_PATCH
4357BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4358 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
4359endif
4360
Ramji Jiyani13a41372022-01-27 07:05:08 +00004361ifdef SYSTEM_DLKM_SECURITY_PATCH
4362BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4363 --prop com.android.build.system_dlkm.security_patch:$(SYSTEM_DLKM_SECURITY_PATCH)
4364endif
4365
Andrew Scull9b103e42020-11-29 14:04:28 +00004366ifdef PVMFW_SECURITY_PATCH
4367BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4368 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
4369endif
4370
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004371BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Devin Moore380d9e42021-11-04 19:01:19 +00004372INIT_BOOT_FOOTER_ARGS := BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07004373VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Lucas Weif57333f2022-02-24 10:30:15 +08004374VENDOR_KERNEL_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004375DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00004376PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004377SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
4378VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05004379RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004380PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09004381SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004382ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07004383VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07004384ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Ramji Jiyani13a41372022-01-27 07:05:08 +00004385SYSTEM_DLKM_FOOTER_ARGS := BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004386
Tao Bao0da43472018-08-22 22:53:41 -07004387# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004388# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07004389define _check-and-set-avb-chain-args
4390$(eval part := $(1))
4391$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004392
4393$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
4394$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
4395$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
4396$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4397$(if $($(_key_path)),,$(error $(_key_path) is not defined))
4398$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
4399$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
4400$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4401
4402# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
4403$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
4404$(eval $(_signing_args) := \
4405 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
4406
cfig1aeef722019-09-20 22:45:06 +08004407# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
4408# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07004409$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08004410 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4411 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004412
Tao Bao744c4c72018-08-20 21:09:07 -07004413# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07004414# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07004415$(if $(filter $(part),$(part:vbmeta_%=%)),\
4416 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
4417 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004418endef
4419
Tao Bao0da43472018-08-22 22:53:41 -07004420# Checks and sets the required build variables for an AVB partition. The partition will be
4421# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07004422# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
4423# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004424# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
4425# but vbmeta would capture the image descriptor of only the first boot
4426# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07004427# $(1): Partition name, e.g. boot or system.
4428define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07004429$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07004430$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07004431 $(if $(_in_chained_vbmeta),\
4432 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07004433 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07004434 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004435 $(if $(filter boot,$(1)),\
4436 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4437 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
4438 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4439 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07004440endef
4441
Hongguang Chenf23364d2020-04-27 18:36:36 -07004442# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
4443# $(1): the custom partition to enable AVB chain.
4444define check-and-set-custom-avb-chain-args
4445$(eval part := $(1))
4446$(eval PART=$(call to-upper,$(part)))
4447$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4448$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4449
4450INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4451 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
4452endef
4453
Tao Baob1a2e352018-08-14 16:17:12 -07004454ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004455$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07004456endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004457
Devin Moore380d9e42021-11-04 19:01:19 +00004458ifdef INSTALLED_INIT_BOOT_IMAGE_TARGET
4459$(eval $(call check-and-set-avb-args,init_boot))
4460endif
4461
Steve Mucklee1b10862019-07-10 10:49:37 -07004462ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4463$(eval $(call check-and-set-avb-args,vendor_boot))
4464endif
4465
Lucas Weif57333f2022-02-24 10:30:15 +08004466ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
4467$(eval $(call check-and-set-avb-args,vendor_kernel_boot))
4468endif
4469
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004470ifdef INSTALLED_SYSTEMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004471$(eval $(call check-and-set-avb-args,system))
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004472endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004473
4474ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004475$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004476endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004477
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004478ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004479$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004480endif
4481
Justin Yun6151e3f2019-06-25 15:58:13 +09004482ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4483$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07004484endif
4485
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004486ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004487$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004488endif
4489
Yifan Hongcfb917a2020-05-07 14:58:20 -07004490ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
4491$(eval $(call check-and-set-avb-args,vendor_dlkm))
4492endif
4493
Yifan Hongf496f1b2020-07-15 16:52:59 -07004494ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
4495$(eval $(call check-and-set-avb-args,odm_dlkm))
4496endif
4497
Ramji Jiyani13a41372022-01-27 07:05:08 +00004498ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
4499$(eval $(call check-and-set-avb-args,system_dlkm))
4500endif
4501
Yueyao Zhu211c9012017-04-27 00:34:50 -07004502ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004503$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004504endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07004505
Andrew Scull9b103e42020-11-29 14:04:28 +00004506ifdef INSTALLED_PVMFWIMAGE_TARGET
4507$(eval $(call check-and-set-avb-args,pvmfw))
4508endif
4509
David Zeuthen8fecb282017-12-01 16:24:01 -05004510ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004511$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05004512endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08004513
David Anderson7709ab22018-10-15 14:41:34 -07004514# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
4515ifdef BOARD_AVB_VBMETA_SYSTEM
4516$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07004517endif
4518
4519ifdef BOARD_AVB_VBMETA_VENDOR
4520$(eval $(call check-and-set-avb-args,vbmeta_vendor))
4521endif
4522
Kelvin Zhangb81b4e32023-01-10 10:37:56 -08004523ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
4524$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(eval $(call check-and-set-avb-args,vbmeta_$(partition))))
4525$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(eval BOARD_AVB_MAKE_VBMETA_$(call to-upper,$(partition))_IMAGE_ARGS += --padding_size 4096))
4526endif
4527
Hongguang Chenf23364d2020-04-27 18:36:36 -07004528ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4529$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4530 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
4531endif
4532
Tao Bao0da43472018-08-22 22:53:41 -07004533BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07004534BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07004535BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
4536
4537ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07004538# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07004539BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07004540endif
Tao Bao0da43472018-08-22 22:53:41 -07004541
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004542ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004543BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004544endif
4545
David Anderson7709ab22018-10-15 14:41:34 -07004546ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
4547BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
4548 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07004549endif
4550
4551ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
4552BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
4553 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07004554endif
4555
Kelvin Zhangb81b4e32023-01-10 10:37:56 -08004556ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
4557 $(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)), \
4558 $(if $(BOARD_AVB_VBMETA_$(partition)_ROLLBACK_INDEX),$(eval \
4559 BOARD_AVB_MAKE_VBMETA_$(partition)_IMAGE_ARGS += \
4560 --rollback_index $(BOARD_AVB_VBMETA_$(partition)_ROLLBACK_INDEX))))
4561endif
4562
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004563# $(1): the directory to extract public keys to
4564define extract-avb-chain-public-keys
4565 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
4566 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
4567 --output $(1)/boot.avbpubkey)
Devin Moore380d9e42021-11-04 19:01:19 +00004568 $(if $(BOARD_AVB_INIT_BOOT_KEY_PATH),\
4569 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_INIT_BOOT_KEY_PATH) \
4570 --output $(1)/init_boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07004571 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
4572 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
4573 --output $(1)/vendor_boot.avbpubkey)
Lucas Weif57333f2022-02-24 10:30:15 +08004574 $(if $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH),\
4575 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH) \
4576 --output $(1)/vendor_kernel_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004577 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
4578 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
4579 --output $(1)/system.avbpubkey)
4580 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
4581 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
4582 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004583 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
4584 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
4585 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09004586 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
4587 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
4588 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004589 $(if $(BOARD_AVB_ODM_KEY_PATH),\
4590 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
4591 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004592 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
4593 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
4594 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004595 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
4596 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
4597 --output $(1)/odm_dlkm.avbpubkey)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004598 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
4599 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH) \
4600 --output $(1)/system_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004601 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
4602 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
4603 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00004604 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
4605 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
4606 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05004607 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
4608 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
4609 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07004610 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
4611 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4612 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07004613 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
4614 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4615 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07004616 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
4617 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4618 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
Kelvin Zhangb81b4e32023-01-10 10:37:56 -08004619 --output $(1)/$(partition).avbpubkey;)) \
4620 $(if $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),\
4621 $(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS), \
4622 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_KEY_PATH) \
4623 --output $(1)/vbmeta_$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004624endef
4625
Tao Bao744c4c72018-08-20 21:09:07 -07004626# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
4627# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07004628# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09004629# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
4630# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07004631# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004632# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07004633# $(2): Output filename.
4634define build-chained-vbmeta-image
Kelvin Zhangb81b4e32023-01-10 10:37:56 -08004635 $(call pretty,"Target chained vbmeta image: $@")
4636 $(hide) $(AVBTOOL) make_vbmeta_image \
4637 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
4638 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
4639 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
4640 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
4641 --output $@
Tao Bao744c4c72018-08-20 21:09:07 -07004642endef
4643
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004644ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07004645ifdef BOARD_AVB_VBMETA_SYSTEM
4646INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
4647$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004648 $(AVBTOOL) \
4649 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
4650 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07004651 $(call build-chained-vbmeta-image,vbmeta_system)
Bob Badourebdefc02022-02-12 15:39:22 -08004652
4653$(call declare-1p-container,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET),)
4654
4655SYSTEM_NOTICE_DEPS += $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004656endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004657endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07004658
4659ifdef BOARD_AVB_VBMETA_VENDOR
4660INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
4661$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004662 $(AVBTOOL) \
4663 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
4664 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07004665 $(call build-chained-vbmeta-image,vbmeta_vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08004666
4667$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
4668
Kelvin Zhangb81b4e32023-01-10 10:37:56 -08004669UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
4670endif
4671
4672ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
4673define declare-custom-vbmeta-target
4674INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_$(call to-lower,$(1)).img
4675$$(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET): \
4676 $(AVBTOOL) \
4677 $(call images-for-partitions,$(BOARD_AVB_VBMETA_$(call to-upper,$(1)))) \
4678 $(BOARD_AVB_VBMETA_$(call to-upper,$(1))_KEY_PATH)
4679 $$(call build-chained-vbmeta-image,vbmeta_$(call to-lower,$(1)))
4680
4681$(call declare-1p-container,$(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET),)
4682
4683UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET)
4684endef
4685
4686$(foreach partition,\
4687 $(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),\
4688 $(eval $(call declare-custom-vbmeta-target,$(partition))))
Tao Bao744c4c72018-08-20 21:09:07 -07004689endif
4690
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004691define build-vbmetaimage-target
4692 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004693 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
4694 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004695 $(hide) $(AVBTOOL) make_vbmeta_image \
4696 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07004697 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004698 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
4699 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004700 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004701endef
4702
Paul Trautrim4e143232019-08-13 16:30:57 +09004703ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004704INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07004705$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4706 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
4707
Kelvin Zhang0841b902023-01-23 11:12:26 -08004708
David Zeuthen8fecb282017-12-01 16:24:01 -05004709$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004710 $(AVBTOOL) \
4711 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00004712 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004713 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Lucas Weif57333f2022-02-24 10:30:15 +08004714 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004715 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4716 $(INSTALLED_VENDORIMAGE_TARGET) \
4717 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004718 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004719 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004720 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004721 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004722 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004723 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004724 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004725 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004726 $(INSTALLED_RECOVERYIMAGE_TARGET) \
4727 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
4728 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
Kelvin Zhang0841b902023-01-23 11:12:26 -08004729 $(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),$(INSTALLED_VBMETA_$(partition)IMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00004730 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4731 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
Kelvin Zhang0841b902023-01-23 11:12:26 -08004732 $(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),$(BOARD_AVB_VBMETA_$(partition)_KEY_PATH)) \
Anton Hansson6d814982018-11-26 18:12:05 +00004733 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004734 $(build-vbmetaimage-target)
4735
Bob Badourebdefc02022-02-12 15:39:22 -08004736$(call declare-1p-container,$(INSTALLED_VBMETAIMAGE_TARGET),)
4737
4738UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETAIMAGE_TARGET)
4739
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004740.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08004741vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4742 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004743vbmetaimage-nodeps:
4744 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09004745endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004746
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004747endif # BOARD_AVB_ENABLE
4748
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004749# List of files from all images
4750INTERNAL_ALLIMAGES_FILES := \
4751 $(FULL_SYSTEMIMAGE_DEPS) \
4752 $(INTERNAL_RAMDISK_FILES) \
4753 $(INTERNAL_USERDATAIMAGE_FILES) \
4754 $(INTERNAL_VENDORIMAGE_FILES) \
4755 $(INTERNAL_PRODUCTIMAGE_FILES) \
4756 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4757 $(INTERNAL_ODMIMAGE_FILES) \
4758 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4759 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004760 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
Jiyong Parke219f002022-12-16 14:30:03 +09004761 $(INTERNAL_PVMFWIMAGE_FILES) \
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004762
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004763# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004764# Check VINTF of build
4765
Ramji Jiyani13a41372022-01-27 07:05:08 +00004766# Note: vendor_dlkm, odm_dlkm, and system_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004767ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07004768
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004769intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
4770check_vintf_all_deps :=
4771
Rob Seymour3f1c9572022-07-28 21:56:28 +00004772APEX_OUT := $(PRODUCT_OUT)/apex
4773# -----------------------------------------------------------------
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004774# Create apex-info-file.xml
Rob Seymour3f1c9572022-07-28 21:56:28 +00004775
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004776apex_dirs := \
Rob Seymour3f1c9572022-07-28 21:56:28 +00004777 $(TARGET_OUT)/apex/% \
4778 $(TARGET_OUT_SYSTEM_EXT)/apex/% \
4779 $(TARGET_OUT_VENDOR)/apex/% \
4780 $(TARGET_OUT_ODM)/apex/% \
4781 $(TARGET_OUT_PRODUCT)/apex/% \
4782
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004783apex_files := $(sort $(filter $(apex_dirs), $(INTERNAL_ALLIMAGES_FILES)))
4784APEX_INFO_FILE := $(APEX_OUT)/apex-info-list.xml
Rob Seymour3f1c9572022-07-28 21:56:28 +00004785
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004786# dump_apex_info scans $(PRODUCT_OUT)/apex and writes apex-info-list.xml there.
4787# This relies on the fact that rules for .apex files install the contents in $(PRODUCT_OUT)/apex.
4788$(APEX_INFO_FILE): $(HOST_OUT_EXECUTABLES)/dump_apex_info $(apex_files)
Rob Seymour3f1c9572022-07-28 21:56:28 +00004789 @echo "Creating apex-info-file in $(PRODUCT_OUT) "
Jooyung Han8af44a92022-11-24 18:36:47 +09004790 $< --root_dir $(PRODUCT_OUT)
Rob Seymour3f1c9572022-07-28 21:56:28 +00004791
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004792apex_files :=
4793apex_dirs :=
Rob Seymour3f1c9572022-07-28 21:56:28 +00004794
Yifan Hongaf9b0702020-01-21 12:46:57 -08004795# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
4796# because they are only used for prebuilt images.
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004797# APEX files in /vendor/apex can have VINTF fragments as well.
Yifan Hongaf9b0702020-01-21 12:46:57 -08004798check_vintf_common_srcs_patterns := \
4799 $(TARGET_OUT)/etc/vintf/% \
4800 $(TARGET_OUT_VENDOR)/etc/vintf/% \
4801 $(TARGET_OUT_ODM)/etc/vintf/% \
4802 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
4803 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004804 $(TARGET_OUT_VENDOR)/apex/% \
Yifan Hongaf9b0702020-01-21 12:46:57 -08004805
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004806check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08004807check_vintf_common_srcs_patterns :=
4808
4809check_vintf_has_system :=
4810check_vintf_has_vendor :=
4811
Yifan Hong28ffd732020-03-13 13:11:10 -07004812ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
4813$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
4814endif
4815ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
4816$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
4817endif
4818
Yifan Hong605ea042020-01-14 21:36:00 +00004819# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08004820check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
4821ifneq ($(check_vintf_system_deps),)
4822check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00004823
Yifan Hongfd150d32021-03-09 12:19:11 -08004824check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00004825check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004826$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00004827 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
Bob Badourdf0f55e2023-03-01 10:34:34 -08004828$(call declare-1p-target,$(check_vintf_system_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004829check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00004830
Devin Moore62d0a732022-10-13 16:50:50 +00004831# -- Check framework manifest against frozen manifests for GSI targets. They need to be compatible.
4832ifneq (true, $(BUILDING_VENDOR_IMAGE))
4833 vintffm_log := $(intermediates)/vintffm.log
4834endif
Yifan Hong7a157b02020-10-20 17:08:11 +00004835check_vintf_all_deps += $(vintffm_log)
4836$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
4837 @( $< --check --dirmap /system:$(TARGET_OUT) \
4838 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
4839
Bob Badourdf0f55e2023-03-01 10:34:34 -08004840$(call declare-1p-target,$(vintffm_log))
Bob Badour5acd4362022-04-12 18:31:35 -07004841
Yifan Hongaf9b0702020-01-21 12:46:57 -08004842endif # check_vintf_system_deps
4843check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004844
4845# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004846check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004847check_vintf_vendor_deps += $(filter $(TARGET_OUT_VENDOR)/apex/%, $(check_vintf_common_srcs))
4848ifneq ($(strip $(check_vintf_vendor_deps)),)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004849check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08004850check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00004851check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07004852# Check vendor SKU=(empty) case when:
4853# - DEVICE_MANIFEST_FILE is not empty; OR
4854# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004855$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004856 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4857 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004858 $(DEVICE_MANIFEST_SKUS)
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004859$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps) $(APEX_INFO_FILE)
Yifan Hong28ffd732020-03-13 13:11:10 -07004860 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004861 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) --dirmap /apex:$(APEX_OUT) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004862 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4863 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Bob Badourdf0f55e2023-03-01 10:34:34 -08004864$(call declare-1p-target,$(check_vintf_vendor_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004865check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08004866endif # check_vintf_vendor_deps
4867check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004868
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004869# -- Kernel version and configurations.
4870ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
4871
Yifan Hong605ea042020-01-14 21:36:00 +00004872BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
4873BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
4874
4875my_board_extracted_kernel :=
4876
4877# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
4878# from INSTALLED_KERNEL_TARGET.
4879ifdef BOARD_KERNEL_CONFIG_FILE
4880ifdef BOARD_KERNEL_VERSION
4881$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
4882 cp $< $@
4883$(BUILT_KERNEL_VERSION_FILE):
4884 echo $(BOARD_KERNEL_VERSION) > $@
4885
Bob Badour7cc4e332023-03-01 10:16:04 -08004886$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
4887$(call declare-license-metadata,$(BUILT_KERNEL_VERSION_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
Bob Badour5acd4362022-04-12 18:31:35 -07004888
Yifan Hong605ea042020-01-14 21:36:00 +00004889my_board_extracted_kernel := true
4890endif # BOARD_KERNEL_VERSION
4891endif # BOARD_KERNEL_CONFIG_FILE
4892
4893ifneq ($(my_board_extracted_kernel),true)
Yifan Hong605ea042020-01-14 21:36:00 +00004894# Tools for decompression that is not in PATH.
4895# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
4896# Algorithms that are in the script but not in this list will be found in PATH.
4897my_decompress_tools := \
4898 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
4899
Yifan Hongb1627772021-07-14 15:01:50 -07004900endif # my_board_extracted_kernel
4901
4902ifneq ($(my_board_extracted_kernel),true)
4903ifdef INSTALLED_KERNEL_TARGET
Yifan Hong605ea042020-01-14 21:36:00 +00004904$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4905$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4906$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07004907$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
4908 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00004909 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08004910 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00004911
Bob Badour7cc4e332023-03-01 10:16:04 -08004912$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
Bob Badour5acd4362022-04-12 18:31:35 -07004913
Yifan Hongb1627772021-07-14 15:01:50 -07004914my_board_extracted_kernel := true
Yifan Hong605ea042020-01-14 21:36:00 +00004915endif # INSTALLED_KERNEL_TARGET
Yifan Hongb1627772021-07-14 15:01:50 -07004916endif # my_board_extracted_kernel
4917
4918ifneq ($(my_board_extracted_kernel),true)
4919ifdef INSTALLED_BOOTIMAGE_TARGET
4920$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4921$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4922$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
4923$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
4924$(BUILT_KERNEL_CONFIGS_FILE): \
4925 $(HOST_OUT_EXECUTABLES)/unpack_bootimg \
4926 $(EXTRACT_KERNEL) \
4927 $(INSTALLED_BOOTIMAGE_TARGET)
4928 $(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
4929 $(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
4930 --output-configs $@ \
4931 --output-release $(BUILT_KERNEL_VERSION_FILE)
4932
Bob Badour7cc4e332023-03-01 10:16:04 -08004933$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
Bob Badour5acd4362022-04-12 18:31:35 -07004934
Yifan Hongb1627772021-07-14 15:01:50 -07004935my_board_extracted_kernel := true
4936endif # INSTALLED_BOOTIMAGE_TARGET
4937endif # my_board_extracted_kernel
4938
4939ifneq ($(my_board_extracted_kernel),true)
4940$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
4941 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
4942 cannot be built into OTA update package. You can fix this by: \
4943 (1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
4944 so that kernel information will be extracted from the built kernel; or \
4945 (2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
4946 (3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
4947 BOARD_KERNEL_VERSION manually; or \
4948 (4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
4949# Clear their values to indicate that these two files does not exist.
4950BUILT_KERNEL_CONFIGS_FILE :=
4951BUILT_KERNEL_VERSION_FILE :=
4952endif
4953
4954my_decompress_tools :=
4955my_board_extracted_kernel :=
Yifan Hong605ea042020-01-14 21:36:00 +00004956
Yifan Hongc0f904e2021-03-17 11:25:31 -07004957endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4958
4959# -- Check VINTF compatibility of build.
4960# Skip partial builds; only check full builds. Only check if:
4961# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
4962# - system / vendor VINTF metadata exists
4963# - Building product / system_ext / odm images if board has product / system_ext / odm images
4964ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4965ifeq ($(check_vintf_has_system),true)
4966ifeq ($(check_vintf_has_vendor),true)
4967ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
4968ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
4969ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
4970
4971check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
4972check_vintf_all_deps += $(check_vintf_compatible_log)
4973
4974check_vintf_compatible_args :=
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004975check_vintf_compatible_deps := $(check_vintf_common_srcs) $(APEX_INFO_FILE)
Yifan Hongc0f904e2021-03-17 11:25:31 -07004976
4977ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004978ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004979check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004980check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004981endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004982endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4983
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004984check_vintf_compatible_args += \
4985 --dirmap /system:$(TARGET_OUT) \
4986 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4987 --dirmap /odm:$(TARGET_OUT_ODM) \
4988 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4989 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
Rob Seymour3f1c9572022-07-28 21:56:28 +00004990 --dirmap /apex:$(APEX_OUT) \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004991
4992ifdef PRODUCT_SHIPPING_API_LEVEL
4993check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4994endif # PRODUCT_SHIPPING_API_LEVEL
4995
4996$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4997$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004998# Check ODM SKU=(empty) case when:
4999# - ODM_MANIFEST_FILES is not empty; OR
5000# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07005001$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07005002 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
5003 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07005004 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07005005# Check vendor SKU=(empty) case when:
5006# - DEVICE_MANIFEST_FILE is not empty; OR
5007# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07005008$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07005009 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
5010 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07005011 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005012$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08005013 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
5014 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005015 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
5016 @echo -n -e 'Args: \n ' >> $@
5017 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07005018 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
5019 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005020 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07005021 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
5022 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
5023 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005024
Bob Badourdf0f55e2023-03-01 10:34:34 -08005025$(call declare-1p-target,$(check_vintf_compatible_log))
Bob Badour5acd4362022-04-12 18:31:35 -07005026
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005027check_vintf_compatible_log :=
5028check_vintf_compatible_args :=
5029check_vintf_compatible_deps :=
5030
5031endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
5032endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
5033endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08005034endif # check_vintf_has_vendor
5035endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005036endif # PRODUCT_ENFORCE_VINTF_MANIFEST
5037
5038# Add all logs of VINTF checks to dist builds
5039droid_targets: $(check_vintf_all_deps)
5040$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
5041
5042# Helper alias to check all VINTF of current build.
5043.PHONY: check-vintf-all
5044check-vintf-all: $(check_vintf_all_deps)
5045 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
5046
Yifan Hongaf9b0702020-01-21 12:46:57 -08005047check_vintf_has_vendor :=
5048check_vintf_has_system :=
5049check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005050check_vintf_all_deps :=
5051intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005052endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00005053
5054# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08005055# Check image sizes <= size of super partition
5056
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005057ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08005058
5059ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07005060
Tianjie16bcac12021-05-13 15:44:43 -07005061PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
5062
5063# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
5064ifdef BUILDING_SYSTEM_OTHER_IMAGE
5065PARTITIONS_AND_OTHER_IN_SUPER += system_other
5066endif # BUILDING_SYSTEM_OTHER_IMAGE
5067
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005068# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07005069# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07005070define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005071 mkdir -p $(dir $(1))
5072 rm -f $(1)
5073 $(call dump-super-image-info, $(1))
Tianjie16bcac12021-05-13 15:44:43 -07005074 $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005075 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07005076 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07005077endef
5078
Yifan Hongd11953c2021-03-11 14:47:48 -08005079check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes.log
Yifan Hong30910932019-10-25 20:36:55 -07005080droid_targets: $(check_all_partition_sizes_log)
5081$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07005082
Yifan Hong30910932019-10-25 20:36:55 -07005083$(check_all_partition_sizes_log): \
5084 $(CHECK_PARTITION_SIZES) \
Tianjie16bcac12021-05-13 15:44:43 -07005085 $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
Yifan Hong30910932019-10-25 20:36:55 -07005086 $(call check-all-partition-sizes-target, \
5087 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
5088 $@)
5089
Bob Badourdf0f55e2023-03-01 10:34:34 -08005090$(call declare-1p-target,$(check_all_partition_sizes_log))
Bob Badour5acd4362022-04-12 18:31:35 -07005091
Yifan Hong30910932019-10-25 20:36:55 -07005092.PHONY: check-all-partition-sizes
5093check-all-partition-sizes: $(check_all_partition_sizes_log)
5094
5095.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07005096check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005097 $(call check-all-partition-sizes-target, \
5098 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07005099
Yifan Hong2dae5722018-07-31 12:47:27 -07005100endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07005101
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005102endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07005103
5104# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08005105# bring in the installer image generation defines if necessary
5106ifeq ($(TARGET_USE_DISKINSTALLER),true)
5107include bootable/diskinstaller/config.mk
5108endif
5109
5110# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07005111# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08005112
Ying Wangbd2d0242015-09-22 11:17:52 -07005113ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005114 build_ota_package := false
5115 build_otatools_package := false
5116else
Tao Bao9be20c72019-04-08 21:11:59 -07005117 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005118 build_ota_package := true
5119 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
5120 build_ota_package := false
5121 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08005122 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005123 build_ota_package := false
5124 endif
5125 ifeq ($(TARGET_PRODUCT),sdk)
5126 build_ota_package := false
5127 endif
Yifan Hongf32f65c2021-07-14 14:19:12 -07005128 # A target without a kernel may be one of the following:
Yifan Hong8c1e5262021-07-19 16:35:05 +00005129 # - A generic target. In this case, the OTA package usually isn't built.
5130 # PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
5131 # generation.
5132 # - A real device target, with TARGET_NO_KERNEL set to true and
5133 # BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
5134 # an OTA package.
Tao Bao9be20c72019-04-08 21:11:59 -07005135 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
5136 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
5137 build_ota_package := false
5138 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00005139 ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
5140 ifeq ($(TARGET_NO_KERNEL),true)
5141 build_ota_package := false
5142 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00005143 endif # INSTALLED_BOOTIMAGE_TARGET == ""
Yifan Hongbf777872021-07-19 16:28:49 +00005144 ifeq ($(recovery_fstab),)
5145 build_ota_package := false
5146 endif
Tao Bao9be20c72019-04-08 21:11:59 -07005147 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005148
Tao Bao9be20c72019-04-08 21:11:59 -07005149 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005150 build_otatools_package := true
5151 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
5152 build_otatools_package := false
5153 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08005154endif
Ying Wangbd2d0242015-09-22 11:17:52 -07005155
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005156ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07005157
5158INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09005159 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07005160 add_img_to_target_files \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00005161 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07005162 append2simg \
5163 avbtool \
5164 blk_alloc_to_base_fs \
5165 boot_signer \
5166 brillo_update_payload \
5167 brotli \
5168 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07005169 build_image \
5170 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07005171 build_verity_metadata \
5172 build_verity_tree \
5173 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07005174 check_ota_package_signature \
5175 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005176 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07005177 checkvintf \
Kelvin Zhangca812332023-04-19 16:15:29 -07005178 create_brick_ota \
Tao Bao96daeeb2019-05-01 21:17:13 -07005179 delta_generator \
5180 e2fsck \
5181 e2fsdroid \
5182 fc_sort \
5183 fec \
Woody Line4164192022-03-21 18:29:41 +08005184 fsck.erofs \
Jaegeuk Kim01da65f2021-06-08 18:24:46 -07005185 fsck.f2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07005186 fs_config \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08005187 generate_gki_certificate \
Tao Bao96daeeb2019-05-01 21:17:13 -07005188 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08005189 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07005190 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07005191 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005192 imgdiff \
Shikha Panward3bef472023-01-13 08:09:29 +00005193 initrd_bootconfig \
Tao Bao96daeeb2019-05-01 21:17:13 -07005194 libconscrypt_openjdk_jni \
5195 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08005196 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07005197 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07005198 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07005199 make_f2fs_casefold \
Satoshi Futenma6d56d452023-04-18 19:15:26 +09005200 merge_ota \
Tao Baoc1966a82019-06-25 11:42:12 -07005201 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005202 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08005203 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07005204 mkbootfs \
5205 mkbootimg \
5206 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08005207 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08005208 mkfs.erofs \
Cole Faustb0002082022-09-05 18:34:56 -07005209 mkf2fsuserimg \
Tao Bao96daeeb2019-05-01 21:17:13 -07005210 mksquashfs \
Cole Faustb0002082022-09-05 18:34:56 -07005211 mksquashfsimage \
Tao Bao96daeeb2019-05-01 21:17:13 -07005212 mkuserimg_mke2fs \
Kelvin Zhang83eb9f72022-03-15 11:12:50 -07005213 ota_extractor \
Tao Bao8821d642019-08-05 12:05:45 -07005214 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08005215 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08005216 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07005217 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08005218 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07005219 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07005220 sign_apex \
5221 sign_target_files_apks \
Jooyung Han8caba5e2021-10-27 03:58:09 +09005222 sign_virt_apex \
Tao Bao96daeeb2019-05-01 21:17:13 -07005223 signapk \
5224 simg2img \
5225 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07005226 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07005227 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08005228 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07005229 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07005230 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005231 verity_signer \
5232 verity_verifier \
5233 zipalign \
Kelvin Zhangb673bbf2021-08-20 10:09:20 -07005234 zucchini \
Kelvin Zhang6d366d32023-02-21 12:42:23 -08005235 zip2zip \
5236
Tao Bao5e04c382017-02-22 16:38:19 -08005237
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005238# Additional tools to unpack and repack the apex file.
5239INTERNAL_OTATOOLS_MODULES += \
5240 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00005241 apex_compression_tool \
Baligh Uddin9170e892023-01-19 18:20:55 +00005242 blkid_static \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005243 deapexer \
5244 debugfs_static \
Baligh Uddin67ab6892022-10-17 17:17:42 +00005245 dump_apex_info \
Dennis Shen888539c2022-11-07 18:53:10 +00005246 fsck.erofs \
Dennis Shen03ef64b2023-03-08 15:39:28 +00005247 make_erofs \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005248 merge_zips \
5249 resize2fs \
5250 soong_zip \
5251
Anton Hansson8dab0a62019-03-28 15:45:40 +00005252ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005253INTERNAL_OTATOOLS_MODULES += \
Aaron Klinge3803212022-10-20 21:24:23 -05005254 futility-host \
Tao Bao96daeeb2019-05-01 21:17:13 -07005255 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08005256endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08005257
Tao Bao96daeeb2019-05-01 21:17:13 -07005258INTERNAL_OTATOOLS_FILES := \
5259 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005260
Ying Wang06898662010-06-17 17:52:18 -07005261.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07005262otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07005263
Tao Bao96daeeb2019-05-01 21:17:13 -07005264# For each module, recursively resolve its host shared library dependencies. Then we have a full
5265# list of modules whose installed files need to be packed.
5266INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
5267 $(sort $(INTERNAL_OTATOOLS_MODULES) \
5268 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005269
Tao Bao96daeeb2019-05-01 21:17:13 -07005270INTERNAL_OTATOOLS_PACKAGE_FILES := \
5271 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
5272
5273INTERNAL_OTATOOLS_PACKAGE_FILES += \
5274 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
hungweichenf1f5dd32022-08-17 08:01:50 +00005275 -name "*.pk8"))
Tao Bao93ab8442018-10-12 11:03:04 -07005276
Hongguang07babe02022-10-31 17:21:22 -07005277ifneq (,$(wildcard packages/modules))
Hongguang547812d2022-10-31 10:20:14 -07005278INTERNAL_OTATOOLS_PACKAGE_FILES += \
5279 $(sort $(shell find packages/modules -type f -name "*.x509.pem" -o -name "*.pk8" -o -name \
5280 "key.pem"))
Hongguang07babe02022-10-31 17:21:22 -07005281endif
Hongguang547812d2022-10-31 10:20:14 -07005282
Tao Bao93ab8442018-10-12 11:03:04 -07005283ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07005284INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07005285 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07005286 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07005287endif
5288ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07005289INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07005290 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
5291 -name "atx_metadata.bin"))
5292endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005293ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005294INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00005295 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07005296endif
5297
Tao Bao96daeeb2019-05-01 21:17:13 -07005298INTERNAL_OTATOOLS_RELEASETOOLS := \
Kelvin Zhanged714e02022-09-22 12:42:24 -07005299 $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
5300 \( -type f -o -type l \) -print | sort)
Tao Bao96daeeb2019-05-01 21:17:13 -07005301
5302BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
5303$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
5304$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
5305$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
5306$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07005307$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005308 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07005309 rm -rf $@ $(PRIVATE_ZIP_ROOT)
5310 mkdir -p $(dir $@)
5311 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
5312 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08005313 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07005314 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005315
Bob Badour5acd4362022-04-12 18:31:35 -07005316$(call declare-1p-container,$(BUILT_OTATOOLS_PACKAGE),build)
5317$(call declare-container-license-deps,$(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS),$(BUILT_OTATOOLS_PACKAGE):)
5318
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005319.PHONY: otatools-package
5320otatools-package: $(BUILT_OTATOOLS_PACKAGE)
5321
Dennis Shen5acfb9c2023-03-30 12:27:31 +00005322$(call dist-for-goals, otatools-package, \
5323 $(BUILT_OTATOOLS_PACKAGE) \
5324)
5325
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005326endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005327
The Android Open Source Project88b60792009-03-03 19:28:42 -08005328# -----------------------------------------------------------------
David Anderson816da932023-03-09 21:09:07 -08005329# fastboot-info.txt
Daniel Zhenge05a15b2023-05-01 11:07:33 -07005330FASTBOOT_INFO_VERSION = 1
David Anderson816da932023-03-09 21:09:07 -08005331
5332INSTALLED_FASTBOOT_INFO_TARGET := $(PRODUCT_OUT)/fastboot-info.txt
5333
5334$(INSTALLED_FASTBOOT_INFO_TARGET):
5335 rm -f $@
5336 $(call pretty,"Target fastboot-info.txt: $@")
5337 $(hide) echo "# fastboot-info for $(TARGET_PRODUCT)" >> $@
5338 $(hide) echo "version $(FASTBOOT_INFO_VERSION)" >> $@
5339ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
5340 $(hide) echo "flash boot" >> $@
5341endif
5342ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
5343 $(hide) echo "flash init_boot" >> $@
5344endif
5345ifdef BOARD_PREBUILT_DTBOIMAGE
5346 $(hide) echo "flash dtbo" >> $@
5347endif
5348ifeq ($(BOARD_USES_PVMFWIMAGE),true)
5349 $(hide) echo "flash pvmfw" >> $@
5350endif
5351ifeq ($(BOARD_AVB_ENABLE),true)
5352ifeq ($(BUILDING_VBMETA_IMAGE),true)
5353 $(hide) echo "flash --apply-vbmeta vbmeta" >> $@
5354endif
5355ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
5356 $(hide) echo "flash --apply-vbmeta vbmeta_system" >> $@
5357endif
5358ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
5359 $(hide) echo "flash --apply-vbmeta vbmeta_vendor" >> $@
5360endif
5361ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5362 $(hide) echo "flash vendor_boot" >> $@
5363endif
5364ifneq (,$(strip $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)))
Daniel Zheng2b7ddbd2023-05-05 13:57:49 -07005365 $(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS), \
5366 echo "flash --apply-vbmeta vbmeta_$(partition)" >> $@;)
David Anderson816da932023-03-09 21:09:07 -08005367endif
5368endif # BOARD_AVB_ENABLE
5369 $(hide) echo "reboot fastboot" >> $@
5370 $(hide) echo "update-super" >> $@
Daniel Zheng2b7ddbd2023-05-05 13:57:49 -07005371 $(hide) $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
David Anderson816da932023-03-09 21:09:07 -08005372 echo "flash $(partition)" >> $@;)
5373ifdef BUILDING_SYSTEM_OTHER_IMAGE
5374 $(hide) echo "flash --slot-other system system_other.img" >> $@
5375endif
5376ifdef BUILDING_CACHE_IMAGE
5377 $(hide) echo "if-wipe erase cache" >> $@
5378endif
5379 $(hide) echo "if-wipe erase userdata" >> $@
5380ifeq ($(BOARD_USES_METADATA_PARTITION),true)
5381 $(hide) echo "if-wipe erase metadata" >> $@
5382endif
5383
5384# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07005385# misc_info.txt
5386
5387INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
5388
5389ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
5390# default to common dir for device vendor
5391tool_extensions := $(TARGET_DEVICE_DIR)/../common
5392else
5393tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
5394endif
5395.KATI_READONLY := tool_extensions
5396
Steve Muckle903a1ca2020-05-07 17:32:10 -07005397# $1: boot image file name
5398define misc_boot_size
5399$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
5400endef
5401
Daniel Normane1e48082019-06-27 13:55:23 -07005402$(INSTALLED_MISC_INFO_TARGET):
5403 rm -f $@
5404 $(call pretty,"Target misc_info.txt: $@")
5405 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
5406 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
5407ifdef BOARD_FLASH_BLOCK_SIZE
5408 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
5409endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07005410ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
5411 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
5412 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07005413endif
5414ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
5415 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07005416else
5417 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005418endif
Devin Moore380d9e42021-11-04 19:01:19 +00005419ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
5420 $(hide) echo "init_boot=true" >> $@
5421 $(hide) echo "init_boot_size=$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)" >> $@
5422endif
J. Avila98cd4cc2020-06-10 20:09:10 +00005423ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
5424 echo "lz4_ramdisks=true" >> $@
5425endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005426ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5427 echo "vendor_boot=true" >> $@
5428 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
5429endif
Lucas Weif57333f2022-02-24 10:30:15 +08005430ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
5431 echo "vendor_kernel_boot=true" >> $@
5432 echo "vendor_kernel_boot_size=$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)" >> $@
5433endif
Daniel Normane1e48082019-06-27 13:55:23 -07005434ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5435 $(hide) echo "no_recovery=true" >> $@
5436endif
5437ifdef BOARD_INCLUDE_RECOVERY_DTBO
5438 $(hide) echo "include_recovery_dtbo=true" >> $@
5439endif
5440ifdef BOARD_INCLUDE_RECOVERY_ACPIO
5441 $(hide) echo "include_recovery_acpio=true" >> $@
5442endif
5443ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
5444 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
5445endif
5446ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
5447 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
5448 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5449else
5450 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5451endif
5452 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
5453 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
Jacky Liubeb0b692021-12-29 16:29:05 +08005454ifdef PRODUCT_EXTRA_OTA_KEYS
5455 $(hide) echo "extra_ota_keys=$(PRODUCT_EXTRA_OTA_KEYS)" >> $@
5456endif
Daniel Normane1e48082019-06-27 13:55:23 -07005457ifdef PRODUCT_EXTRA_RECOVERY_KEYS
5458 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
5459endif
5460 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07005461 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005462 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Devin Moore380d9e42021-11-04 19:01:19 +00005463 $(hide) echo 'mkbootimg_init_args=$(BOARD_MKBOOTIMG_INIT_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005464ifdef BOARD_GKI_SIGNING_KEY_PATH
5465 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
5466 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005467 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
5468endif
Daniel Normane1e48082019-06-27 13:55:23 -07005469 $(hide) echo "multistage_support=1" >> $@
5470 $(hide) echo "blockimgdiff_versions=3,4" >> $@
5471ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
5472 $(hide) echo "build_generic_ota_package=true" >> $@
5473endif
5474ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
5475 # OTA scripts are only interested in fingerprint related properties
5476 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
5477endif
5478ifneq (,$(filter address, $(SANITIZE_TARGET)))
5479 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
5480 $(hide) echo "userdata_img_with_data=true" >> $@
5481endif
5482ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
5483 $(hide) echo "full_recovery_image=true" >> $@
5484endif
Bill Peckhame868aec2019-09-17 17:06:47 -07005485ifdef BOARD_USES_VENDORIMAGE
5486 $(hide) echo "board_uses_vendorimage=true" >> $@
5487endif
Daniel Normane1e48082019-06-27 13:55:23 -07005488ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08005489ifeq ($(BUILDING_VBMETA_IMAGE),true)
5490 $(hide) echo "avb_building_vbmeta_image=true" >> $@
5491endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005492 $(hide) echo "avb_enable=true" >> $@
5493 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
5494 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
5495 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
5496 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5497ifdef BOARD_AVB_BOOT_KEY_PATH
5498 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
5499 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
5500 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5501endif # BOARD_AVB_BOOT_KEY_PATH
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08005502 $(hide) echo "avb_init_boot_add_hash_footer_args=$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5503ifdef BOARD_AVB_INIT_BOOT_KEY_PATH
5504 $(hide) echo "avb_init_boot_key_path=$(BOARD_AVB_INIT_BOOT_KEY_PATH)" >> $@
5505 $(hide) echo "avb_init_boot_algorithm=$(BOARD_AVB_INIT_BOOT_ALGORITHM)" >> $@
5506 $(hide) echo "avb_init_boot_rollback_index_location=$(BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5507endif # BOARD_AVB_INIT_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07005508 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5509ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
5510 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
5511 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
5512 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5513endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Lucas Weif57333f2022-02-24 10:30:15 +08005514 echo "avb_vendor_kernel_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5515ifdef BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
5516 echo "avb_vendor_kernel_boot_key_path=$(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH)" >> $@
5517 echo "avb_vendor_kernel_boot_algorithm=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ALGORITHM)" >> $@
5518 echo "avb_vendor_kernel_boot_rollback_index_location=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5519endif # BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07005520 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
5521ifdef BOARD_AVB_RECOVERY_KEY_PATH
5522 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
5523 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
5524 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
5525endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07005526ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
5527 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
5528 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5529 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
5530 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
5531 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
5532 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
5533 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
5534 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
5535endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07005536ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
5537 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
5538 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
5539 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
5540 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
5541 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
5542endif # BOARD_AVB_VBMETA_SYSTEM
5543ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
5544 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
Bowgo Tsaic85a2012022-06-07 11:36:35 +08005545 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS)" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005546 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
5547 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
5548 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
5549endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
Kelvin Zhangb81b4e32023-01-10 10:37:56 -08005550ifneq (,$(strip $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)))
5551 $(hide) echo "avb_custom_vbmeta_images_partition_list=$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)" >> $@
5552 $(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),\
5553 echo "avb_vbmeta_$(partition)=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition)))" >> $@ ;\
5554 echo "avb_vbmeta_$(partition)_args=$(BOARD_AVB_MAKE_VBMETA_$(call to-upper,$(partition))_IMAGE_ARGS)" >> $@ ;\
5555 echo "avb_vbmeta_$(partition)_key_path=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_KEY_PATH)" >> $@ ;\
5556 echo "avb_vbmeta_$(partition)_algorithm=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_ALGORITHM)" >> $@ ;\
5557 echo "avb_vbmeta_$(partition)_rollback_index_location=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@ ;)
5558endif # BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
Daniel Normane1e48082019-06-27 13:55:23 -07005559endif # BOARD_AVB_ENABLE
5560ifdef BOARD_BPT_INPUT_FILES
5561 $(hide) echo "board_bpt_enable=true" >> $@
5562 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
5563 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
5564endif
5565ifdef BOARD_BPT_DISK_SIZE
5566 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
5567endif
5568 $(call generate-userimage-prop-dictionary, $@)
5569ifeq ($(AB_OTA_UPDATER),true)
5570 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
5571 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
5572 $(hide) echo "ab_update=true" >> $@
5573endif
Yifan Hong65afc072020-04-17 10:08:10 -07005574ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
5575 $(hide) echo "allow_non_ab=true" >> $@
5576endif
Daniel Normane1e48082019-06-27 13:55:23 -07005577ifdef BOARD_PREBUILT_DTBOIMAGE
5578 $(hide) echo "has_dtbo=true" >> $@
5579ifeq ($(BOARD_AVB_ENABLE),true)
5580 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
5581 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
5582ifdef BOARD_AVB_DTBO_KEY_PATH
5583 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
5584 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
5585 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
5586endif # BOARD_AVB_DTBO_KEY_PATH
5587endif # BOARD_AVB_ENABLE
5588endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005589ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005590 $(hide) echo "has_pvmfw=true" >> $@
5591ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi592a3ca2021-10-04 11:34:11 +02005592 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@
Andrew Scull9b103e42020-11-29 14:04:28 +00005593 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
5594ifdef BOARD_AVB_PVMFW_KEY_PATH
5595 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
5596 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
5597 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
5598endif # BOARD_AVB_PVMFW_KEY_PATH
5599endif # BOARD_AVB_ENABLE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005600endif # BOARD_USES_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005601 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07005602 @# VINTF checks
5603ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
5604 $(hide) echo "vintf_enforce=true" >> $@
5605endif
5606ifdef ODM_MANIFEST_SKUS
5607 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
5608endif
Yifan Hong28ffd732020-03-13 13:11:10 -07005609ifdef ODM_MANIFEST_FILES
5610 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
5611endif
5612ifdef DEVICE_MANIFEST_SKUS
5613 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
5614endif
5615ifdef DEVICE_MANIFEST_FILE
5616 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
5617endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005618ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
5619 $(hide) echo "bootloader_in_update_package=true" >> $@
5620endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07005621ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
5622 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
5623endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05005624ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5625 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
5626endif
Jose Galmes9c8f6eb2021-07-21 09:34:08 -07005627ifeq ($(BUILDING_WITH_VSDK),true)
5628 $(hide) echo "building_with_vsdk=true" >> $@
5629endif
5630ifeq ($(TARGET_FLATTEN_APEX),false)
5631 $(hide) echo "target_flatten_apex=false" >> $@
5632endif
Daniel Normane1e48082019-06-27 13:55:23 -07005633
David Anderson816da932023-03-09 21:09:07 -08005634$(call declare-0p-target,$(INSTALLED_FASTBOOT_INFO_TARGET))
5635
5636.PHONY: fastboot_info
5637fastboot_info: $(INSTALLED_FASTBOOT_INFO_TARGET)
5638
Daniel Zhengeea63fa2023-05-08 12:11:56 -07005639droidcore-unbundled: $(INSTALLED_FASTBOOT_INFO_TARGET)
5640
Bob Badourebdefc02022-02-12 15:39:22 -08005641$(call declare-0p-target,$(INSTALLED_MISC_INFO_TARGET))
5642
Daniel Normane1e48082019-06-27 13:55:23 -07005643.PHONY: misc_info
5644misc_info: $(INSTALLED_MISC_INFO_TARGET)
5645
Bill Peckham315b98a2021-06-15 19:35:06 -07005646droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
Daniel Normane1e48082019-06-27 13:55:23 -07005647
5648# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005649# A zip of the directories that map to the target filesystem.
5650# This zip can be used to create an OTA package or filesystem image
5651# as a post-build step.
5652#
5653name := $(TARGET_PRODUCT)
5654ifeq ($(TARGET_BUILD_TYPE),debug)
5655 name := $(name)_debug
5656endif
5657name := $(name)-target_files-$(FILE_NAME_TAG)
5658
5659intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005660BUILT_TARGET_FILES_DIR := $(intermediates)/$(name).zip.list
The Android Open Source Project88b60792009-03-03 19:28:42 -08005661BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005662$(BUILT_TARGET_FILES_PACKAGE): zip_root := $(intermediates)/$(name)
5663$(BUILT_TARGET_FILES_DIR): zip_root := $(intermediates)/$(name)
5664$(BUILT_TARGET_FILES_DIR): intermediates := $(intermediates)
5665
The Android Open Source Project88b60792009-03-03 19:28:42 -08005666
5667# $(1): Directory to copy
5668# $(2): Location to copy it to
5669# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
5670define package_files-copy-root
5671 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
5672 mkdir -p $(2) && \
5673 $(ACP) -rd $(strip $(1))/* $(2); \
5674 fi
5675endef
5676
Tao Baoa04fca32015-11-30 12:22:24 -08005677built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07005678
5679# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08005680ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07005681built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07005682 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07005683endif
5684
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005685$(BUILT_TARGET_FILES_DIR): PRIVATE_OTA_TOOLS := $(built_ota_tools)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005686
Dan Willemsen653bea92017-03-21 15:47:37 -07005687tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005688$(BUILT_TARGET_FILES_DIR): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07005689
HÃ¥kan Kvist8cabc712022-05-02 07:43:34 +02005690updater_dep :=
Sen Jiang4438fd92016-03-07 16:51:01 -08005691ifeq ($(AB_OTA_UPDATER),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005692updater_dep += system/update_engine/update_engine.conf
Bob Badour5acd4362022-04-12 18:31:35 -07005693$(call declare-1p-target,system/update_engine/update_engine.conf,system/update_engine)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005694updater_dep += external/zucchini/version_info.h
Bob Badour5acd4362022-04-12 18:31:35 -07005695$(call declare-license-metadata,external/zucchini/version_info.h,legacy_notice,notice,external/zucchini/LICENSE,external/zucchini)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005696updater_dep += $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so
Yifan Hong65afc072020-04-17 10:08:10 -07005697endif
5698
5699# Build OTA tools if non-A/B is allowed
5700ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005701updater_dep += $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07005702endif
Yifan Hong65afc072020-04-17 10:08:10 -07005703
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005704$(BUILT_TARGET_FILES_DIR): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07005705
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005706# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07005707# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005708ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005709$(BUILT_TARGET_FILES_DIR): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07005710else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005711$(BUILT_TARGET_FILES_DIR): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005712else
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005713$(BUILT_TARGET_FILES_DIR): PRIVATE_RECOVERY_OUT := RECOVERY
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005714endif
5715
Dan Willemsen653bea92017-03-21 15:47:37 -07005716ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07005717 ifdef OSRELEASED_DIRECTORY
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005718 $(BUILT_TARGET_FILES_DIR): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
5719 $(BUILT_TARGET_FILES_DIR): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
5720 $(BUILT_TARGET_FILES_DIR): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
Dan Willemsen653bea92017-03-21 15:47:37 -07005721 endif
Tao Baoa835f382019-07-18 15:55:30 -07005722
5723 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
5724 # additionally include radio or bootloader partitions).
5725 ifeq ($(AB_OTA_PARTITIONS),)
5726 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
5727 endif
5728endif
5729
5730ifneq ($(AB_OTA_PARTITIONS),)
5731 ifneq ($(AB_OTA_UPDATER),true)
5732 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
5733 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07005734endif
5735
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005736# Run fs_config while creating the target files package
5737# $1: root directory
5738# $2: add prefix
5739define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08005740(cd $(1); find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,$(2),' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) -R "$(2)"
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005741endef
5742
Yifan Hong60bfcc42019-11-01 11:39:45 -07005743define filter-out-missing-vendor
5744$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
5745endef
Petri Gynther09865a42021-03-10 18:23:39 -08005746define filter-out-missing-vendor_dlkm
5747$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
5748endef
5749define filter-out-missing-odm
5750$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
5751endef
5752define filter-out-missing-odm_dlkm
5753$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
5754endef
Ramji Jiyani13a41372022-01-27 07:05:08 +00005755define filter-out-missing-system_dlkm
5756$(if $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(1),$(filter-out system_dlkm,$(1)))
5757endef
5758# Filter out vendor,vendor_dlkm,odm,odm_dlkm,system_dlkm from the list for AOSP targets.
Petri Gynther09865a42021-03-10 18:23:39 -08005759# $(1): list
5760define filter-out-missing-partitions
5761$(call filter-out-missing-vendor,\
5762 $(call filter-out-missing-vendor_dlkm,\
5763 $(call filter-out-missing-odm,\
Ramji Jiyani13a41372022-01-27 07:05:08 +00005764 $(call filter-out-missing-odm_dlkm,\
5765 $(call filter-out-missing-system_dlkm,$(1))))))
Petri Gynther09865a42021-03-10 18:23:39 -08005766endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07005767
5768# Information related to dynamic partitions and virtual A/B. This information
5769# is needed for building the super image (see dump-super-image-info) and
5770# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08005771# $(1): file
5772define dump-dynamic-partitions-info
5773 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
5774 echo "use_dynamic_partitions=true" >> $(1))
5775 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
5776 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08005777 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
5778 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
5779 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00005780 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
5781 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08005782 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
5783 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005784 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
5785 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5786 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
5787 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5788 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
5789 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005790 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005791 $(if $(BOARD_SUPER_PARTITION_GROUPS),
5792 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
5793 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
5794 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
5795 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005796 echo "super_$(group)_partition_list=$(call filter-out-missing-partitions,$(BOARD_$(call to-upper,$(group))_PARTITION_LIST))" >> $(1);))
Yifan Hongcb35bd92019-04-02 16:29:59 -07005797 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
5798 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07005799 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
5800 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005801 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
5802 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005803 $(if $(BOARD_SUPER_PARTITION_SIZE), \
5804 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
5805 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
5806 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
5807 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
5808 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
5809 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
5810 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005811 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
5812 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05005813 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
5814 echo "virtual_ab_compression=true" >> $(1))
Kelvin Zhangfa91e982022-02-09 11:19:16 -08005815# This value controls the compression algorithm used for VABC
5816# valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
5817# e.g. "none", "gz", "brotli"
5818 $(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD), \
5819 echo "virtual_ab_compression_method=$(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005820 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
5821 echo "virtual_ab_retrofit=true" >> $(1))
Daniel Zheng025099c2023-05-02 13:50:27 -07005822 $(if $(PRODUCT_VIRTUAL_AB_COW_VERSION), \
5823 echo "virtual_ab_cow_version=$(PRODUCT_VIRTUAL_AB_COW_VERSION)" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005824endef
5825
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005826# By conditionally including the dependency of the target files package on the
5827# full system image deps, we speed up builds that do not build the system
5828# image.
5829ifdef BUILDING_SYSTEM_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005830 $(BUILT_TARGET_FILES_DIR): $(FULL_SYSTEMIMAGE_DEPS)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005831else
5832 # releasetools may need the system build.prop even when building a
5833 # system-image-less product.
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005834 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_BUILD_PROP_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005835endif
5836
5837ifdef BUILDING_USERDATA_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005838 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_USERDATAIMAGE_FILES)
Colin Cross43f2eb22020-08-26 18:41:29 -07005839endif
5840
5841ifdef BUILDING_SYSTEM_OTHER_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005842 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
Colin Cross43f2eb22020-08-26 18:41:29 -07005843endif
5844
5845ifdef BUILDING_VENDOR_BOOT_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005846 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_RAMDISK_FILES)
5847 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
5848 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Colin Crosse6431202021-02-24 11:44:55 -08005849 # The vendor ramdisk may be built from the recovery ramdisk.
5850 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005851 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Colin Crosse6431202021-02-24 11:44:55 -08005852 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07005853endif
5854
5855ifdef BUILDING_RECOVERY_IMAGE
5856 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08005857 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07005858 # commands in build-recoveryimage-target, which would touch the files under
5859 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
5860 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005861 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_BOOTIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005862 else
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005863 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_RECOVERYIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005864 endif
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005865 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_RECOVERYIMAGE_FILES)
Colin Cross43f2eb22020-08-26 18:41:29 -07005866endif
5867
5868# Conditionally depend on the image files if the image is being built so the
5869# target-files.zip rule doesn't wait on the image creation rule, or the image
5870# if it is coming from a prebuilt.
5871
5872ifdef BUILDING_VENDOR_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005873 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDORIMAGE_FILES)
Colin Cross43f2eb22020-08-26 18:41:29 -07005874else ifdef BOARD_PREBUILT_VENDORIMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005875 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_VENDORIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005876endif
5877
5878ifdef BUILDING_PRODUCT_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005879 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_PRODUCTIMAGE_FILES)
Colin Cross43f2eb22020-08-26 18:41:29 -07005880else ifdef BOARD_PREBUILT_PRODUCTIMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005881 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_PRODUCTIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005882endif
5883
5884ifdef BUILDING_SYSTEM_EXT_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005885 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Colin Cross43f2eb22020-08-26 18:41:29 -07005886else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005887 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005888endif
5889
Devin Moore380d9e42021-11-04 19:01:19 +00005890ifneq (,$(BUILDING_BOOT_IMAGE)$(BUILDING_INIT_BOOT_IMAGE))
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005891 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_RAMDISK_FILES)
Devin Moore380d9e42021-11-04 19:01:19 +00005892endif # BUILDING_BOOT_IMAGE != "" || BUILDING_INIT_BOOT_IMAGE != ""
5893
Yifan Hong49968aa2020-11-09 11:52:52 -08005894ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005895 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_BOOTIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005896endif
5897
5898ifdef BUILDING_ODM_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005899 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_ODMIMAGE_FILES)
Colin Cross43f2eb22020-08-26 18:41:29 -07005900else ifdef BOARD_PREBUILT_ODMIMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005901 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_ODMIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005902endif
5903
5904ifdef BUILDING_VENDOR_DLKM_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005905 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005906else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005907 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005908endif
5909
5910ifdef BUILDING_ODM_DLKM_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005911 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005912else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005913 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005914endif
5915
Ramji Jiyani13a41372022-01-27 07:05:08 +00005916ifdef BUILDING_SYSTEM_DLKM_IMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005917 $(BUILT_TARGET_FILES_DIR): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
Ramji Jiyani13a41372022-01-27 07:05:08 +00005918else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005919 $(BUILT_TARGET_FILES_DIR): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
Ramji Jiyani13a41372022-01-27 07:05:08 +00005920endif
5921
Isaac Chen9e09d472019-07-05 17:30:41 +08005922ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07005923 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005924 $(BUILT_TARGET_FILES_DIR): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08005925endif
5926
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005927ifdef BOARD_PREBUILT_BOOTLOADER
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005928$(BUILT_TARGET_FILES_DIR): $(INSTALLED_BOOTLOADER_MODULE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005929droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005930endif
5931
The Android Open Source Project88b60792009-03-03 19:28:42 -08005932# Depending on the various images guarantees that the underlying
5933# directories are up-to-date.
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005934$(BUILT_TARGET_FILES_DIR): \
Anton Hansson6d814982018-11-26 18:12:05 +00005935 $(INSTALLED_RADIOIMAGE_TARGET) \
5936 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005937 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005938 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00005939 $(INSTALLED_PVMFWIMAGE_TARGET) \
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01005940 $(INSTALLED_PVMFW_BINARY_TARGET) \
Andrew Scullbbc930b2022-02-17 22:34:27 +00005941 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07005942 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005943 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
5944 $(INSTALLED_KERNEL_TARGET) \
Enrico Granatab582e0f2020-10-14 15:17:20 -06005945 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005946 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005947 $(INSTALLED_2NDBOOTLOADER_TARGET) \
5948 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08005949 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005950 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005951 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5952 $(PRODUCT_VENDOR_BASE_FS_PATH) \
5953 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09005954 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005955 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07005956 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07005957 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00005958 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00005959 $(LPMAKE) \
5960 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07005961 $(INSTALLED_MISC_INFO_TARGET) \
Daniel Zhengc1ffd4c2023-05-09 13:35:33 -07005962 $(INSTALLED_FASTBOOT_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005963 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005964 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005965 $(SOONG_ZIP) \
5966 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07005967 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07005968 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005969 $(BUILT_KERNEL_CONFIGS_FILE) \
5970 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005971 | $(ACP)
Kelvin Zhang2c561d82023-04-20 21:01:52 -07005972 @echo "Building target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005973 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005974 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07005975ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))$(filter true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005976 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005977 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005978# Exclude recovery files in the default vendor ramdisk if including a standalone
5979# recovery ramdisk in vendor_boot.
5980ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005981 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005982 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005983endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005984ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005985ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07005986 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07005987else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07005988 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
5989endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005990endif
Yifan Hong78860162020-10-28 14:15:21 -07005991ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005992ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005993 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005994endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005995ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08005996ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07005997 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08005998else
Steve Mucklee1b10862019-07-10 10:49:37 -07005999 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07006000endif
Steve Mucklee1b10862019-07-10 10:49:37 -07006001endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08006002ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07006003 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08006004endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07006005ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07006006 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08006007endif
Yifan Hongaad34e52020-10-12 11:08:30 -07006008ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07006009ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07006010 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07006011endif # INTERNAL_KERNEL_CMDLINE != ""
6012endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07006013ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07006014 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07006015endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07006016ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07006017 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07006018endif
Yifan Hong3941a872020-10-28 16:33:06 -07006019endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08006020endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08006021 @# Components of the boot image
6022 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07006023 $(hide) mkdir -p $(zip_root)/ROOT
6024 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006025 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08006026 @# If we are using recovery as boot, this is already done when processing recovery.
6027ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006028 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006029 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006030ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07006031 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08006032endif
Yifan Hong46aff092020-10-28 13:50:47 -07006033ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07006034 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07006035else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07006036 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08006037ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07006038 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08006039endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08006040ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07006041 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08006042endif
Doug Zongker38a649f2009-06-17 09:07:09 -07006043ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07006044 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07006045endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07006046ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07006047 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07006048endif
Yifan Hongaad34e52020-10-12 11:08:30 -07006049endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07006050endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07006051 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
6052 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07006053 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07006054ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
6055 mkdir -p $(zip_root)/VENDOR_BOOT
6056 $(call package_files-copy-root, \
6057 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
6058ifdef INSTALLED_DTBIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08006059ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
Steve Mucklee1b10862019-07-10 10:49:37 -07006060 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
6061endif
Lucas Weif57333f2022-02-24 10:30:15 +08006062endif # end of INSTALLED_DTBIMAGE_TARGET
Devin Moore50509012021-01-13 10:45:04 -08006063ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
6064 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
6065endif
Steve Mucklee1b10862019-07-10 10:49:37 -07006066ifdef BOARD_KERNEL_BASE
6067 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
6068endif
6069ifdef BOARD_KERNEL_PAGESIZE
6070 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
6071endif
6072 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08006073ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
6074 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
6075 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08006076 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
6077 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
6078 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
6079 $(if $(prebuilt_ramdisk), \
6080 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
6081 $(call package_files-copy-root, \
6082 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
6083 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
6084 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08006085endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07006086endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08006087ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
6088 mkdir -p $(zip_root)/VENDOR_KERNEL_BOOT
6089 $(call package_files-copy-root, \
6090 $(TARGET_VENDOR_KERNEL_RAMDISK_OUT),$(zip_root)/VENDOR_KERNEL_BOOT/RAMDISK)
6091ifdef INSTALLED_DTBIMAGE_TARGET
6092 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_KERNEL_BOOT/dtb
6093endif
6094ifdef BOARD_KERNEL_PAGESIZE
6095 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_KERNEL_BOOT/pagesize
6096endif
6097endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08006098ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08006099 @# Contents of the system image
6100 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006101 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08006102else ifdef INSTALLED_BUILD_PROP_TARGET
6103 @# Copy the system build.prop even if not building a system image
6104 @# because add_img_to_target_files may need it to build other partition
6105 @# images.
6106 $(hide) mkdir -p "$(zip_root)/SYSTEM"
6107 $(hide) cp "$(INSTALLED_BUILD_PROP_TARGET)" "$(patsubst $(TARGET_OUT)/%,$(zip_root)/SYSTEM/%,$(INSTALLED_BUILD_PROP_TARGET))"
Dan Willemsen67495202019-01-16 12:42:05 -08006108endif
6109ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08006110 @# Contents of the data image
6111 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006112 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08006113endif
6114ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07006115 @# Contents of the vendor image
6116 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006117 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07006118endif
Dan Willemsen67495202019-01-16 12:42:05 -08006119ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006120 @# Contents of the product image
6121 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006122 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006123endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006124ifdef BUILDING_SYSTEM_EXT_IMAGE
6125 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01006126 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09006127 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01006128endif
Dan Willemsen67495202019-01-16 12:42:05 -08006129ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006130 @# Contents of the odm image
6131 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006132 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006133endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006134ifdef BUILDING_VENDOR_DLKM_IMAGE
6135 @# Contents of the vendor_dlkm image
6136 $(hide) $(call package_files-copy-root, \
6137 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
6138endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07006139ifdef BUILDING_ODM_DLKM_IMAGE
6140 @# Contents of the odm_dlkm image
6141 $(hide) $(call package_files-copy-root, \
6142 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
6143endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006144ifdef BUILDING_SYSTEM_DLKM_IMAGE
6145 @# Contents of the system_dlkm image
6146 $(hide) $(call package_files-copy-root, \
6147 $(TARGET_OUT_SYSTEM_DLKM),$(zip_root)/SYSTEM_DLKM)
6148endif
Dan Willemsen67495202019-01-16 12:42:05 -08006149ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07006150 @# Contents of the system_other image
6151 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00006152 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07006153endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006154 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07006155 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07006156 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granatab582e0f2020-10-14 15:17:20 -06006157ifdef BUILDING_RAMDISK_IMAGE
6158ifeq (true,$(BOARD_IMG_USE_RAMDISK))
6159 @# Contents of the ramdisk image
6160 $(hide) mkdir -p $(zip_root)/IMAGES
6161 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
6162endif
6163endif
Yifan Hong65afc072020-04-17 10:08:10 -07006164ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08006165ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07006166 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07006167 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07006168endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08006169endif
Doug Zongker8678df42009-06-15 14:30:14 -07006170 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08006171 @# build them.
6172 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07006173 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09006174 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07006175ifneq ($(tool_extension),)
6176 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
6177endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07006178 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07006179 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07006180 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Daniel Zhengc1ffd4c2023-05-09 13:35:33 -07006181ifneq ($(INSTALLED_FASTBOOT_INFO_TARGET),)
6182 $(hide) cp $(INSTALLED_FASTBOOT_INFO_TARGET) $(zip_root)/META/fastboot-info.txt
6183endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00006184ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
6185 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
6186 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07006187endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00006188ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
6189 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
6190 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07006191endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00006192ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
6193 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
6194 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006195endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006196ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
6197 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
6198 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01006199endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00006200ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
6201 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
6202 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006203endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006204ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
6205 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
6206 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
6207endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07006208ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
6209 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
6210 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
6211endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006212ifneq ($(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH),)
6213 $(hide) cp $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
6214 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH))
6215endif
Yifan Hong65afc072020-04-17 10:08:10 -07006216ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07006217ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07006218 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07006219 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07006220endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08006221endif
Alex Deymo70067ac2015-09-29 19:05:37 -07006222ifeq ($(AB_OTA_UPDATER),true)
6223 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07006224 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Kelvin Zhangc06f0622021-11-30 12:38:39 -08006225 $(hide) cp $(TOPDIR)external/zucchini/version_info.h $(zip_root)/META/zucchini_config.txt
Kelvin Zhang6877e812022-01-06 11:12:04 -08006226 $(hide) cp $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so $(zip_root)/META/liblz4.so
Cole Faust90099992022-02-17 11:35:27 -08006227 $(hide) for part in $(sort $(AB_OTA_PARTITIONS)); do \
Alex Deymo8925d332015-10-01 17:38:09 -07006228 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
6229 done
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07006230 $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
Sen Jiang8f22e2a2015-11-12 13:53:25 -08006231 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
6232 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07006233ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07006234 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
6235 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
6236 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07006237endif
Alex Deymo70067ac2015-09-29 19:05:37 -07006238endif
Steve Fungdfbab492015-09-24 18:12:33 -07006239ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07006240 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07006241 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07006242endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07006243ifdef BOARD_PREBUILT_VENDORIMAGE
6244 $(hide) mkdir -p $(zip_root)/IMAGES
6245 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
6246endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006247ifdef BOARD_PREBUILT_PRODUCTIMAGE
6248 $(hide) mkdir -p $(zip_root)/IMAGES
6249 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
6250endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006251ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01006252 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09006253 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01006254endif
Devin Moore380d9e42021-11-04 19:01:19 +00006255ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
Devin Moorecda41f02022-01-05 00:08:39 +00006256 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6257 $(hide) cp $(INSTALLED_INIT_BOOT_IMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Devin Moore380d9e42021-11-04 19:01:19 +00006258endif
Ramji Jiyani034e7772022-01-24 04:00:29 +00006259
Bowgo Tsaib23656d2021-05-20 00:14:42 +08006260ifndef BOARD_PREBUILT_BOOTIMAGE
Yi-Yo Chiang81939002022-01-08 23:46:40 +08006261ifneq (,$(strip $(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES))))
Yifan Hong49968aa2020-11-09 11:52:52 -08006262ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07006263 $(hide) mkdir -p $(zip_root)/IMAGES
6264 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08006265endif # INSTALLED_BOOTIMAGE_TARGET
6266endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaib23656d2021-05-20 00:14:42 +08006267else # BOARD_PREBUILT_BOOTIMAGE is defined
6268 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6269 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
6270endif # BOARD_PREBUILT_BOOTIMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006271ifdef BOARD_PREBUILT_ODMIMAGE
6272 $(hide) mkdir -p $(zip_root)/IMAGES
6273 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
6274endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07006275ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07006276 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07006277 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
6278endif
6279ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
6280 $(hide) mkdir -p $(zip_root)/IMAGES
6281 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07006282endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006283ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
6284 $(hide) mkdir -p $(zip_root)/IMAGES
6285 $(hide) cp $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
6286endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07006287ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07006288 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6289 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08006290endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01006291ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00006292 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6293 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Andrew Scullbbc930b2022-02-17 22:34:27 +00006294 $(hide) cp $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) $(zip_root)/PREBUILT_IMAGES/
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01006295 $(hide) mkdir -p $(zip_root)/PVMFW
6296 $(hide) cp $(INSTALLED_PVMFW_BINARY_TARGET) $(zip_root)/PVMFW/
Pierre-Clément Tosid8248af2021-10-07 12:18:17 +02006297endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00006298ifdef BOARD_PREBUILT_BOOTLOADER
6299 $(hide) mkdir -p $(zip_root)/IMAGES
6300 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
6301endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07006302ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
6303 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6304 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
6305 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
6306endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07006307 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
6308 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
6309 @# INSTALLED_RADIOIMAGE_TARGET.
6310 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
6311 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006312 @# Run fs_config on all the system, vendor, boot ramdisk,
6313 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08006314ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006315 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08006316endif
6317ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006318 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
6319endif
Dan Willemsen67495202019-01-16 12:42:05 -08006320ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006321 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
6322endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006323ifdef BUILDING_SYSTEM_EXT_IMAGE
6324 $(hide) $(call fs_config,$(zip_root)/SYSTEM_EXT,system_ext/) > $(zip_root)/META/system_ext_filesystem_config.txt
Dario Freni5f681e12018-05-29 13:09:01 +01006325endif
Dan Willemsen67495202019-01-16 12:42:05 -08006326ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006327 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
6328endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006329ifdef BUILDING_VENDOR_DLKM_IMAGE
6330 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
6331endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07006332ifdef BUILDING_ODM_DLKM_IMAGE
6333 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
6334endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006335ifdef BUILDING_SYSTEM_DLKM_IMAGE
6336 $(hide) $(call fs_config,$(zip_root)/SYSTEM_DLKM,system_dlkm/) > $(zip_root)/META/system_dlkm_filesystem_config.txt
6337endif
Tom Cherryd14b8952018-08-09 14:26:00 -07006338 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006339 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08006340 @# BOOT/RAMDISK contains the first stage and recovery ramdisk.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006341 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Devin Moore380d9e42021-11-04 19:01:19 +00006342ifdef BUILDING_INIT_BOOT_IMAGE
6343 $(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK)
6344 $(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt
Vincent Donnefort6e861e92023-02-17 10:12:57 +00006345 $(hide) cp $(RAMDISK_NODE_LIST) $(zip_root)/META/ramdisk_node_list
Devin Moore380d9e42021-11-04 19:01:19 +00006346ifdef BOARD_KERNEL_PAGESIZE
6347 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize
6348endif # BOARD_KERNEL_PAGESIZE
6349endif # BUILDING_INIT_BOOT_IMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07006350ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
6351 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
6352endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006353ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
6354 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
6355endif
Dan Willemsen67495202019-01-16 12:42:05 -08006356ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006357 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
6358endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07006359 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07006360ifdef BUILT_KERNEL_CONFIGS_FILE
6361 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
6362endif
6363ifdef BUILT_KERNEL_VERSION_FILE
6364 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
6365endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07006366 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
6367ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6368 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
6369endif
Tao Baocbd6d492019-10-07 22:46:02 -07006370 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
6371 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08006372ifeq ($(BUILD_QEMU_IMAGES),true)
6373 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
6374 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
6375endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08006376 @# Zip everything up, preserving symlinks and placing META/ files first to
6377 @# help early validation of the .zip file while uploading it.
Kelvin Zhang2c561d82023-04-20 21:01:52 -07006378 $(hide) find $(zip_root)/META | sort >$@
6379 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@
6380
6381$(BUILT_TARGET_FILES_PACKAGE): $(BUILT_TARGET_FILES_DIR)
6382 @echo "Packaging target files: $@"
Colin Cross17e98b72021-02-03 16:03:55 -08006383 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07006384
Ying Wanga0febe52013-03-20 11:02:05 -07006385.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08006386target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
6387
Kelvin Zhang2c561d82023-04-20 21:01:52 -07006388.PHONY: target-files-dir
6389target-files-dir: $(BUILT_TARGET_FILES_DIR)
6390
Bob Badour5acd4362022-04-12 18:31:35 -07006391$(call declare-1p-container,$(BUILT_TARGET_FILES_PACKAGE),)
6392$(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED_RADIOIMAGE_TARGET) \
6393 $(INSTALLED_RECOVERYIMAGE_TARGET) \
6394 $(INSTALLED_CACHEIMAGE_TARGET) \
6395 $(INSTALLED_DTBOIMAGE_TARGET) \
6396 $(INSTALLED_PVMFWIMAGE_TARGET) \
6397 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
6398 $(INSTALLED_CUSTOMIMAGES_TARGET) \
6399 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
6400 $(INSTALLED_KERNEL_TARGET) \
6401 $(INSTALLED_RAMDISK_TARGET) \
6402 $(INSTALLED_DTBIMAGE_TARGET) \
6403 $(INSTALLED_2NDBOOTLOADER_TARGET) \
6404 $(BOARD_PREBUILT_DTBOIMAGE) \
6405 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
6406 $(BOARD_RECOVERY_ACPIO) \
6407 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
6408 $(PRODUCT_VENDOR_BASE_FS_PATH) \
6409 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
6410 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
6411 $(PRODUCT_ODM_BASE_FS_PATH) \
6412 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
6413 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
6414 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
6415 $(LPMAKE) \
6416 $(SELINUX_FC) \
6417 $(INSTALLED_MISC_INFO_TARGET) \
David Anderson816da932023-03-09 21:09:07 -08006418 $(INSTALLED_FASTBOOT_INFO_TARGET) \
Bob Badour5acd4362022-04-12 18:31:35 -07006419 $(APKCERTS_FILE) \
6420 $(SOONG_APEX_KEYS_FILE) \
6421 $(HOST_OUT_EXECUTABLES)/fs_config \
6422 $(ADD_IMG_TO_TARGET_FILES) \
6423 $(MAKE_RECOVERY_PATCH) \
6424 $(BUILT_KERNEL_CONFIGS_FILE) \
6425 $(BUILT_KERNEL_VERSION_FILE),$(BUILT_TARGET_FILES_PACKAGE):)
6426
Ying Wang4709d7c2014-04-14 17:25:43 -07006427$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07006428
Dan Albert4d323332016-10-14 13:23:06 -07006429# -----------------------------------------------------------------
6430# NDK Sysroot Package
6431NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Colin Crossec65b762022-10-20 14:03:47 -07006432.PHONY: ndk_sysroot
6433ndk_sysroot: $(NDK_SYSROOT_TARGET)
Dan Willemsen14e10262018-06-17 21:54:21 -07006434$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07006435 @echo Package NDK sysroot...
6436 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
6437
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006438ifeq ($(HOST_OS),linux)
Colin Crossec65b762022-10-20 14:03:47 -07006439$(call dist-for-goals,sdk ndk_sysroot,$(NDK_SYSROOT_TARGET))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006440endif
Dan Albert4d323332016-10-14 13:23:06 -07006441
Ying Wang09c4b682015-08-11 11:24:19 -07006442ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07006443# -----------------------------------------------------------------
6444# OTA update package
6445
Yifan Hong50e79542018-11-08 17:44:12 -08006446# $(1): output file
6447# $(2): additional args
6448define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07006449PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07006450 $(OTA_FROM_TARGET_FILES) \
6451 --verbose \
Tao Bao8821d642019-08-05 12:05:45 -07006452 --path $(HOST_OUT) \
6453 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
6454 $(2) \
Kelvin Zhang01e67f62023-05-10 17:03:40 +00006455 $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08006456endef
6457
Tianjie6bd3b1a2020-10-16 18:53:47 -07006458product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07006459ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006460 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07006461endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07006462name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07006463
6464INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08006465INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
6466
Bob Badour5acd4362022-04-12 18:31:35 -07006467$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
6468
Doug Zongker8678df42009-06-15 14:30:14 -07006469$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08006470$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Kelvin Zhang01e67f62023-05-10 17:03:40 +00006471$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_DIR) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07006472 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08006473 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07006474
Bob Badour5acd4362022-04-12 18:31:35 -07006475$(call declare-1p-container,$(INTERNAL_OTA_PACKAGE_TARGET),)
6476$(call declare-container-license-deps,$(INTERNAL_OTA_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6477
Doug Zongker8678df42009-06-15 14:30:14 -07006478.PHONY: otapackage
6479otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
6480
Tao Bao519d1822018-12-27 12:47:23 -08006481ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006482name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08006483
6484INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08006485$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07006486$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
6487 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07006488 $(OTA_FROM_TARGET_FILES) \
6489 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08006490 @echo "Package OTA (retrofit dynamic partitions): $@"
6491 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
6492
Bob Badour5acd4362022-04-12 18:31:35 -07006493$(call declare-1p-container,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),)
6494$(call declare-container-license-deps,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6495
Yifan Hong50e79542018-11-08 17:44:12 -08006496.PHONY: otardppackage
6497
6498otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
6499
Tao Bao519d1822018-12-27 12:47:23 -08006500endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08006501
Tianjie6bd3b1a2020-10-16 18:53:47 -07006502ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
6503name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
6504
6505INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6506$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Kelvin Zhang01e67f62023-05-10 17:03:40 +00006507$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_DIR) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006508 @echo "Package partial OTA: $@"
6509 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
6510
Bob Badour5acd4362022-04-12 18:31:35 -07006511$(call declare-1p-container,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),)
6512$(call declare-container-license-deps,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6513
6514
Tianjie6bd3b1a2020-10-16 18:53:47 -07006515.PHONY: partialotapackage
6516partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
6517
6518endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
6519
Ying Wang09c4b682015-08-11 11:24:19 -07006520endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07006521
Ying Wang09a00a62010-10-20 14:01:09 -07006522# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01006523# A zip of the appcompat directory containing logs
6524APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
6525# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006526ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07006527$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
6528 $(INTERNAL_RAMDISK_FILES) \
6529 $(INTERNAL_USERDATAIMAGE_FILES) \
6530 $(INTERNAL_VENDORIMAGE_FILES) \
6531 $(INTERNAL_PRODUCTIMAGE_FILES) \
6532 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01006533endif
6534$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
6535$(APPCOMPAT_ZIP): $(SOONG_ZIP)
6536 @echo "appcompat logs: $@"
6537 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6538 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
6539 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
6540 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
6541
Jeongik Cha2522c362021-04-27 23:52:15 +09006542# The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
6543ifeq ($(BUILD_OS),linux)
Jeongik Cha62519de2021-05-13 13:29:39 +09006544ifneq ($(DEX2OAT),)
Saeid Farivar Asanjan0b4f8d52022-08-08 20:23:45 +00006545dexpreopt_tools_deps := $(DEXPREOPT_GEN_DEPS) $(DEXPREOPT_GEN)
Eric Miao1d0fd2c2021-11-08 19:34:50 +00006546dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/dexdump
6547dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/oatdump
Jeongik Cha2522c362021-04-27 23:52:15 +09006548DEXPREOPT_TOOLS_ZIP := $(PRODUCT_OUT)/dexpreopt_tools.zip
6549$(DEXPREOPT_TOOLS_ZIP): $(dexpreopt_tools_deps)
6550$(DEXPREOPT_TOOLS_ZIP): PRIVATE_DEXPREOPT_TOOLS_DEPS := $(dexpreopt_tools_deps)
6551$(DEXPREOPT_TOOLS_ZIP): $(SOONG_ZIP)
6552 $(hide) mkdir -p $(dir $@)
6553 $(hide) $(SOONG_ZIP) -d -o $@ -j $(addprefix -f ,$(PRIVATE_DEXPREOPT_TOOLS_DEPS)) -f $$(realpath $(DEX2OAT))
Bob Badour5acd4362022-04-12 18:31:35 -07006554$(call declare-1p-target,$(DEXPREOPT_TOOLS_ZIP),)
Jeongik Cha62519de2021-05-13 13:29:39 +09006555endif # DEX2OAT is set
6556endif # BUILD_OS == linux
Jeongik Cha2522c362021-04-27 23:52:15 +09006557
Jeongik Chaa8056d62021-04-07 23:57:16 +09006558DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
Jeongik Chab26bf582021-06-08 11:31:31 +09006559
6560$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
6561 $(INSTALLED_VENDORIMAGE_TARGET) \
6562 $(INSTALLED_ODMIMAGE_TARGET) \
6563 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6564
6565ifeq (,$(TARGET_BUILD_UNBUNDLED))
6566$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
6567 $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
6568
6569endif
Jeongik Chaa8056d62021-04-07 23:57:16 +09006570
6571$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
6572 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Chab26bf582021-06-08 11:31:31 +09006573
6574ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006575ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006576 $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006577endif
6578ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006579 $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006580endif
Jeongik Chab26bf582021-06-08 11:31:31 +09006581endif #!TARGET_BUILD_UNBUNDLED
Jeongik Chaa8056d62021-04-07 23:57:16 +09006582 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
6583
Jeongik Chab26bf582021-06-08 11:31:31 +09006584.PHONY: dexpreopt_config_zip
6585dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
6586
Bob Badour5acd4362022-04-12 18:31:35 -07006587$(call declare-1p-target,$(DEXPREOPT_CONFIG_ZIP),)
6588
Dario Frenid1011272018-07-23 20:20:15 +01006589# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006590# A zip of the symbols directory. Keep the full paths to make it
6591# more obvious where these files came from.
Colin Crossac7febc2022-04-06 01:11:20 +00006592# Also produces a textproto containing mappings from elf IDs to symbols
6593# filename, which will allow finding the appropriate symbols to deobfuscate
6594# a stack trace frame.
The Android Open Source Project88b60792009-03-03 19:28:42 -08006595#
Colin Crossac7febc2022-04-06 01:11:20 +00006596
The Android Open Source Project88b60792009-03-03 19:28:42 -08006597name := $(TARGET_PRODUCT)
6598ifeq ($(TARGET_BUILD_TYPE),debug)
6599 name := $(name)_debug
6600endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006601
Colin Crossac7febc2022-04-06 01:11:20 +00006602# The path to the zip file containing binaries with symbols.
6603SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols-$(FILE_NAME_TAG).zip
6604# The path to a file containing mappings from elf IDs to filenames.
6605SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping-$(FILE_NAME_TAG).textproto
6606.KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING
Colin Cross6cdc5d22017-10-20 11:37:33 -07006607# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006608ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006609$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07006610endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006611$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
Colin Crossac7febc2022-04-06 01:11:20 +00006612$(SYMBOLS_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)
6613$(SYMBOLS_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006614 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006615 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006616 $(hide) mkdir -p $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE)) $(PRIVATE_MAPPING_PACKAGING_DIR)
6617 # Find all of the files in the symbols directory and zip them into the symbols zip.
Jiyong Park88e09802019-03-21 15:19:16 +09006618 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07006619 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006620 # Find all of the files in the symbols mapping directory and merge them into the symbols mapping textproto.
6621 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6622 $(hide) $(SYMBOLS_MAP) -merge $(SYMBOLS_MAPPING) -ignore_missing_files @$(PRIVATE_LIST_FILE)
6623$(SYMBOLS_ZIP): .KATI_IMPLICIT_OUTPUTS := $(SYMBOLS_MAPPING)
6624
Bob Badour5acd4362022-04-12 18:31:35 -07006625$(call declare-1p-container,$(SYMBOLS_ZIP),)
6626ifeq (,$(TARGET_BUILD_UNBUNDLED))
6627$(call declare-container-license-deps,$(SYMBOLS_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6628endif
6629
Ryan Campbell81c9d292016-09-12 13:56:50 -07006630# -----------------------------------------------------------------
6631# A zip of the coverage directory.
6632#
Oliver Nguyene91ab232019-04-30 15:14:44 -07006633name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07006634ifeq ($(TARGET_BUILD_TYPE),debug)
6635name := $(name)_debug
6636endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07006637COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006638ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006639$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07006640endif
6641$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
6642$(COVERAGE_ZIP): $(SOONG_ZIP)
6643 @echo "Package coverage: $@"
6644 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6645 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
6646 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
6647 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006648
Bob Badourf2529722022-03-18 11:34:03 -07006649$(call declare-1p-container,$(COVERAGE_ZIP),)
Bob Badour5acd4362022-04-12 18:31:35 -07006650ifeq (,$(TARGET_BUILD_UNBUNDLED))
Bob Badourf2529722022-03-18 11:34:03 -07006651$(call declare-container-license-deps,$(COVERAGE_ZIP),$(INTERNAL_ALLIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badour5acd4362022-04-12 18:31:35 -07006652endif
Bob Badourf2529722022-03-18 11:34:03 -07006653
6654SYSTEM_NOTICE_DEPS += $(COVERAGE_ZIP)
6655
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006656#------------------------------------------------------------------
6657# Export the LLVM profile data tool and dependencies for Clang coverage processing
6658#
6659ifeq (true,$(CLANG_COVERAGE))
6660 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006661 LLVM_COV := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov
Qing Shend058fc32022-09-30 00:27:58 +00006662 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib/x86_64-unknown-linux-gnu/libc++.so.1
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006663 # Use llvm-profdata.zip for backwards compatibility with tradefed code.
6664 LLVM_COVERAGE_TOOLS_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006665
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006666 $(LLVM_COVERAGE_TOOLS_ZIP): $(SOONG_ZIP)
6667 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX) -f $(LLVM_COV)
6668
6669 $(call dist-for-goals,droidcore-unbundled apps_only,$(LLVM_COVERAGE_TOOLS_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006670endif
6671
The Android Open Source Project88b60792009-03-03 19:28:42 -08006672# -----------------------------------------------------------------
6673# A zip of the Android Apps. Not keeping full path so that we don't
6674# include product names when distributing
6675#
6676name := $(TARGET_PRODUCT)
6677ifeq ($(TARGET_BUILD_TYPE),debug)
6678 name := $(name)_debug
6679endif
6680name := $(name)-apps-$(FILE_NAME_TAG)
6681
6682APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07006683$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006684 @echo "Package apps: $@"
6685 $(hide) rm -rf $@
6686 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006687 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
6688 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00006689 echo "No apps to zip up. Generating empty apps archive." ; \
6690 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006691 else \
Anton Hansson6d814982018-11-26 18:12:05 +00006692 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006693 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07006694
Ying Wangbc415dd2012-08-15 12:22:44 -07006695ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07006696#------------------------------------------------------------------
6697# An archive of classes for use in generating code-coverage reports
6698# These are the uninstrumented versions of any classes that were
6699# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07006700# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006701
Colin Crossa6bc3a82017-09-27 14:28:41 -07006702JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Colin Cross330b1fe2021-04-06 18:04:06 -07006703$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
6704$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
6705$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
6706$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006707$(JACOCO_REPORT_CLASSES_ALL) :
6708 @echo "Collecting uninstrumented classes"
Colin Cross330b1fe2021-04-06 18:04:06 -07006709 mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
6710 $(SOONG_ZIP) -o $@ -L 0 \
6711 -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
6712 -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
6713 -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
6714 -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006715
Jiyong Park3c875602021-01-21 12:46:56 +09006716ifeq (,$(TARGET_BUILD_UNBUNDLED))
6717 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
6718endif
Ying Wangbc415dd2012-08-15 12:22:44 -07006719endif # EMMA_INSTRUMENT=true
6720
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006721
Ying Wangae9115a2013-08-22 20:52:47 -07006722#------------------------------------------------------------------
6723# A zip of Proguard obfuscation dictionary files.
Colin Crossac7febc2022-04-06 01:11:20 +00006724# Also produces a textproto containing mappings from the hashes of the
6725# dictionary contents (which are also stored in the dex files on the
6726# devices) to the filename of the proguard dictionary, which will allow
6727# finding the appropriate dictionary to deobfuscate a stack trace frame.
Ying Wangae9115a2013-08-22 20:52:47 -07006728#
Colin Crossac7febc2022-04-06 01:11:20 +00006729
6730# The path to the zip file containing proguard dictionaries.
Ying Wangc62c92c2013-08-28 18:38:25 -07006731PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Crossac7febc2022-04-06 01:11:20 +00006732# The path to the zip file containing mappings from dictionary hashes to filenames.
6733PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping-$(FILE_NAME_TAG).textproto
6734.KATI_READONLY := PROGUARD_DICT_ZIP PROGUARD_DICT_MAPPING
Colin Cross114e8df2019-09-05 17:19:35 -07006735# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006736ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006737$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07006738endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006739$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
Colin Crossac7febc2022-04-06 01:11:20 +00006740$(PROGUARD_DICT_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)
6741$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_filelist)/filelist
6742$(PROGUARD_DICT_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
Ying Wangae9115a2013-08-22 20:52:47 -07006743 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossac7febc2022-04-06 01:11:20 +00006744 rm -rf $@ $(PRIVATE_LIST_FILE)
6745 mkdir -p $(PRIVATE_PACKAGING_DIR) $(PRIVATE_MAPPING_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6746 # Zip all of the files in the proguard dictionary directory.
6747 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -D $(PRIVATE_PACKAGING_DIR)
6748 # Find all of the files in the proguard dictionary mapping directory and merge them into the mapping textproto.
6749 # Strip the PRIVATE_PACKAGING_DIR off the filenames to match soong_zip's -C argument.
6750 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6751 $(SYMBOLS_MAP) -merge $(PROGUARD_DICT_MAPPING) -strip_prefix $(PRIVATE_PACKAGING_DIR)/ -ignore_missing_files @$(PRIVATE_LIST_FILE)
6752$(PROGUARD_DICT_ZIP): .KATI_IMPLICIT_OUTPUTS := $(PROGUARD_DICT_MAPPING)
Ying Wangae9115a2013-08-22 20:52:47 -07006753
Bob Badour5acd4362022-04-12 18:31:35 -07006754$(call declare-1p-container,$(PROGUARD_DICT_ZIP),)
6755ifeq (,$(TARGET_BUILD_UNBUNDLED))
6756$(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6757endif
6758
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006759#------------------------------------------------------------------
6760# A zip of Proguard usage files.
6761#
6762PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
6763# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
6764ifeq (,$(TARGET_BUILD_UNBUNDLED))
6765$(PROGUARD_USAGE_ZIP): \
6766 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6767 $(INSTALLED_RAMDISK_TARGET) \
6768 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00006769 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006770 $(INSTALLED_USERDATAIMAGE_TARGET) \
6771 $(INSTALLED_VENDORIMAGE_TARGET) \
6772 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6773 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6774 $(INSTALLED_ODMIMAGE_TARGET) \
6775 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6776 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00006777 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006778 $(updater_dep)
6779endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006780$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
6781$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006782$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
6783 @echo "Packaging Proguard usage files."
Colin Cross330b1fe2021-04-06 18:04:06 -07006784 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6785 find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006786 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07006787
Bob Badour5acd4362022-04-12 18:31:35 -07006788$(call declare-1p-container,$(PROGUARD_USAGE_ZIP),)
6789ifeq (,$(TARGET_BUILD_UNBUNDLED))
6790$(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(INSTALLED_SYSTEMIMAGE_TARGET) \
6791 $(INSTALLED_RAMDISK_TARGET) \
6792 $(INSTALLED_BOOTIMAGE_TARGET) \
6793 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
6794 $(INSTALLED_USERDATAIMAGE_TARGET) \
6795 $(INSTALLED_VENDORIMAGE_TARGET) \
6796 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6797 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6798 $(INSTALLED_ODMIMAGE_TARGET) \
6799 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6800 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
6801 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
6802 $(updater_dep),$(PROGUARD_USAGE_ZIP):/)
6803endif
6804
Tao Bao48a2feb2019-06-28 11:00:05 -07006805ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6806
6807# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
6808# $(1): output file
6809define dump-super-image-info
6810 $(call dump-dynamic-partitions-info,$(1))
6811 $(if $(filter true,$(AB_OTA_UPDATER)), \
6812 echo "ab_update=true" >> $(1))
6813endef
6814
6815endif # PRODUCT_USE_DYNAMIC_PARTITIONS
6816
The Android Open Source Project88b60792009-03-03 19:28:42 -08006817# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07006818# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08006819
6820ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6821
6822# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
6823ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6824
6825ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07006826
6827# For real devices and for dist builds, build super image from target files to an intermediate directory.
6828INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
6829$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
Kelvin Zhang01e67f62023-05-10 17:03:40 +00006830$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_DIR) $(BUILD_SUPER_IMAGE)
Yifan Hongacd862a2019-04-16 15:44:30 -07006831 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08006832 PATH=$(dir $(LPMAKE)):$$PATH \
6833 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07006834
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006835# Skip packing it in dist package because it is in update package.
6836ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07006837$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006838endif
Yifan Hongacd862a2019-04-16 15:44:30 -07006839
6840.PHONY: superimage_dist
6841superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07006842
6843endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07006844endif # BOARD_SUPER_PARTITION_SIZE != ""
6845endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08006846
Yifan Hongacd862a2019-04-16 15:44:30 -07006847# -----------------------------------------------------------------
6848# super partition image for development
6849
6850ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6851ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6852ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
6853
6854# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
6855# $(1): built image path
6856# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
6857define build-superimage-target
6858 mkdir -p $(dir $(2))
6859 rm -rf $(2)
6860 $(call dump-super-image-info,$(2))
6861 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
6862 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09006863 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
6864 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07006865 mkdir -p $(dir $(1))
6866 PATH=$(dir $(LPMAKE)):$$PATH \
6867 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
6868endef
6869
6870INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
6871INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
6872 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
6873
changho.shina8f9f112019-10-15 13:26:19 +09006874ifdef BUILDING_SYSTEM_OTHER_IMAGE
6875ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
6876INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
6877endif
6878endif
6879
Yifan Hongacd862a2019-04-16 15:44:30 -07006880$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6881 $(call pretty,"Target super fs image for debug: $@")
6882 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08006883 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006884
Yifan Hongacd862a2019-04-16 15:44:30 -07006885# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
6886.PHONY: superimage
6887superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08006888
Peter Collingbourne683c4932022-07-06 15:49:20 -07006889# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
6890# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
6891# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
6892# virtual devices.
6893ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
6894droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
6895
Isaac Chen52cc60c2019-08-14 18:52:13 +08006896$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006897endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
6898
6899# Build $(PRODUCT_OUT)/super.img without dependencies.
6900.PHONY: superimage-nodeps supernod
6901superimage-nodeps supernod: intermediates :=
6902superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6903 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
6904 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
6905 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
6906
6907endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
6908endif # BOARD_SUPER_PARTITION_SIZE != ""
6909endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
6910
6911# -----------------------------------------------------------------
6912# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00006913ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006914
Yifan Hong8b79d162018-11-29 12:32:00 -08006915INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
6916$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
6917$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
6918 $(call pretty,"Target empty super fs image: $@")
6919 mkdir -p $(intermediates)
6920 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07006921 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08006922 PATH=$(dir $(LPMAKE)):$$PATH \
6923 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08006924
6925$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6926
Bob Badourebdefc02022-02-12 15:39:22 -08006927$(call declare-0p-target,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6928
Yo Chiange86bab42021-03-25 10:12:28 +00006929endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006930
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006931
6932# -----------------------------------------------------------------
6933# The update package
6934
6935name := $(TARGET_PRODUCT)
6936ifeq ($(TARGET_BUILD_TYPE),debug)
6937 name := $(name)_debug
6938endif
6939name := $(name)-img-$(FILE_NAME_TAG)
6940
6941INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6942
Tao Bao57f8ed62019-08-14 23:08:18 -07006943$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
6944 $(call pretty,"Package: $@")
6945 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
6946 $(IMG_FROM_TARGET_FILES) \
6947 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
6948 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006949
Bob Badour5acd4362022-04-12 18:31:35 -07006950$(call declare-1p-container,$(INTERNAL_UPDATE_PACKAGE_TARGET),)
6951$(call declare-container-license-deps,$(INTERNAL_UPDATE_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES),$(PRODUCT_OUT)/:/)
6952
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006953.PHONY: updatepackage
6954updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07006955$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006956
6957
Yifan Hong2b891ac2018-11-29 12:06:31 -08006958# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006959# dalvik something
6960.PHONY: dalvikfiles
6961dalvikfiles: $(INTERNAL_DALVIK_MODULES)
6962
Bo Huf0d50bb2017-08-01 19:02:09 +00006963ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00006964MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08006965MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00006966SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08006967
6968ifdef INSTALLED_SYSTEMIMAGE_TARGET
6969INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08006970INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
6971$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
6972 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
6973 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08006974$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08006975 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
6976 @echo Create system-qemu.img now
6977 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08006978 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00006979
6980systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006981droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08006982endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006983ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00006984INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006985$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00006986 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006987 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00006988
6989vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006990droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
Bo Huf0d50bb2017-08-01 19:02:09 +00006991endif
bohu8fd437c2020-03-30 20:16:13 -07006992
6993ifdef INSTALLED_RAMDISK_TARGET
6994ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
6995ifdef INTERNAL_VENDOR_RAMDISK_TARGET
6996INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
6997$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
6998 @echo Create ramdisk-qemu.img
6999 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
7000
Bill Peckham315b98a2021-06-15 19:35:06 -07007001droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
bohu8fd437c2020-03-30 20:16:13 -07007002endif
7003endif
7004endif
7005
Anton Hansson32c76fe2018-12-13 14:34:18 +00007006ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09007007INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00007008$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09007009 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08007010 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09007011
7012productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07007013droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09007014endif
Justin Yun6151e3f2019-06-25 15:58:13 +09007015ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
7016INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
7017$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
7018 @echo Create system_ext-qemu.img
7019 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01007020
Justin Yun6151e3f2019-06-25 15:58:13 +09007021systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07007022droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01007023endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00007024ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08007025INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
7026$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
7027 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08007028 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08007029
7030odmimage: $(INSTALLED_QEMU_ODMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07007031droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08007032endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07007033
Yifan Hongcfb917a2020-05-07 14:58:20 -07007034ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
7035INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
7036$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
7037 @echo Create vendor_dlkm-qemu.img
7038 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
7039
7040vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07007041droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07007042endif
7043
Yifan Hongf496f1b2020-07-15 16:52:59 -07007044ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
7045INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
7046$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
7047 @echo Create odm_dlkm-qemu.img
7048 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
7049
7050odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07007051droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07007052endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07007053
Ramji Jiyani13a41372022-01-27 07:05:08 +00007054ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
7055INSTALLED_QEMU_SYSTEM_DLKMIMAGE := $(PRODUCT_OUT)/system_dlkm-qemu.img
7056$(INSTALLED_QEMU_SYSTEM_DLKMIMAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
7057 @echo Create system_dlkm-qemu.img
7058 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET))
7059
7060system_dlkmimage: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
7061droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
7062endif
7063
Matt Wachowski9e4d5152018-08-07 16:29:22 -07007064QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08007065$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
7066 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07007067 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08007068 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
7069 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07007070
7071systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
Bill Peckham315b98a2021-06-15 19:35:06 -07007072droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08007073
Bo Huf0d50bb2017-08-01 19:02:09 +00007074endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08007075# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08007076# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07007077ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007078INTERNAL_EMULATOR_PACKAGE_FILES += \
7079 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007080 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07007081 $(INSTALLED_SYSTEMIMAGE_TARGET) \
7082 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007083
7084name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
7085
7086INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
7087
Ying Wang5d887702015-11-04 10:06:25 -08007088$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007089 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07007090 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007091
Ying Wang7d8c5352012-07-26 10:15:21 -07007092endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08007093
The Android Open Source Project88b60792009-03-03 19:28:42 -08007094
7095# -----------------------------------------------------------------
7096# The SDK
7097
Dan Willemsen39b81cd2021-09-16 14:23:07 -07007098ifneq ($(filter sdk,$(MAKECMDGOALS)),)
7099
The Android Open Source Project88b60792009-03-03 19:28:42 -08007100# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07007101sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007102
7103# Build a name that looks like:
7104#
7105# linux-x86 --> android-sdk_12345_linux-x86
7106# darwin-x86 --> android-sdk_12345_mac-x86
7107# windows-x86 --> android-sdk_12345_windows
7108#
Dan Willemsen39b81cd2021-09-16 14:23:07 -07007109ifneq ($(HOST_OS),linux)
7110 $(error Building the monolithic SDK is only supported on Linux)
7111endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08007112sdk_name := android-sdk_$(FILE_NAME_TAG)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07007113INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH)
Joe Onorato03fbe402009-04-13 08:31:16 -07007114sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007115
7116sdk_dep_file := $(sdk_dir)/sdk_deps.mk
7117
7118ATREE_FILES :=
7119-include $(sdk_dep_file)
7120
7121# if we don't have a real list, then use "everything"
7122ifeq ($(strip $(ATREE_FILES)),)
7123ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007124 $(ALL_DOCS) \
7125 $(ALL_SDK_FILES)
7126endif
7127
7128atree_dir := development/build
7129
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01007130
Dan Willemsen53c98f72021-10-16 16:49:06 -07007131sdk_atree_files := $(atree_dir)/sdk.exclude.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08007132
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02007133# development/build/sdk-android-<abi>.atree is used to differentiate
7134# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
7135# files like the kernel image. We use TARGET_CPU_ABI because we don't
7136# have a better way to distinguish between CPU models.
7137ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
7138 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
7139endif
7140
Anton Hansson8dab0a62019-03-28 15:45:40 +00007141ifneq ($(PRODUCT_SDK_ATREE_FILES),)
7142sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08007143else
7144sdk_atree_files += $(atree_dir)/sdk.atree
7145endif
7146
The Android Open Source Project88b60792009-03-03 19:28:42 -08007147deps := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007148 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01007149 $(SDK_METADATA_FILES) \
Anton Hansson55a8f022022-05-12 08:45:29 +00007150 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007151 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08007152 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007153 $(HOST_OUT_EXECUTABLES)/atree \
Jerome Gaillardcf713d42019-10-23 11:43:26 +01007154 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08007155
Anton Hansson874dbe72022-10-26 15:00:55 +00007156# The name of the subdir within the platforms dir of the sdk. One of:
7157# - android-<SDK_INT> (stable base dessert SDKs)
7158# - android-<CODENAME> (stable extension SDKs)
7159# - android-<SDK_INT>-ext<EXT_INT> (codename SDKs)
7160sdk_platform_dir_name := $(strip \
7161 $(if $(filter REL,$(PLATFORM_VERSION_CODENAME)), \
7162 $(if $(filter $(PLATFORM_SDK_EXTENSION_VERSION),$(PLATFORM_BASE_SDK_EXTENSION_VERSION)), \
7163 android-$(PLATFORM_SDK_VERSION), \
7164 android-$(PLATFORM_SDK_VERSION)-ext$(PLATFORM_SDK_EXTENSION_VERSION) \
7165 ), \
7166 android-$(PLATFORM_VERSION_CODENAME) \
7167 ) \
7168)
7169
The Android Open Source Project88b60792009-03-03 19:28:42 -08007170INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
7171$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
7172$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
7173$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
7174$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
Anton Hansson874dbe72022-10-26 15:00:55 +00007175$(INTERNAL_SDK_TARGET): PRIVATE_PLATFORM_NAME := $(sdk_platform_dir_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007176# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
7177#
7178#SDK_GNU_ERROR := true
7179
Ying Wang5d887702015-11-04 10:06:25 -08007180$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007181 @echo "Package SDK: $@"
7182 $(hide) rm -rf $(PRIVATE_DIR) $@
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07007183 $(hide) for f in $(strip $(target_gnu_MODULES)); do \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007184 if [ -f $$f ]; then \
7185 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
7186 including GNU target $$f >&2; \
7187 FAIL=$(SDK_GNU_ERROR); \
7188 fi; \
7189 done; \
7190 if [ $$FAIL ]; then exit 1; fi
7191 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00007192 ATREE_STRIP="$(HOST_STRIP) -x" \
7193 $(HOST_OUT_EXECUTABLES)/atree \
7194 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
7195 -m $(PRIVATE_DEP_FILE) \
7196 -I . \
7197 -I $(PRODUCT_OUT) \
7198 -I $(HOST_OUT) \
7199 -I $(TARGET_COMMON_OUT_ROOT) \
Anton Hansson874dbe72022-10-26 15:00:55 +00007200 -v "PLATFORM_NAME=$(PRIVATE_PLATFORM_NAME)" \
Anton Hansson6d814982018-11-26 18:12:05 +00007201 -v "OUT_DIR=$(OUT_DIR)" \
7202 -v "HOST_OUT=$(HOST_OUT)" \
7203 -v "TARGET_ARCH=$(TARGET_ARCH)" \
7204 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
7205 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Anton Hansson6d814982018-11-26 18:12:05 +00007206 -o $(PRIVATE_DIR) && \
Anton Hansson6d814982018-11-26 18:12:05 +00007207 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
7208 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
7209 chmod -R ug+rwX $(PRIVATE_DIR) && \
7210 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007211 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
7212
Raphaelc4d47312011-02-15 16:09:36 -08007213MAIN_SDK_DIR := $(sdk_dir)
7214MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07007215
7216endif # sdk in MAKECMDGOALS
Raphael3d224a02010-04-16 17:50:09 -07007217
The Android Open Source Project88b60792009-03-03 19:28:42 -08007218# -----------------------------------------------------------------
7219# Findbugs
7220INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
7221INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
7222$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
7223 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09007224 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08007225 > $@
7226$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
7227 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09007228 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07007229 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08007230
7231# -----------------------------------------------------------------
7232# Findbugs
7233
7234# -----------------------------------------------------------------
7235# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07007236ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08007237include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01007238-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07007239-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07007240-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07007241# Also the project-specific tasks
7242-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
7243-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07007244-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07007245# Also add test specifc tasks
7246include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07007247include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07007248endif
Raphaelc4d47312011-02-15 16:09:36 -08007249
Ying Wang67132ba2015-10-28 16:42:39 -07007250include $(BUILD_SYSTEM)/product-graph.mk
7251
Raphaelc4d47312011-02-15 16:09:36 -08007252# -----------------------------------------------------------------
7253# Create SDK repository packages. Must be done after tasks/* since
7254# we need the addon rules defined.
7255ifneq ($(sdk_repo_goal),)
7256include $(TOPDIR)development/build/tools/sdk_repo.mk
7257endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07007258
7259# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07007260# Soong generates the list of all shared libraries that are depended on by fuzz
7261# targets. It saves this list as a source:destination pair to
7262# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
7263# build of the unstripped shared library, and the destination is the
7264# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
7265# where fuzz target shared libraries are to be "reinstalled". The
7266# copy-many-files below generates the rules to copy the unstripped shared
7267# libraries to the device or host "reinstallation" directory. These rules are
7268# depended on by each module in soong_cc_prebuilt.mk, where the module will have
7269# a dependency on each shared library that it needs to be "reinstalled".
7270FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
7271
7272# -----------------------------------------------------------------
hamzeh5dfe7a22021-04-29 12:44:16 -07007273# The rule to build all fuzz targets for C++ and Rust, and package them.
Mitch Phillipsceefc442019-09-26 16:37:59 -07007274# Note: The packages are created in Soong, and in a perfect world,
7275# we'd be able to create the phony rule there. But, if we want to
7276# have dist goals for the fuzz target, we need to have the PHONY
7277# target defined in make. MakeVarsContext.DistForGoal doesn't take
7278# into account that a PHONY rule create by Soong won't be available
7279# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08007280# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07007281# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08007282.PHONY: haiku
7283haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
7284$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00007285$(call dist-for-goals,haiku,$(PRODUCT_OUT)/module-info.json)
hamzeh5dfe7a22021-04-29 12:44:16 -07007286
Muhammad Haseeb Ahmade3a89402022-10-13 21:19:06 +00007287.PHONY: haiku-java-device
7288haiku-java-device: $(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_DEVICE_TARGETS)
7289$(call dist-for-goals,haiku-java-device,$(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES))
7290$(call dist-for-goals,haiku-java-device,$(PRODUCT_OUT)/module-info.json)
7291
7292.PHONY: haiku-java-host
7293haiku-java-host: $(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_HOST_TARGETS)
7294$(call dist-for-goals,haiku-java-host,$(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES))
7295$(call dist-for-goals,haiku-java-host,$(PRODUCT_OUT)/module-info.json)
Muhammad Haseeb Ahmadcced1362022-01-13 03:17:39 +00007296
hamzeh5dfe7a22021-04-29 12:44:16 -07007297.PHONY: haiku-rust
7298haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
7299$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00007300$(call dist-for-goals,haiku-rust,$(PRODUCT_OUT)/module-info.json)
Jerome Gaillardcf713d42019-10-23 11:43:26 +01007301
7302# -----------------------------------------------------------------
7303# Extract platform fonts used in Layoutlib
7304include $(BUILD_SYSTEM)/layoutlib_fonts.mk
Bob Badourebdefc02022-02-12 15:39:22 -08007305
7306
7307# -----------------------------------------------------------------
7308# OS Licensing
7309
7310include $(BUILD_SYSTEM)/os_licensing.mk
7311
7312# When appending new code to this file, please insert above OS Licensing