blob: a96cfd5e59184024b2f4ab9f6f703b44fdcb13c9 [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 Badour70c07dd2022-02-12 15:39:22 -08007SYSTEM_NOTICE_DEPS :=
8VENDOR_NOTICE_DEPS :=
9UNMOUNTED_NOTICE_DEPS :=
10ODM_NOTICE_DEPS :=
11OEM_NOTICE_DEPS :=
12PRODUCT_NOTICE_DEPS :=
13SYSTEM_EXT_NOTICE_DEPS :=
14VENDOR_DLKM_NOTICE_DEPS :=
15ODM_DLKM_NOTICE_DEPS :=
16SYSTEM_DLKM_NOTICE_DEPS :=
17
The Android Open Source Project88b60792009-03-03 19:28:42 -080018# -----------------------------------------------------------------
19# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -070020# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080021# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
22# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080023# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070024# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070025#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070026#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070027define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070028$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
29 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080030 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
31$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
32 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
33 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
34 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
35 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
36 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
37 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
38 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
39 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
40 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
41 use vintf_compatibility_matrix / vintf_fragments instead!)) \
42 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
43 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
44 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
45 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
46 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
47 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
48 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
49 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
50 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
51)
Ying Wang68864102011-09-29 13:23:25 -070052endef
Yo Chiang0b49c032020-03-17 17:49:49 +080053
Yo Chiang336883a2020-05-14 17:17:29 +080054# Phony target to check PRODUCT_COPY_FILES copy pairs don't contain ELF files
55.PHONY: check-elf-prebuilt-product-copy-files
56check-elf-prebuilt-product-copy-files:
57
Yo Chiang0b49c032020-03-17 17:49:49 +080058check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080059ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
60check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080061endif
62check_elf_prebuilt_product_copy_files_hint := \
63 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
64
Ying Wang619fccf2012-09-05 18:08:29 -070065# filter out the duplicate <source file>:<dest file> pairs.
66unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080067$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070068 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
69 $(eval unique_product_copy_files_pairs += $(cf))))
70unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080071product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070072$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070073 $(eval _src := $(call word-colon,1,$(cf))) \
74 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070075 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080076 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080077 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070078 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070079 $(if $(filter %.xml,$(_dest)),\
80 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010081 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
82 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070083 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
84 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080085 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
86 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
87 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
88 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070089 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080090
91# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070092pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
93$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
94$(pcf_ignored_file):
95 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080096
Bob Badour5acd4362022-04-12 18:31:35 -070097$(call declare-0p-target,$(pcf_ignored_file))
98
Bill Peckham315b98a2021-06-15 19:35:06 -070099$(call dist-for-goals,droidcore-unbundled,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
Dan Willemsen7537fd02018-10-16 23:15:08 -0700100
101pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -0800102product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -0700103unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -0700104unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800105
106# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800107# Returns the max allowed size for an image suitable for hash verification
108# (e.g., boot.img, recovery.img, etc).
109# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
110# $(1): partition size to flash the image
111define get-hash-image-max-size
112$(if $(1), \
113 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
114 $(eval _hash_meta_size := 69632), \
115 $(eval _hash_meta_size := 0)) \
116 $(1)-$(_hash_meta_size))
117endef
118
119# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800120# Define rules to copy headers defined in copy_headers.mk
121# If more than one makefile declared a header, print a warning,
122# then copy the last one defined. This matches the previous make
123# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700124has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800125$(foreach dest,$(ALL_COPIED_HEADERS), \
126 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800127 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800128 $(if $(call streq,$(_src),$(_srcs)),, \
129 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800130 $(warning _ Using $(_src)) \
131 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
132 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
133 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
134 $(warning _ Ignoring $(src)) \
135 $(warning __ from $(firstword $(_makefiles))) \
136 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
137 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800138 $(eval $(call copy-one-header,$(_src),$(dest))))
139all_copied_headers: $(ALL_COPIED_HEADERS)
140
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700141ifdef has_dup_copy_headers
142 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700143 $(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 -0700144endif
145
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800146$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
147
Dan Willemsen6f60f022016-02-23 13:40:07 -0800148# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100150ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800151gen := $(OUT_DOCS)/index.html
152ALL_DOCS += $(gen)
153$(gen): frameworks/base/docs/docs-redirect-index.html
154 @mkdir -p $(dir $@)
155 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700156endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800157
Dan Albert303e6032017-10-04 10:20:20 -0700158ndk_doxygen_out := $(OUT_NDK_DOCS)
159ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
160ndk_docs_src_dir := frameworks/native/docs
161ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
162ifneq ($(wildcard $(ndk_docs_src_dir)),)
163ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
164 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
165$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
166 @mkdir -p $(ndk_doxygen_out)
167 @echo "Generating NDK docs to $(ndk_doxygen_out)"
168 @( cat $(ndk_doxyfile); \
169 echo "INPUT=$(ndk_headers)"; \
170 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
171 ) | doxygen -
172
Bob Badour5acd4362022-04-12 18:31:35 -0700173$(call declare-1p-target,$(ndk_doxygen_out)/index.html,)
174
Dan Albert303e6032017-10-04 10:20:20 -0700175# Note: Not a part of the docs target because we don't have doxygen available.
176# You can run this target locally if you have doxygen installed.
177ndk-docs: $(ndk_doxygen_out)/index.html
178.PHONY: ndk-docs
179endif
180
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700181ifeq ($(HOST_OS),linux)
Colin Crossd60401a2019-04-18 14:46:48 -0700182$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700183endif
Dan Willemsenad6a1542018-12-14 01:04:19 -0800184
Andres Moralesb8876e12015-05-06 20:44:22 -0700185INSTALLED_RECOVERYIMAGE_TARGET :=
Yifan Hong881df392020-10-09 14:29:39 -0700186# Build recovery image if
187# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
188# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
189# with recovery resources.
190# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
191# but not the final recovery image.
Chris Grossa784ef12019-04-22 11:09:57 -0700192ifdef BUILDING_RECOVERY_IMAGE
193ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong881df392020-10-09 14:29:39 -0700194ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -0700195INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
196endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700197endif
Yifan Hong881df392020-10-09 14:29:39 -0700198endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700199
Jiyong Parke1346862020-05-18 14:31:30 +0900200include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100201
202# ----------------------------------------------------------------
203
204# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800205# sdk-build.prop
206#
207# There are certain things in build.prop that we don't want to
208# ship with the sdk; remove them.
209
210# This must be a list of entire property keys followed by
211# "=" characters, without any internal spaces.
212sdk_build_prop_remove := \
213 ro.build.user= \
214 ro.build.host= \
215 ro.product.brand= \
216 ro.product.manufacturer= \
217 ro.product.device=
218# TODO: Remove this soon-to-be obsolete property
219sdk_build_prop_remove += ro.build.product=
220INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
221$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
222 @echo SDK buildinfo: $@
223 @mkdir -p $(dir $@)
224 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000225 $(sdk_build_prop_remove)))" $< > $@.tmp
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700226 $(hide) for x in $(strip $(sdk_build_prop_remove)); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000227 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800228 $(hide) mv $@.tmp $@
229
Bob Badour5acd4362022-04-12 18:31:35 -0700230$(call declare-0p-target,$(INSTALLED_SDK_BUILD_PROP_TARGET))
231
The Android Open Source Project88b60792009-03-03 19:28:42 -0800232# -----------------------------------------------------------------
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800233# declare recovery ramdisk files
234ifeq ($(BUILDING_RECOVERY_IMAGE),true)
235INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
236endif
237
238# -----------------------------------------------------------------
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800239# Declare vendor ramdisk fragments
240INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
241
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800242ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
243 ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
244 $(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \
245 BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set)
246 endif
247 INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery
248 VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT)
249 VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
250 BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY
251 .KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR
252endif
253
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800254# Validation check and assign default --ramdisk_type.
255$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
256 $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
257 $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
258 $(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))) \
259 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
260 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
261 $(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
262 $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
263 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
264)
265
266# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
267$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
268 $(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
269 $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
270 $(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)) \
271 $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
272 ) \
273)
274INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
275
Yi-Yo Chiang378b7792021-04-09 20:09:13 +0800276# Strip the list in case of any whitespace.
277INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \
278 $(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS))
279
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800280# Assign --ramdisk_name for each vendor ramdisk fragment.
281$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
282 $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
283 $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
284 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
285 $(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
286)
287
288# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700289# kernel modules
290
291# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
292DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
293
J. Avilaa2ceec62020-05-12 23:40:02 +0000294define copy-and-strip-kernel-module
295$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000296 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000297endef
298
Colin Cross4f60e362019-06-05 11:53:43 -0700299# $(1): modules list
300# $(2): output dir
301# $(3): mount point
302# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700303# $(5): module load list
304# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800305# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000306# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700307# $(9): module directory name
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800308# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700309define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700310 $(if $(9), \
311 $(eval _dir := $(9)/), \
312 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000313 $(foreach module,$(1), \
314 $(eval _src := $(module)) \
315 $(if $(8), \
316 $(eval _src := $(8)/$(notdir $(module))) \
317 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700318 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700319 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700320 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
321 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
322 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
323 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700324endef
325
326# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700327# $(2): mount point
328# $(3): staging dir
329# $(4): module load list
330# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800331# $(6): module archive
332# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700333# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800334# TODO(b/144844424): If a module archive is being used, this step (which
335# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
336# the output directory. This should be moved to a module with a
337# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
338# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700339define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700340$(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 -0700341$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700342$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
Steve Muckle474e4d02019-06-19 12:56:48 -0700343$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700344$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700345$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700346$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
Steve Muckle474e4d02019-06-19 12:56:48 -0700347$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800348$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
349$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
350$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700351 @echo depmod $$(PRIVATE_STAGING_DIR)
352 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700353 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800354 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700355 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800356 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700357 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800358 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
359 )
360 $(if $(1),\
361 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
362 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
363 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
364 done; \
365 )
Colin Cross4f60e362019-06-05 11:53:43 -0700366 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
367 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700368 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
369 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700370endef
371
Steve Muckle474e4d02019-06-19 12:56:48 -0700372# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700373# $(2): modules list
374# $(3): module load list
375# $(4): module load list filename
376# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700377define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700378 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
379 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700380endef
381
382# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700383# $(2): modules list
384# $(3): module load list
385# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700386define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700387$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
388$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
389 @echo load-list $$(@)
390 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700391endef
392
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800393# $(1): source options file
394# $(2): destination pathname
395# Returns a build rule that checks the syntax of and installs a kernel modules
396# options file. Strip and squeeze any extra space and blank lines.
397# For use via $(eval).
398define build-image-kernel-modules-options-file
399$(2): $(1)
400 @echo "libmodprobe options $$(@)"
401 $(hide) mkdir -p "$$(dir $$@)"
402 $(hide) rm -f "$$@"
403 $(hide) awk <"$$<" >"$$@" \
404 '/^#/ { print; next } \
405 NF == 0 { next } \
406 NF < 2 || $$$$1 != "options" \
407 { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
408 exit_status = 1; next } \
409 { $$$$1 = $$$$1; print } \
410 END { exit exit_status }'
411endef
412
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800413# $(1): source blocklist file
414# $(2): destination pathname
415# Returns a build rule that checks the syntax of and installs a kernel modules
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800416# blocklist file. Strip and squeeze any extra space and blank lines.
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800417# For use via $(eval).
418define build-image-kernel-modules-blocklist-file
419$(2): $(1)
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800420 @echo "libmodprobe blocklist $$(@)"
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800421 $(hide) mkdir -p "$$(dir $$@)"
422 $(hide) rm -f "$$@"
423 $(hide) awk <"$$<" >"$$@" \
424 '/^#/ { print; next } \
425 NF == 0 { next } \
426 NF != 2 || $$$$1 != "blocklist" \
427 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
428 exit_status = 1; next } \
429 { $$$$1 = $$$$1; print } \
430 END { exit exit_status }'
431endef
432
Steve Muckle2335d762020-05-28 18:39:38 -0700433# $(1): image name
434# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
435# $(3): mount point
436# $(4): module load filename
437# $(5): stripped staging directory
438# $(6): kernel module directory name (top is an out of band value for no directory)
439define build-image-kernel-modules-dir
440$(if $(filter top,$(6)),\
441 $(eval _kver :=)$(eval _sep :=),\
442 $(eval _kver := $(6))$(eval _sep :=_))\
443$(if $(5),\
444 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
445 $(eval _stripped_staging_dir :=))\
446$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
447 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
448 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800449 $(call copy-many-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)))) \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800450$(if $(_kver), \
451 $(eval _dir := $(_kver)/), \
452 $(eval _dir :=)) \
453$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
454 $(eval $(call build-image-kernel-modules-options-file, \
455 $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
456 $(2)/lib/modules/$(_dir)modules.options)) \
457 $(2)/lib/modules/$(_dir)modules.options) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800458$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
459 $(eval $(call build-image-kernel-modules-blocklist-file, \
460 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800461 $(2)/lib/modules/$(_dir)modules.blocklist)) \
462 $(2)/lib/modules/$(_dir)modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700463endef
464
465# $(1): kernel module directory name (top is an out of band value for no directory)
466define build-recovery-as-boot-load
467$(if $(filter top,$(1)),\
468 $(eval _kver :=)$(eval _sep :=),\
469 $(eval _kver := $(1))$(eval _sep :=_))\
470 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
471 $(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))))
472endef
473
474# $(1): kernel module directory name (top is an out of band value for no directory)
475define build-vendor-ramdisk-recovery-load
476$(if $(filter top,$(1)),\
477 $(eval _kver :=)$(eval _sep :=),\
478 $(eval _kver := $(1))$(eval _sep :=_))\
479 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
480 $(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))))
481endef
482
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700483# $(1): kernel module directory name (top is an out of band value for no directory)
484define build-vendor-charger-load
485$(if $(filter top,$(1)),\
486 $(eval _kver :=)$(eval _sep :=),\
487 $(eval _kver := $(1))$(eval _sep :=_))\
488 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
489 $(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))))
490endef
491
Steve Mucklee1b10862019-07-10 10:49:37 -0700492ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
493 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
494 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700495 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700496 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
497endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700498
Steve Muckle69280d22019-07-11 12:23:38 -0700499ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
500 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700501endif
502
Steve Mucklee1b10862019-07-10 10:49:37 -0700503ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700504 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700505 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700506 endif
507endif
508
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800509ifneq ($(BOARD_DO_NOT_STRIP_RECOVERY_MODULES),true)
510 RECOVERY_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery_stripped)
511else
512 RECOVERY_STRIPPED_MODULE_STAGING_DIR :=
513endif
514
J. Avilaa2ceec62020-05-12 23:40:02 +0000515ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
516 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
517else
518 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
519endif
Colin Cross4f60e362019-06-05 11:53:43 -0700520
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700521ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
522 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
523else
524 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
525endif
526
Lucas Weif57333f2022-02-24 10:30:15 +0800527ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_KERNEL_RAMDISK_MODULES),true)
528 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_kernel_ramdisk_stripped)
529else
530 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
531endif
532
Steve Muckle2335d762020-05-28 18:39:38 -0700533BOARD_KERNEL_MODULE_DIRS += top
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800534$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800535 $(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 +0800536 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800537 $(if $(vendor_ramdisk_fragment), \
538 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
539 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
540 $(eval ### else ###), \
541 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
542 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800543 $(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 +0800544 $(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 +0800545 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
546 $(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))) \
547 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
548 $(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))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700549 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800550 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
551 $(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 -0700552
553# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800554# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700555# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900556# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700557# $2 certificate
558# $3 private key
559# $4 compressed
560# $5 partition tag
561# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100562define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700563$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
564$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
565$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
566$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700567
568endef
569
Jaewoong Jung704b4542020-06-29 19:37:53 -0700570# -----------------------------------------------------------------
571# Merge an individual apkcerts output into the final apkcerts.txt output.
572# Use a macro to make it compatible with _apkcerts_write_line
573# $1 apkcerts file to be merged
574# $2 output file
575define _apkcerts_merge
576$(hide) cat $1 >> $2
577
578endef
579
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580name := $(TARGET_PRODUCT)
581ifeq ($(TARGET_BUILD_TYPE),debug)
582 name := $(name)_debug
583endif
584name := $(name)-apkcerts-$(FILE_NAME_TAG)
585intermediates := \
586 $(call intermediates-dir-for,PACKAGING,apkcerts)
587APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700588all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
589$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800590# We don't need to really build all the modules.
591# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700592$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800593 @echo APK certs list: $@
594 @mkdir -p $(dir $@)
595 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700596 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700597 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
598 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
599 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700600 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700601 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Inseob Kimf69346e2021-10-13 15:16:33 +0900602 $(if $(filter true,$(PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA)),\
603 $(call _apkcerts_write_line,$(notdir $(basename $(FSVERITY_APK_OUT))),$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system,$@))
Ying Wangd9a88d52012-10-26 09:21:28 -0700604 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700605 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800606
Bob Badour5acd4362022-04-12 18:31:35 -0700607$(call declare-0p-target,$(APKCERTS_FILE))
608
The Android Open Source Project88b60792009-03-03 19:28:42 -0800609.PHONY: apkcerts-list
610apkcerts-list: $(APKCERTS_FILE)
611
Ying Wang15e487a2011-02-15 10:56:18 -0800612ifneq (,$(TARGET_BUILD_APPS))
613 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900614 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800615endif
Ying Wangefb21682010-07-23 16:42:13 -0700616
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900617
The Android Open Source Project88b60792009-03-03 19:28:42 -0800618# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700619# build system stats
620BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
621$(BUILD_SYSTEM_STATS):
622 @rm -f $@
623 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
624 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700625$(call declare-1p-target,$(BUILD_SYSTEM_STATS),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700626$(call dist-for-goals,droidcore-unbundled,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700627
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700628# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800629# build /product/etc/security/avb/system_other.avbpubkey if needed
630ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800631ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800632INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
633ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800634endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800635endif # BUILDING_SYSTEM_OTHER_IMAGE
636
637# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700638# Modules ready to be converted to Soong, ordered by how many
639# modules depend on them.
640SOONG_CONV := $(sort $(SOONG_CONV))
641SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
642$(SOONG_CONV_DATA):
643 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700644 @$(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 -0700645
Bob Badour5acd4362022-04-12 18:31:35 -0700646$(call declare-1p-target,$(SOONG_CONV_DATA),build)
647
Colin Crossfdea8932017-12-06 14:38:40 -0800648SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700649SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
650$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
651 @rm -f $@
652 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
Bob Badour5acd4362022-04-12 18:31:35 -0700653$(call declare-1p-target,$(SOONG_TO_CONVERT),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700654$(call dist-for-goals,droidcore-unbundled,$(SOONG_TO_CONVERT))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700655
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700656$(PRODUCT_OUT)/product_packages.txt:
657 @rm -f $@
658 echo "" > $@
659 $(foreach x,$(PRODUCT_PACKAGES),echo $(x) >> $@$(newline))
660
Joe Onorato02fb89a2020-06-27 00:10:23 -0700661MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700662PRODUCT_PACKAGES_TXT := $(PRODUCT_OUT)/product_packages.txt
Joe Onorato02fb89a2020-06-27 00:10:23 -0700663MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
664$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700665$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato02fb89a2020-06-27 00:10:23 -0700666 @rm -f $@
667 $(hide) $(MK2BP_CATALOG_SCRIPT) \
668 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700669 --product-packages=$(PRODUCT_PACKAGES_TXT) \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700670 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
671 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700672 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700673 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700674 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700675$(call declare-1p-target,$(MK2BP_REMAINING_HTML),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700676$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_HTML))
Joe Onorato02fb89a2020-06-27 00:10:23 -0700677
Joe Onorato31986072020-08-10 09:58:49 -0700678MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700679$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato31986072020-08-10 09:58:49 -0700680 @rm -f $@
681 $(hide) $(MK2BP_CATALOG_SCRIPT) \
682 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700683 --product-packages=$(PRODUCT_PACKAGES_TXT) \
684 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700685 --mode=csv \
686 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700687$(call declare-1p-target,$(MK2BP_REMAINING_CSV))
Bill Peckham315b98a2021-06-15 19:35:06 -0700688$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_CSV))
Joe Onorato31986072020-08-10 09:58:49 -0700689
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700690# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800691# Modules use -Wno-error, or added default -Wall -Werror
692WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
693$(WALL_WERROR):
694 @rm -f $@
695 echo "# Modules using -Wno-error" >> $@
696 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Yi Kongee99ddf2022-05-19 20:13:55 +0800697 echo "# Modules that allow warnings" >> $@
698 for m in $(sort $(SOONG_MODULES_WARNINGS_ALLOWED) $(MODULES_WARNINGS_ALLOWED)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800699
Bob Badour5acd4362022-04-12 18:31:35 -0700700$(call declare-0p-target,$(WALL_WERROR))
701
Bill Peckham315b98a2021-06-15 19:35:06 -0700702$(call dist-for-goals,droidcore-unbundled,$(WALL_WERROR))
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800703
704# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700705# C/C++ flag information for modules
Bill Peckham315b98a2021-06-15 19:35:06 -0700706$(call dist-for-goals,droidcore-unbundled,$(SOONG_MODULES_CFLAG_ARTIFACTS))
Jesse Paid0046922019-09-13 17:02:32 -0700707
Bob Badour5acd4362022-04-12 18:31:35 -0700708$(foreach a,$(SOONG_MODULES_CFLAG_ARTIFACTS),$(call declare-0p-target,$(call word-colon,1,$(a))))
709
Jesse Paid0046922019-09-13 17:02:32 -0700710# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800711# Modules missing profile files
712PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
713$(PGO_PROFILE_MISSING):
714 @rm -f $@
715 echo "# Modules missing PGO profile files" >> $@
716 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
717
Bob Badour5acd4362022-04-12 18:31:35 -0700718$(call declare-0p-target,$(PGO_PROFILE_MISSING))
719
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800720$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
721
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000722CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
723$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
724 rm -f $@
725 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700726$(call declare-0p-target,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000727$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
728
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800729# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700730# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700731# for future OTA packages installed by this system. Actual product
732# deliverables will be re-signed by hand. We expect this file to
733# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700734DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700735
736
Jeff Browne33ba4c2011-07-11 22:11:46 -0700737# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800738# if they don't do anything.
739.PHONY: systemimage
740systemimage:
741
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800742# -----------------------------------------------------------------
743
744.PHONY: event-log-tags
745
Joe Onoratob7510532010-07-14 10:22:54 -0700746# Produce an event logs tag file for everything we know about, in order
747# to properly allocate numbers. Then produce a file that's filtered
748# for what's going to be installed.
749
750all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
751
Colin Crossdc8f8e42012-04-12 13:25:54 -0700752event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
753
Joe Onoratob7510532010-07-14 10:22:54 -0700754# Include tags from all packages that we know about
755all_event_log_tags_src := \
756 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
757
Dan Willemsena3f66322020-05-28 15:46:33 -0700758$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
759$(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 -0700760 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900761 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700762
Bob Badour5acd4362022-04-12 18:31:35 -0700763$(call declare-0p-target,$(all_event_log_tags_file))
764
Doug Zongkera34fa952011-02-23 12:17:29 -0800765# Include tags from all packages included in this product, plus all
766# tags that are part of the system (ie, not in a vendor/ or device/
767# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800768event_log_tags_src := \
769 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800770 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800771 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800772 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
773 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800774
Dan Willemsena3f66322020-05-28 15:46:33 -0700775$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700776$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700777$(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 -0800778 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900779 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800780
Bob Badour2f66fd12022-03-09 17:30:24 -0800781$(eval $(call declare-0p-target,$(event_log_tags_file)))
782
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800783event-log-tags: $(event_log_tags_file)
784
785ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
786
Colin Cross79a76ec2022-03-21 15:06:11 -0700787# Initialize INSTALLED_FILES_OUTSIDE_IMAGES with the list of all device files,
788# files installed in images will be filtered out later.
789INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out \
790 $(PRODUCT_OUT)/apex/% \
Colin Cross41e93ea2022-03-25 17:31:49 -0700791 $(PRODUCT_OUT)/fake_packages/% \
Colin Cross79a76ec2022-03-21 15:06:11 -0700792 $(PRODUCT_OUT)/testcases/%, \
793 $(filter $(PRODUCT_OUT)/%,$(ALL_DEFAULT_INSTALLED_MODULES)))
Joe Onoratob7510532010-07-14 10:22:54 -0700794
The Android Open Source Project88b60792009-03-03 19:28:42 -0800795# #################################################################
796# Targets for boot/OS images
797# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800798ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
799 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000800 ifdef BOARD_PREBUILT_BOOTLOADER
801 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
802 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
803 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800804 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
805 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
806 else
807 INSTALLED_2NDBOOTLOADER_TARGET :=
808 endif
809else
810 INSTALLED_BOOTLOADER_MODULE :=
811 INSTALLED_2NDBOOTLOADER_TARGET :=
812endif # TARGET_NO_BOOTLOADER
813ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700814 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
815 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
816 $(PRODUCT_OUT)/$(k))
817 else
818 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
819 endif
Ying Wangc6349742014-01-13 16:14:20 -0800820else
821 INSTALLED_KERNEL_TARGET :=
822endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800823
824# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700825# the root dir
Colin Cross79a76ec2022-03-21 15:06:11 -0700826INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_ROOT_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Tom Cherryd14b8952018-08-09 14:26:00 -0700827INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800828 $(ALL_DEFAULT_INSTALLED_MODULES))
829
Colin Cross79a76ec2022-03-21 15:06:11 -0700830
Luis Hector Chavezff489932018-07-03 15:41:40 -0700831INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
832INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
833$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700834$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700835 @echo Installed file list: $@
SzuWei Linc230b0b2021-12-30 13:48:01 +0800836 mkdir -p $(TARGET_ROOT_OUT)
Petri Gynther728e0bd2021-03-06 13:29:28 -0800837 mkdir -p $(dir $@)
838 rm -f $@
839 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
840 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700841
Bob Badoure9bdbc52022-03-10 11:31:07 -0800842$(call declare-0p-target,$(INSTALLED_FILES_FILE_ROOT))
Bob Badour5acd4362022-04-12 18:31:35 -0700843$(call declare-0p-target,$(INSTALLED_FILES_JSON_ROOT))
Bob Badoure9bdbc52022-03-10 11:31:07 -0800844
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800845#------------------------------------------------------------------
846# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700847ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800848INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700849ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800850$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800851 cat $^ > $@
852endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700853endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800854
Tom Cherryd14b8952018-08-09 14:26:00 -0700855# -----------------------------------------------------------------
856# the ramdisk
Colin Cross79a76ec2022-03-21 15:06:11 -0700857INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -0800858ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700859INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
Tom Cherryd14b8952018-08-09 14:26:00 -0700860 $(ALL_DEFAULT_INSTALLED_MODULES))
861
862INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
863INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
864$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700865$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700866 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800867 mkdir -p $(TARGET_RAMDISK_OUT)
868 mkdir -p $(dir $@)
869 rm -f $@
870 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
871 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700872
Bob Badour70c07dd2022-02-12 15:39:22 -0800873$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -0700874$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RAMDISK)))
Bob Badour70c07dd2022-02-12 15:39:22 -0800875
Joe Onorato64d85d02009-04-09 19:31:12 -0700876BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
877
J. Avila3f6560e2020-05-11 20:20:03 +0000878ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
879# -l enables the legacy format used by the Linux kernel
880COMPRESSION_COMMAND_DEPS := $(LZ4)
881COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
882RAMDISK_EXT := .lz4
883else
884COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
885COMPRESSION_COMMAND := $(MINIGZIP)
886RAMDISK_EXT := .gz
887endif
888
Joe Onorato64d85d02009-04-09 19:31:12 -0700889# We just build this directly to the install location.
890INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900891$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
J. Avila3f6560e2020-05-11 20:20:03 +0000892$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800893 $(call pretty,"Target ramdisk: $@")
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900894 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
895ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
896 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
897endif
J. Avila3f6560e2020-05-11 20:20:03 +0000898 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800899
Bob Badour70c07dd2022-02-12 15:39:22 -0800900$(call declare-1p-container,$(INSTALLED_RAMDISK_TARGET),)
901$(call declare-container-license-deps,$(INSTALLED_RAMDISK_TARGET),$(INTERNAL_RAMDISK_FILE),$(PRODUCT_OUT)/:/)
902
903UNMOUNTED_NOTICE_DEPS += $(INSTALLED_RAMDISK_TARGET)
904
Ying Wangad7fd292013-08-08 16:34:29 -0700905.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000906ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700907 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000908 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800909
Dan Willemsen67495202019-01-16 12:42:05 -0800910endif # BUILDING_RAMDISK_IMAGE
911
The Android Open Source Project88b60792009-03-03 19:28:42 -0800912# -----------------------------------------------------------------
913# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700914
915# This is defined here since we may be building recovery as boot
916# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700917ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
918 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
919else
920 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
921endif
922
Yifan Hong0674a6e2020-10-22 14:37:01 -0700923INTERNAL_PREBUILT_BOOTIMAGE :=
924
925my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
926ifdef my_installed_prebuilt_gki_apex
927 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
928 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
929 endif # len(my_installed_prebuilt_gki_apex) > 1
930
931 ifdef BOARD_PREBUILT_BOOTIMAGE
932 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
933 endif # BOARD_PREBUILT_BOOTIMAGE defined
934
935 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
936 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
937 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
938
939 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
940
941else # my_installed_prebuilt_gki_apex not defined
942
Steve Muckle04b6f052020-08-09 14:36:56 -0700943# $1: boot image target
944# returns the kernel used to make the bootimage
945define bootimage-to-kernel
946 $(if $(BOARD_KERNEL_BINARIES),\
947 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
948 $(INSTALLED_KERNEL_TARGET))
949endef
950
Steve Muckle903a1ca2020-05-07 17:32:10 -0700951ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
952 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
953endif
954
955# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800956# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700957define get-bootimage-partition-size
Peter Collingbourne730200e2022-02-16 13:32:53 -0800958$(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
959endef
960
961# $1: partition size
962define get-partition-size-argument
963 $(if $(1),--partition_size $(1),--dynamic_partition_size)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700964endef
Chris Grossa784ef12019-04-22 11:09:57 -0700965
966ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800967INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700968 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700969
Devin Moore380d9e42021-11-04 19:01:19 +0000970INTERNAL_INIT_BOOT_IMAGE_ARGS :=
971
Bowgo Tsai85578e02022-04-19 10:50:59 +0800972# TODO(b/229701033): clean up BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK.
973ifneq ($(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK),true)
974 ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
975 ifneq ($(BUILDING_INIT_BOOT_IMAGE),true)
976 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
977 else
978 INTERNAL_INIT_BOOT_IMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
979 endif
Devin Moore380d9e42021-11-04 19:01:19 +0000980 endif
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700981endif
982
Steve Mucklee1b10862019-07-10 10:49:37 -0700983ifndef BUILDING_VENDOR_BOOT_IMAGE
984ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
985 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
986endif
987endif
988
The Android Open Source Project88b60792009-03-03 19:28:42 -0800989INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
990
Anton Hansson8dab0a62019-03-28 15:45:40 +0000991ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700992ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000993VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700994 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
995endif
996endif
997
Anton Hansson72e36f02019-02-26 17:36:30 +0000998INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700999
Yifan Hong46aff092020-10-28 13:50:47 -07001000# kernel cmdline/base/pagesize in boot.
1001# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
1002# device-specific.
1003# - If not using GKI:
1004# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
1005# - Otherwise, put them in boot.
1006ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07001007 ifdef GENERIC_KERNEL_CMDLINE
1008 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1009 endif
Yifan Hong46aff092020-10-28 13:50:47 -07001010else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
1011 ifdef INTERNAL_KERNEL_CMDLINE
1012 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1013 endif
1014 ifdef BOARD_KERNEL_BASE
1015 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1016 endif
1017 ifdef BOARD_KERNEL_PAGESIZE
1018 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1019 endif
1020endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001021
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001022ifdef BOARD_GKI_SIGNING_KEY_PATH
1023 # GKI boot images will not set system version & SPL value in the header.
1024 # They can be set by the device manufacturer in the AVB properties instead.
1025 INTERNAL_MKBOOTIMG_VERSION_ARGS :=
1026else
1027 INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -07001028 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001029 --os_patch_level $(PLATFORM_SECURITY_PATCH)
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001030endif # BOARD_GKI_SIGNING_KEY_PATH
Sami Tolvanen3303d902016-03-15 16:49:30 +00001031
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001032# $(1): image target to certify
1033# $(2): out certificate target
1034# $(3): image name
1035# $(4): additional AVB arguments
1036define generate_generic_boot_image_certificate
1037 rm -rf "$(2)"
1038 mkdir -p "$(dir $(2))"
1039 $(GENERATE_GKI_CERTIFICATE) $(INTERNAL_GKI_CERTIFICATE_ARGS) \
1040 --additional_avb_args "$(4)" \
1041 --name "$(3)" --output "$(2)" "$(1)"
1042endef
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001043
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001044INTERNAL_GKI_CERTIFICATE_ARGS :=
1045INTERNAL_GKI_CERTIFICATE_DEPS :=
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001046ifdef BOARD_GKI_SIGNING_KEY_PATH
1047 ifndef BOARD_GKI_SIGNING_ALGORITHM
1048 $(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
1049 endif
1050
1051 INTERNAL_GKI_CERTIFICATE_ARGS := \
1052 --key "$(BOARD_GKI_SIGNING_KEY_PATH)" \
1053 --algorithm "$(BOARD_GKI_SIGNING_ALGORITHM)" \
1054 --avbtool "$(AVBTOOL)"
1055
1056 # Quote and pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string argument.
1057 ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
1058 INTERNAL_GKI_CERTIFICATE_ARGS += --additional_avb_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
1059 endif
1060
1061 INTERNAL_GKI_CERTIFICATE_DEPS := \
1062 $(GENERATE_GKI_CERTIFICATE) \
1063 $(BOARD_GKI_SIGNING_KEY_PATH) \
1064 $(AVBTOOL)
1065
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001066endif
1067
Chris Grossa784ef12019-04-22 11:09:57 -07001068# Define these only if we are building boot
1069ifdef BUILDING_BOOT_IMAGE
1070INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1071
The Android Open Source Project88b60792009-03-03 19:28:42 -08001072ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001073$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001074endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -04001075
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001076$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
1077
1078ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -04001079
Steve Muckle04b6f052020-08-09 14:36:56 -07001080# $1: boot image target
1081define build_boot_board_avb_enabled
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001082 $(eval kernel := $(call bootimage-to-kernel,$(1)))
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001083 $(MKBOOTIMG) --kernel $(kernel) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001084 $(if $(BOARD_GKI_SIGNING_KEY_PATH), \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001085 $(eval boot_signature := $(call intermediates-dir-for,PACKAGING,generic_boot)/$(notdir $(1)).boot_signature) \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001086 $(eval kernel_signature := $(call intermediates-dir-for,PACKAGING,generic_kernel)/$(notdir $(kernel)).boot_signature) \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001087 $(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 +08001088 $(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 +08001089 cat $(kernel_signature) >> $(boot_signature) $(newline) \
1090 $(call assert-max-image-size,$(boot_signature),16 << 10) $(newline) \
1091 truncate -s $$(( 16 << 10 )) $(boot_signature) $(newline) \
1092 cat "$(boot_signature)" >> $(1))
Yifan Hongebe65f82020-10-15 14:48:07 -07001093 $(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 -07001094 $(AVBTOOL) add_hash_footer \
1095 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001096 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) \
Steve Muckle04b6f052020-08-09 14:36:56 -07001097 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1098 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1099endef
1100
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001101$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001102 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001103 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -04001104
Bob Badour70c07dd2022-02-12 15:39:22 -08001105$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1106$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES) $(INTERNAL_GKI_CERTIFICATE_DEPS),$(PRODUCT_OUT)/:/)
1107
1108UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1109
David Zeuthen0eb10972016-09-28 17:55:27 -04001110.PHONY: bootimage-nodeps
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001111bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001112 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001113 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001114
Anton Hansson8dab0a62019-03-28 15:45:40 +00001115else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -07001116
Steve Muckle04b6f052020-08-09 14:36:56 -07001117# $1: boot image target
1118define build_boot_supports_boot_signer
1119 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
1120 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -07001121 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001122endef
1123
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001124$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -07001125 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001126 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -07001127
Bob Badour70c07dd2022-02-12 15:39:22 -08001128$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1129$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1130
1131UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1132
Geremy Condra740b6632014-07-08 20:07:41 -07001133.PHONY: bootimage-nodeps
1134bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
1135 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001136 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -07001137
Anton Hansson8dab0a62019-03-28 15:45:40 +00001138else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -08001139
Steve Muckle04b6f052020-08-09 14:36:56 -07001140# $1: boot image target
1141define build_boot_supports_vboot
1142 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
1143 $(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 -07001144 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001145endef
1146
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001147$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001148 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001149 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -08001150
Bob Badour70c07dd2022-02-12 15:39:22 -08001151$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1152$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1153
1154UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1155
David Riley17be3d32015-03-03 08:54:11 -08001156.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001157bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001158 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001159 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -08001160
1161else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001162
Steve Muckle04b6f052020-08-09 14:36:56 -07001163# $1: boot image target
1164define build_boot_novboot
1165 $(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 -07001166 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001167endef
1168
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001169$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001170 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001171 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -07001172
Bob Badour70c07dd2022-02-12 15:39:22 -08001173$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1174$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1175
1176UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1177
Ying Wangad7fd292013-08-08 16:34:29 -07001178.PHONY: bootimage-nodeps
1179bootimage-nodeps: $(MKBOOTIMG)
1180 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001181 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -07001182
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001183endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -07001184endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001185
Tao Baob1a2e352018-08-14 16:17:12 -07001186else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001187ifdef BOARD_PREBUILT_BOOTIMAGE
Yifan Hong0674a6e2020-10-22 14:37:01 -07001188INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +09001189INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001190
1191ifeq ($(BOARD_AVB_ENABLE),true)
1192$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
1193 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1194 $(AVBTOOL) add_hash_footer \
1195 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001196 $(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001197 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1198 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08001199
1200$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1201$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_BOOTIMAGE),$(PRODUCT_OUT)/:/)
1202
1203UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001204else
1205$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
1206 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1207endif # BOARD_AVB_ENABLE
1208
Tao Baob1a2e352018-08-14 16:17:12 -07001209else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -07001210INSTALLED_BOOTIMAGE_TARGET :=
1211endif # BOARD_PREBUILT_BOOTIMAGE
1212endif # TARGET_NO_KERNEL
Yifan Hong0674a6e2020-10-22 14:37:01 -07001213endif # my_installed_prebuilt_gki_apex not defined
1214
1215my_apex_extracted_boot_image :=
1216my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001217
1218# -----------------------------------------------------------------
Devin Moore380d9e42021-11-04 19:01:19 +00001219# init boot image
1220ifeq ($(BUILDING_INIT_BOOT_IMAGE),true)
1221
1222INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1223$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_RAMDISK_TARGET)
1224
1225ifdef BOARD_KERNEL_PAGESIZE
1226 INTERNAL_INIT_BOOT_IMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1227endif
1228
1229ifeq ($(BOARD_AVB_ENABLE),true)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08001230$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
Devin Moore380d9e42021-11-04 19:01:19 +00001231 $(call pretty,"Target init_boot image: $@")
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001232 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output "$@"
Devin Moore380d9e42021-11-04 19:01:19 +00001233 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
1234 $(AVBTOOL) add_hash_footer \
1235 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001236 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001237 --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1238 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08001239
1240$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1241$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_GENERIC_RAMDISK_BOOT_SIGNATURE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001242else
1243$(INSTALLED_INIT_BOOT_IMAGE_TARGET):
1244 $(call pretty,"Target init_boot image: $@")
1245 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output $@
1246 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
Bob Badour70c07dd2022-02-12 15:39:22 -08001247
1248$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001249endif
1250
Bob Badour70c07dd2022-02-12 15:39:22 -08001251UNMOUNTED_NOTICE_DEPS += $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
1252
Devin Moore380d9e42021-11-04 19:01:19 +00001253else # BUILDING_INIT_BOOT_IMAGE is not true
1254
1255ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
1256INTERNAL_PREBUILT_INIT_BOOT_IMAGE := $(BOARD_PREBUILT_INIT_BOOT_IMAGE)
1257INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1258
1259ifeq ($(BOARD_AVB_ENABLE),true)
1260$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
1261 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
1262 $(AVBTOOL) add_hash_footer \
1263 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001264 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001265 --partition_name boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1266 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08001267
1268$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1269$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_PREBUILT_INIT_BOOT_IMAGE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001270else
1271$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE)
1272 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
Bob Badour70c07dd2022-02-12 15:39:22 -08001273
1274$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001275endif # BOARD_AVB_ENABLE
1276
Bob Badour70c07dd2022-02-12 15:39:22 -08001277UNMOUNTED_NOTICE_DEPS += $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
1278
Devin Moore380d9e42021-11-04 19:01:19 +00001279else # BOARD_PREBUILT_INIT_BOOT_IMAGE not defined
1280INSTALLED_INIT_BOOT_IMAGE_TARGET :=
1281endif # BOARD_PREBUILT_INIT_BOOT_IMAGE
1282
1283endif # BUILDING_INIT_BOOT_IMAGE is not true
Ramji Jiyani10655232022-01-20 06:43:09 +00001284
1285# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001286# vendor boot image
Colin Cross79a76ec2022-03-21 15:06:11 -07001287INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Steve Mucklee1b10862019-07-10 10:49:37 -07001288ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1289
1290ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
1291 $(error vboot 1.0 does not support vendor_boot partition)
1292endif
1293
1294INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
Steve Mucklee1b10862019-07-10 10:49:37 -07001295 $(ALL_DEFAULT_INSTALLED_MODULES))
1296
Petri Gynther6a6d6212021-03-06 00:45:53 -08001297INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001298
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001299# Exclude recovery files in the default vendor ramdisk if including a standalone
1300# recovery ramdisk in vendor_boot.
Yifan Hong881df392020-10-09 14:29:39 -07001301ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001302ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
Yifan Hong881df392020-10-09 14:29:39 -07001303$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1304$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1305endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001306endif
Yifan Hong881df392020-10-09 14:29:39 -07001307
J. Avila3f6560e2020-05-11 20:20:03 +00001308$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001309 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001310
Petri Gynther828828b2021-03-04 11:04:03 -08001311INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1312$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08001313 @echo "Target vendor ramdisk: $@"
Petri Gynther828828b2021-03-04 11:04:03 -08001314 $(copy-file-to-target)
Petri Gynther828828b2021-03-04 11:04:03 -08001315
Bob Badour70c07dd2022-02-12 15:39:22 -08001316$(call declare-1p-container,$(INSTALLED_VENDOR_RAMDISK_TARGET),)
1317$(call declare-container-license-deps,$(INSTALLED_VENDOR_RAMDISK_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
1318
1319VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_RAMDISK_TARGET)
1320
Petri Gynther6ff52012020-11-20 11:59:41 -08001321INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1322INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1323$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1324$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1325$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001326 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001327 mkdir -p $(dir $@)
1328 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001329 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1330 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001331
Bob Badour70c07dd2022-02-12 15:39:22 -08001332$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07001333$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_RAMDISK)))
Bob Badour70c07dd2022-02-12 15:39:22 -08001334
Steve Mucklee1b10862019-07-10 10:49:37 -07001335ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Lucas Weif57333f2022-02-24 10:30:15 +08001336 ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1337 # If we have vendor_kernel_boot partition, we migrate dtb image to that image
1338 # and allow dtb in vendor_boot to be empty.
1339 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1340 endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001341endif
1342ifdef BOARD_KERNEL_BASE
1343 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1344endif
1345ifdef BOARD_KERNEL_PAGESIZE
1346 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1347endif
1348ifdef INTERNAL_KERNEL_CMDLINE
1349 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1350endif
1351
Devin Moore50509012021-01-13 10:45:04 -08001352ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001353 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1354 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001355 rm -f $@
1356 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1357 printf "%s\n" $(param) >> $@;)
1358 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1359endif
1360
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001361# $(1): Build target name
1362# $(2): Staging dir to be compressed
1363# $(3): Build dependencies
1364define build-vendor-ramdisk-fragment-target
1365$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1366 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1367endef
1368
1369# $(1): Ramdisk name
1370define build-vendor-ramdisk-fragment
1371$(strip \
1372 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1373 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1374 $(build_target) \
1375)
1376endef
1377
1378# $(1): Ramdisk name
1379# $(2): Prebuilt file path
1380define build-prebuilt-vendor-ramdisk-fragment
1381$(strip \
1382 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1383 $(eval $(call copy-one-file,$(2),$(build_target))) \
1384 $(build_target) \
1385)
1386endef
1387
1388INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1389INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1390
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001391$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001392 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1393 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1394 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1395 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001396 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001397 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1398 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1399)
1400
Steve Mucklee1b10862019-07-10 10:49:37 -07001401INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1402$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001403$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001404ifeq ($(BOARD_AVB_ENABLE),true)
1405$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1406 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001407 $(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 -07001408 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1409 $(AVBTOOL) add_hash_footer \
1410 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001411 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Steve Mucklee1b10862019-07-10 10:49:37 -07001412 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1413 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1414else
1415$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1416 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001417 $(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 -07001418 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1419endif
Bob Badour70c07dd2022-02-12 15:39:22 -08001420
1421$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
1422$(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)/:/)
1423VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001424endif # BUILDING_VENDOR_BOOT_IMAGE
1425
1426# -----------------------------------------------------------------
Lucas Weif57333f2022-02-24 10:30:15 +08001427# vendor kernel boot image
1428ifeq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1429
1430INTERNAL_VENDOR_KERNEL_RAMDISK_FILES := $(filter $(TARGET_VENDOR_KERNEL_RAMDISK_OUT)/%, \
Lucas Weif57333f2022-02-24 10:30:15 +08001431 $(ALL_DEFAULT_INSTALLED_MODULES))
1432
1433INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_kernel_boot)/vendor_kernel_ramdisk.cpio$(RAMDISK_EXT)
1434
1435$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
1436 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
1437
1438INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_kernel_ramdisk.img
1439$(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1440 @echo "Target vendor kernel ramdisk: $@"
1441 $(copy-file-to-target)
1442
1443INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-kernel-ramdisk.txt
1444INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK:.txt=.json)
1445$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK)
1446$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1447$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
1448 @echo Installed file list: $@
1449 mkdir -p $(dir $@)
1450 rm -f $@
1451 $(FILESLIST) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) > $(@:.txt=.json)
1452 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
1453
Bob Badour5acd4362022-04-12 18:31:35 -07001454$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK))
1455$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK))
1456
Lucas Weif57333f2022-02-24 10:30:15 +08001457INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS := --vendor_ramdisk $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1458INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_kernel_boot.img
1459$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1460
1461ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1462 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1463 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
1464endif
1465ifdef BOARD_KERNEL_PAGESIZE
1466 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1467endif
1468
1469
1470ifeq ($(BOARD_AVB_ENABLE),true)
1471$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_KERNEL_BOOTIMAGE_KEY_PATH)
1472 $(call pretty,"Target vendor_kernel_boot image: $@")
1473 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1474 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1475 $(AVBTOOL) add_hash_footer \
1476 --image $@ \
1477 $(call get-partition-size-argument,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)) \
1478 --partition_name vendor_kernel_boot $(INTERNAL_AVB_VENDOR_KERNEL_BOOT_SIGNING_ARGS) \
1479 $(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)
1480else
1481$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):
1482 $(call pretty,"Target vendor_kernel_boot image: $@")
1483 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1484 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1485endif
Bob Badour5acd4362022-04-12 18:31:35 -07001486$(call declare-1p-container,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
1487ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1488$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),\
1489 $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET),\
1490 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1491else
1492$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET),$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1493endif
Lucas Weif57333f2022-02-24 10:30:15 +08001494endif # BUILDING_VENDOR_KERNEL_BOOT_IMAGE
1495
1496# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001497# NOTICE files
1498#
Steve Blockd14d3b42012-03-01 11:34:41 +00001499# We are required to publish the licenses for all code under BSD, GPL and
1500# Apache licenses (and possibly other more exotic ones as well). We err on the
1501# side of caution, so the licenses for other third-party code are included here
1502# too.
1503#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001504# This needs to be before the systemimage rules, because it adds to
1505# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1506# go into the systemimage.
1507
Steve Block495e5852012-02-29 19:18:08 +00001508.PHONY: notice_files
1509
Bob Badour70c07dd2022-02-12 15:39:22 -08001510# Convert license metadata into xml notice file.
1511# $(1) - Output target notice filename
1512# $(2) - Product name
1513# $(3) - File title
1514# $(4) - License metadata file roots
1515# $(5) - Prefixes to strip
1516#
1517define xml-notice-rule
1518$(1): PRIVATE_PRODUCT := $(2)
1519$(1): PRIVATE_MESSAGE := $(3)
Bob Badour5acd4362022-04-12 18:31:35 -07001520$(1): PRIVATE_DEPS := $(call corresponding-license-metadata,$(4))
Bob Badour70c07dd2022-02-12 15:39:22 -08001521$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badour5acd4362022-04-12 18:31:35 -07001522 OUT_DIR=$(OUT_DIR) $(XMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $$(PRIVATE_DEPS)
Bob Badour70c07dd2022-02-12 15:39:22 -08001523
1524notice_files: $(1)
1525endef
1526
1527# Convert license metadata into text notice file.
1528# $(1) - Output target notice filename
1529# $(2) - Product name
1530# $(3) - File title
1531# $(4) - License metadata file roots
1532# $(5) - Prefixes to strip
1533#
1534define text-notice-rule
1535$(1): PRIVATE_PRODUCT := $(2)
1536$(1): PRIVATE_MESSAGE := $(3)
1537$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001538 OUT_DIR=$(OUT_DIR) $(TEXTNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
Bob Badour70c07dd2022-02-12 15:39:22 -08001539
1540notice_files: $(1)
1541endef
1542
1543# Conversion license metadata into html notice file.
1544# $(1) - Output target notice filename
1545# $(2) - Product name
1546# $(3) - File title
1547# $(4) - License metadata file roots
1548# $(5) - Prefixes to strip
1549#
1550define html-notice-rule
1551$(1): PRIVATE_PRODUCT := $(2)
1552$(1): PRIVATE_MESSAGE := $(3)
1553$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001554 OUT_DIR=$(OUT_DIR) $(HTMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
Bob Badour70c07dd2022-02-12 15:39:22 -08001555
1556notice_files: $(1)
1557endef
1558
Bob Badour6259a092022-03-23 23:28:40 -07001559$(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 -08001560
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001561# Notice file logic isn't relevant for TARGET_BUILD_APPS
1562ifndef TARGET_BUILD_APPS
1563
The Android Open Source Project88b60792009-03-03 19:28:42 -08001564# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1565# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1566# the src subdirectory.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001567kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1568winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001569
Bob Badour4b25c902020-01-28 13:23:39 -08001570# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1571# reasons--not to be flashed onto any device. Targets under these directories
1572# need no associated notice file on the device UI.
1573exclude_target_dirs := apex
1574
Steven Morelandae69e572017-12-15 14:49:55 -08001575# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001576ifneq ($(PRODUCT_NOTICE_SPLIT),true)
Bob Badour70c07dd2022-02-12 15:39:22 -08001577#target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001578target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1579installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Bob Badour879cfa82021-04-15 10:41:38 -07001580
1581$(call declare-0p-target,$(target_notice_file_html_gz))
1582$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001583else
Bob Badour70c07dd2022-02-12 15:39:22 -08001584# target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001585target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001586installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1587
1588target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001589target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1590installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001591
1592target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
Dario Freniadc972d2018-07-09 18:38:38 +01001593target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1594installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001595
Justin Yun6151e3f2019-06-25 15:58:13 +09001596target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
Justin Yun6151e3f2019-06-25 15:58:13 +09001597target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1598installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001599
Chris Gross15d96552019-07-16 14:38:43 -07001600target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
Chris Gross15d96552019-07-16 14:38:43 -07001601target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1602installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1603
Yifan Hong3d3f0302020-05-11 18:35:11 -07001604target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
Yifan Hong3d3f0302020-05-11 18:35:11 -07001605target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1606installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1607
Yifan Hongc83f9e92020-07-15 16:57:47 -07001608target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
Yifan Hongc83f9e92020-07-15 16:57:47 -07001609target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1610installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1611
Ramji Jiyani13a41372022-01-27 07:05:08 +00001612target_system_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.txt
Ramji Jiyani13a41372022-01-27 07:05:08 +00001613target_system_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.xml.gz
1614installed_system_dlkm_notice_xml_gz := $(TARGET_OUT_SYSTEM_DLKM)/etc/NOTICE.xml.gz
1615
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001616# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1617# being built. A notice xml file must depend on all modules that could potentially
1618# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001619license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001620# Only files copied to a system image need system image notices.
1621license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001622# Phonys/fakes don't have notice files (though their deps might)
1623license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001624# testcases are not relevant to the system image.
1625license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001626# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001627license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001628# system_other is relevant to system partition.
1629license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001630license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1631license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001632license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001633license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001634license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001635license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001636license_modules_odm_dlkm := $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001637license_modules_agg := $(license_modules_system) \
1638 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001639 $(license_modules_product) \
1640 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001641 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001642 $(license_modules_vendor_dlkm) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001643 $(license_modules_odm_dlkm) \
1644 $(license_modules_system_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001645# targets used for debug symbols only and do not get copied to the device
1646license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1647
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001648license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001649license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1650
1651# Identify the other targets we expect to have notices for:
1652# targets copied to the device but are not readable by the UI (e.g. must boot
1653# into a different partition to read or don't have an associated /etc
1654# directory) must have their notices built somewhere readable.
1655license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1656license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1657license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1658license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1659license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1660license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001661license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001662license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1663license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1664license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1665license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1666license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1667license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1668
1669# after removing targets in system images, targets reported in system images, and
1670# targets used for debug symbols that do not need notices, nothing must remain.
1671license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1672$(call maybe-print-list-and-error, $(license_modules_rest), \
1673 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001674
Chris Grossaad39b32019-06-13 09:43:26 -07001675# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1676# update its notice file, so include those notices in the system partition instead
1677ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001678license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001679system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1680system_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 -07001681else
Bob Badour4b25c902020-01-28 13:23:39 -08001682license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001683system_xml_directories := xml_system
1684system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001685endif
1686
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001687endif # PRODUCT_NOTICE_SPLIT
1688
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001689ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001690
Ying Wang62c81f82013-08-22 20:02:03 -07001691endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001692
1693# The kernel isn't really a module, so to get its module file in there, we
1694# make the target NOTICE files depend on this particular file too, which will
1695# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001696$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001697
Bob Badour70c07dd2022-02-12 15:39:22 -08001698# No matter where it gets copied from, a copied linux kernel is licensed under "GPL 2.0 only"
1699$(eval $(call declare-copy-files-license-metadata,,:kernel,SPDX-license-identifier-GPL-2.0-only,notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,))
1700
Dan Willemsen288bedf2019-05-28 15:36:47 -07001701$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001702
Doug Zongker8678df42009-06-15 14:30:14 -07001703
The Android Open Source Project88b60792009-03-03 19:28:42 -08001704# #################################################################
1705# Targets for user images
1706# #################################################################
1707
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001708# These options tell the recovery updater/installer how to mount the partitions writebale.
1709# <fstype>=<fstype_opts>[|<fstype_opts>]...
1710# fstype_opts := <opt>[,<opt>]...
1711# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001712# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1713DEFAULT_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 -07001714
Tao Baodba635a2019-06-24 10:39:54 -07001715INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001716 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001717 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001718 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001719
Bob Badour2f66fd12022-03-09 17:30:24 -08001720$(call declare-1p-target,$(MKE2FS_CONF),system/extras)
1721
Tao Baodba635a2019-06-24 10:39:54 -07001722ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1723INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001724endif
1725
Yifan Hongcfb917a2020-05-07 14:58:20 -07001726ifneq ($(filter \
1727 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1728 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1729 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1730 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1731 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1732 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001733 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001734 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001735 ,erofs),)
David Anderson94ad5bb2022-03-04 10:57:58 -08001736INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
David Andersonf54665f2022-03-04 14:42:18 -08001737ifeq ($(BOARD_EROFS_USE_LEGACY_COMPRESSION),true)
1738BOARD_EROFS_COMPRESSOR ?= "lz4"
1739else
Kelvin Zhang37d49292021-12-01 14:21:24 -08001740BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
Gao Xiang961041a2020-06-17 13:59:16 +08001741endif
David Andersonf54665f2022-03-04 14:42:18 -08001742endif
Gao Xiang961041a2020-06-17 13:59:16 +08001743
1744ifneq ($(filter \
1745 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1746 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1747 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1748 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1749 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1750 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1751 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001752 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001753 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001754INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1755endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001756
Anton Hansson8dab0a62019-03-28 15:45:40 +00001757ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001758INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001759ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001760INTERNAL_USERIMAGES_DEPS += $(FEC)
1761endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001762endif
1763
Tao Baodba635a2019-06-24 10:39:54 -07001764ifeq ($(BOARD_AVB_ENABLE),true)
1765INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1766endif
1767
1768# Get a colon-separated list of search paths.
1769INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1770
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001771# Collects file_contexts files from modules to be installed
1772$(call merge-fc-files, \
1773 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1774 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1775
Alex Klyubin092c9022017-03-13 13:28:34 -07001776SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001777
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001778INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1779
Yifan Hongc5c01242018-11-09 10:27:23 -08001780ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001781
Anton Hansson8dab0a62019-03-28 15:45:40 +00001782ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001783 $(error vboot 1.0 doesn't support logical partition)
1784endif
1785
Yifan Hongc5c01242018-11-09 10:27:23 -08001786endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001787
David Anderson707e6f52021-09-21 22:24:43 -07001788# $(1) the partition name (eg system)
1789# $(2) the image prop file
1790define add-common-flags-to-image-props
1791$(eval _var := $(call to-upper,$(1)))
1792$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
1793$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
1794endef
1795
1796# $(1) the partition name (eg system)
1797# $(2) the image prop file
1798define add-common-ro-flags-to-image-props
1799$(eval _var := $(call to-upper,$(1)))
David Anderson64b351b2021-10-13 00:20:43 -07001800$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001801$(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 -07001802$(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 -07001803$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
1804$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
1805$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
1806$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
1807$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
1808$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
1809$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
1810$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
1811$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
1812$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
1813$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
1814$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
1815$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
1816$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
1817$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
1818$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
David Anderson5f4aa6c2021-09-23 17:03:14 -07001819$(if $(or $(_size), $(_reserved), $(_headroom)),,
1820 $(hide) echo "$(1)_disable_sparse=true" >> $(2))
David Anderson707e6f52021-09-21 22:24:43 -07001821$(call add-common-flags-to-image-props,$(1),$(2))
David Anderson9e95a022021-08-31 21:32:45 -07001822endef
1823
Ying Wangbd93d422011-10-28 17:02:30 -07001824# $(1): the path of the output dictionary file
Ramji Jiyani13a41372022-01-27 07:05:08 +00001825# $(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 -07001826# $(3): additional "key=value" pairs to append to the dictionary file.
1827define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001828$(if $(filter $(2),system),\
Bowgo Tsai867ab662019-01-29 13:30:18 +08001829 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001830 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001831 $(call add-common-ro-flags-to-image-props,system,$(1))
Chris Gross203191b2020-05-30 02:39:12 +00001832)
1833$(if $(filter $(2),system_other),\
1834 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
David Anderson9e95a022021-08-31 21:32:45 -07001835 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
1836 $(hide) echo "system_other_disable_sparse=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001837)
Yifan Hong760d3c02018-05-30 11:16:46 -07001838$(if $(filter $(2),userdata),\
1839 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1840 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001841 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1842 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kim55c16dd2020-10-12 19:50:05 -07001843 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001844 $(call add-common-flags-to-image-props,userdata,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001845)
Yifan Hong760d3c02018-05-30 11:16:46 -07001846$(if $(filter $(2),cache),\
1847 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1848 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001849 $(call add-common-flags-to-image-props,cache,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001850)
1851$(if $(filter $(2),vendor),\
David Anderson707e6f52021-09-21 22:24:43 -07001852 $(call add-common-ro-flags-to-image-props,vendor,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001853)
1854$(if $(filter $(2),product),\
David Anderson707e6f52021-09-21 22:24:43 -07001855 $(call add-common-ro-flags-to-image-props,product,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001856)
Justin Yun6151e3f2019-06-25 15:58:13 +09001857$(if $(filter $(2),system_ext),\
David Anderson707e6f52021-09-21 22:24:43 -07001858 $(call add-common-ro-flags-to-image-props,system_ext,$(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001859)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001860$(if $(filter $(2),odm),\
David Anderson707e6f52021-09-21 22:24:43 -07001861 $(call add-common-ro-flags-to-image-props,odm,$(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001862)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001863$(if $(filter $(2),vendor_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001864 $(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001865)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001866$(if $(filter $(2),odm_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001867 $(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001868)
Ramji Jiyani13a41372022-01-27 07:05:08 +00001869$(if $(filter $(2),system_dlkm),\
1870 $(call add-common-ro-flags-to-image-props,system_dlkm,$(1))
1871)
Yifan Hong760d3c02018-05-30 11:16:46 -07001872$(if $(filter $(2),oem),\
1873 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1874 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1875 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1876 $(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 -07001877 $(call add-common-flags-to-image-props,oem,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001878)
Tao Bao3602eca2018-07-10 10:53:55 -07001879$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001880
Cole Faust8fc7bef2022-06-15 16:10:49 -07001881$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT2)),$(hide) echo "fs_type=ext2" >> $(1),
1882 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT3)),$(hide) echo "fs_type=ext3" >> $(1),
1883 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT4)),$(hide) echo "fs_type=ext4" >> $(1))))
1884
1885$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)),,$(hide) echo "extfs_sparse_flag=-s" >> $(1))
1886$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED)),,$(hide) echo "erofs_sparse_flag=-s" >> $(1))
1887$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)),,$(hide) echo "squashfs_sparse_flag=-s" >> $(1))
1888$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)),,$(hide) echo "f2fs_sparse_flag=-S" >> $(1))
David Anderson40a821f2021-09-22 18:02:01 -07001889$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001890$(if $(BOARD_EROFS_COMPRESS_HINTS),$(hide) echo "erofs_default_compress_hints=$(BOARD_EROFS_COMPRESS_HINTS)" >> $(1))
David Anderson64b351b2021-10-13 00:20:43 -07001891$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
1892$(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 -08001893$(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 -07001894$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1895$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1896$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001897$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1898$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1899$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1900$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1901$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001902$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001903$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1904$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1905$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001906$(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 -07001907$(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 -07001908$(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 +00001909$(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 +00001910$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1911$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1912$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1913$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1914$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001915$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001916$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1917$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1918$(if $(BOARD_AVB_ENABLE),\
1919 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1920 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1921 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1922 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001923$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1924$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1925$(if $(BOARD_AVB_ENABLE),\
1926 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1927 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001928 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001929$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1930$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1931$(if $(BOARD_AVB_ENABLE),\
1932 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1933 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1934 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1935 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001936$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1937$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1938$(if $(BOARD_AVB_ENABLE),\
1939 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1940 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1941 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1942 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001943$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001944$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001945 $(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 +01001946$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001947 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1948 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1949 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1950 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001951$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1952$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1953$(if $(BOARD_AVB_ENABLE),\
1954 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1955 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1956 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1957 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001958$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1959$(if $(BOARD_AVB_ENABLE),\
1960 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1961$(if $(BOARD_AVB_ENABLE),\
1962 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1963 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1964 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1965 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001966$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1967$(if $(BOARD_AVB_ENABLE),\
1968 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1969$(if $(BOARD_AVB_ENABLE),\
1970 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1971 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1972 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1973 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001974$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1975$(if $(BOARD_AVB_ENABLE),\
1976 $(hide) echo "avb_system_dlkm_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1977$(if $(BOARD_AVB_ENABLE),\
1978 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
1979 $(hide) echo "avb_system_dlkm_key_path=$(BOARD_AVB_SYSTEM_DLKM_KEY_PATH)" >> $(1)
1980 $(hide) echo "avb_system_dlkm_algorithm=$(BOARD_AVB_SYSTEM_DLKM_ALGORITHM)" >> $(1)
1981 $(hide) echo "avb_system_dlkm_rollback_index_location=$(BOARD_SYSTEM_SYSTEM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001982$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1983 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001984$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001985 $(hide) echo "system_root_image=true" >> $(1))
Bowgo Tsai85578e02022-04-19 10:50:59 +08001986$(if $(filter true,$(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK)),\
1987 $(hide) echo "gki_boot_image_without_ramdisk=true" >> $(1))
Tom Cherryd14b8952018-08-09 14:26:00 -07001988$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001989$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1990 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001991$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1992endef
1993
1994# $(1): the path of the output dictionary file
1995# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001996PROP_DICTIONARY_IMAGES := oem
1997ifdef BUILDING_CACHE_IMAGE
1998 PROP_DICTIONARY_IMAGES += cache
1999endif
2000ifdef BUILDING_SYSTEM_IMAGE
2001 PROP_DICTIONARY_IMAGES += system
2002endif
Chris Gross203191b2020-05-30 02:39:12 +00002003ifdef BUILDING_SYSTEM_OTHER_IMAGE
2004 PROP_DICTIONARY_IMAGES += system_other
2005endif
Daniel Norman72c626f2019-05-13 15:58:14 -07002006ifdef BUILDING_USERDATA_IMAGE
2007 PROP_DICTIONARY_IMAGES += userdata
2008endif
2009ifdef BUILDING_VENDOR_IMAGE
2010 PROP_DICTIONARY_IMAGES += vendor
2011endif
2012ifdef BUILDING_PRODUCT_IMAGE
2013 PROP_DICTIONARY_IMAGES += product
2014endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002015ifdef BUILDING_SYSTEM_EXT_IMAGE
2016 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07002017endif
2018ifdef BUILDING_ODM_IMAGE
2019 PROP_DICTIONARY_IMAGES += odm
2020endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002021ifdef BUILDING_VENDOR_DLKM_IMAGE
2022 PROP_DICTIONARY_IMAGES += vendor_dlkm
2023endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07002024ifdef BUILDING_ODM_DLKM_IMAGE
2025 PROP_DICTIONARY_IMAGES += odm_dlkm
2026endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00002027ifdef BUILDING_SYSTEM_DLKM_IMAGE
2028 PROP_DICTIONARY_IMAGES += system_dlkm
2029endif
Yifan Hong760d3c02018-05-30 11:16:46 -07002030define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07002031 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07002032endef
2033
Yifan Hongbbcba1e2018-06-18 16:32:35 -07002034# $(1): the path of the input dictionary file, where each line has the format key=value
2035# $(2): the key to look up
2036define read-image-prop-dictionary
2037$$(grep '$(2)=' $(1) | cut -f2- -d'=')
2038endef
2039
The Android Open Source Project88b60792009-03-03 19:28:42 -08002040# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07002041# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07002042
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002043# Recovery image exists if we are building recovery, or building recovery as boot.
Colin Cross79a76ec2022-03-21 15:06:11 -07002044INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RECOVERY_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Chris Grossa784ef12019-04-22 11:09:57 -07002045ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002046
Ying Wang37526142015-03-10 12:02:57 -07002047INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
2048 $(ALL_DEFAULT_INSTALLED_MODULES))
2049
Tao Bao10fc9492018-08-14 12:17:48 -07002050INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
2051INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
2052
Colin Cross359f4212020-12-02 15:14:04 -08002053ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2054INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
2055endif
2056
Tao Bao10fc9492018-08-14 12:17:48 -07002057# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
2058# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
2059# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
2060# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08002061$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07002062
2063$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002064$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07002065 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002066 mkdir -p $(dir $@)
2067 rm -f $@
2068 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
2069 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07002070
Bob Badour5acd4362022-04-12 18:31:35 -07002071$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RECOVERY)))
2072$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RECOVERY)))
2073
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002074recovery_sepolicy := \
2075 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07002076 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002077 $(TARGET_RECOVERY_ROOT_OUT)/plat_service_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002078 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002079 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002080 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_service_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002081 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
2082 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002083 $(TARGET_RECOVERY_ROOT_OUT)/vendor_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002084 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08002085 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002086 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
2087 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002088 $(TARGET_RECOVERY_ROOT_OUT)/product_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002089 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08002090
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002091# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
2092# SELinux files
2093IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
2094
Steve Muckle04b6f052020-08-09 14:36:56 -07002095# if building multiple boot images from multiple kernels, use the first kernel listed
2096# for the recovery image
2097recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002098recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07002099recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08002100
Anton Hansson45a40da2019-01-18 14:06:34 +00002101# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
2102# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
2103# which get remapped to a bucket.
2104recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07002105ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
2106recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00002107# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07002108# ------160------240------320----------480------------640------
2109# mdpi hdpi xhdpi xxhdpi xxxhdpi
2110recovery_density := $(strip \
2111 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
2112 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
2113 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
2114 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07002115endif
2116
2117ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
2118recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
2119else
Doug Zongker25d55f82014-04-04 13:51:15 -07002120recovery_resources_common := $(recovery_resources_common)-xhdpi
2121endif
2122
Tao Baoe1e829e2018-08-29 20:36:00 -07002123# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
2124# Note that the font selected here can be overridden for a particular device by putting a font.png
2125# in its private recovery resources.
2126ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07002127recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08002128else
Dan Willemsen97672232020-05-27 00:09:16 -07002129recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08002130endif
2131
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002132
2133# We will only generate the recovery background text images if the variable
2134# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
2135# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
2136# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
2137# BoardConfig in order to use this feature.
2138ifeq ($(recovery_density),xxxhdpi)
2139TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
2140else ifeq ($(recovery_density),xxhdpi)
2141TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
2142endif
2143
2144ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
2145# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
2146ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
2147 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
2148else
2149 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
2150endif
2151
2152
Dan Willemsen97672232020-05-27 00:09:16 -07002153RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002154RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
2155RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
2156RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
2157RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
2158
xunchangcc57d312018-12-07 12:12:17 -08002159RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
2160RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
2161RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
2162RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
2163RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
2164
2165generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002166 $(RECOVERY_INSTALLING_TEXT_FILE) \
2167 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
2168 $(RECOVERY_ERASING_TEXT_FILE) \
2169 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08002170 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
2171 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
2172 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
2173 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
2174 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
2175 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002176
Dan Willemsen97672232020-05-27 00:09:16 -07002177resource_dir := bootable/recovery/tools/recovery_l10n/res/
2178resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002179image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08002180zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002181$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07002182$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002183$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
2184$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08002185$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002186$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08002187$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002188 recovery_installing \
2189 recovery_installing_security \
2190 recovery_erasing \
2191 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08002192 recovery_no_command
2193$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002194 recovery_cancel_wipe_data \
2195 recovery_factory_data_reset \
2196 recovery_try_again \
2197 recovery_wipe_data_menu_header \
2198 recovery_wipe_data_confirmation
2199$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07002200$(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 -08002201 # Prepares the font directory.
2202 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
2203 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08002204 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002205 @rm -rf $(dir $@)
2206 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08002207 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08002208 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08002209 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002210 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
2211 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
2212 --text_name $(text_name) \
2213 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2214 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002215 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002216 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002217else
2218RECOVERY_INSTALLING_TEXT_FILE :=
2219RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2220RECOVERY_ERASING_TEXT_FILE :=
2221RECOVERY_ERROR_TEXT_FILE :=
2222RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002223RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2224RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2225RECOVERY_TRY_AGAIN_TEXT_FILE :=
2226RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2227RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002228endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2229
Ying Wang9a175682015-08-06 11:47:47 -07002230ifndef TARGET_PRIVATE_RES_DIRS
2231TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2232endif
Doug Zongker4647f122009-07-02 09:00:54 -07002233recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002234 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002235recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002236
2237
Andrew Boiefa61ff02012-09-28 09:33:45 -07002238ifdef TARGET_RECOVERY_FSTAB
2239recovery_fstab := $(TARGET_RECOVERY_FSTAB)
Cole Faust64c2ddb2022-01-07 12:44:31 -08002240else ifdef TARGET_RECOVERY_FSTAB_GENRULE
2241# Specifies a soong genrule module that generates an fstab.
2242recovery_fstab := $(call intermediates-dir-for,ETC,$(TARGET_RECOVERY_FSTAB_GENRULE))/$(TARGET_RECOVERY_FSTAB_GENRULE)
Andrew Boiefa61ff02012-09-28 09:33:45 -07002243else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002244recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002245endif
Tao Baoc3c17532016-06-10 10:11:54 -07002246ifdef TARGET_RECOVERY_WIPE
2247recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002248else
Tao Baoc3c17532016-06-10 10:11:54 -07002249recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002250endif
Tao Bao8beab692015-07-22 12:33:18 -07002251
Tao Bao6d5d6232018-03-09 17:04:42 -08002252# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002253# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002254# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2255# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002256#
2257# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002258# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002259# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002260# b) We build a single image that contains boot and recovery both - no recovery image to install
2261# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07002262# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08002263# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002264# d) We include the recovery DTBO image within recovery - not needing the resource file as we
2265# do bsdiff because boot and recovery will contain different number of entries
2266# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002267# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
2268# do bsdiff because boot and recovery will contain different number of entries
2269# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yifan Hongef7a9712020-10-20 13:17:42 -07002270# f) We build a single image that contains vendor_boot and recovery both - no recovery image to
2271# install
2272# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002273
Tom Cherry2929cad2018-09-20 11:04:37 -07002274ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002275 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
2276 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002277# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002278RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2279ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002280else
Tao Bao8beab692015-07-22 12:33:18 -07002281RECOVERY_RESOURCE_ZIP :=
2282endif
Doug Zongker4647f122009-07-02 09:00:54 -07002283
Tao Bao139c7272018-07-31 13:26:54 -07002284INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2285
2286$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002287 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2288 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2289 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2290 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2291 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2292 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2293 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2294 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2295
2296# Parses the given list of build variables and writes their values as build properties if defined.
2297# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2298# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2299# $(1): Map from the build variable names to property names
2300# $(2): Output file
2301define append-recovery-ui-properties
2302echo "#" >> $(2)
2303echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2304echo "#" >> $(2)
2305$(foreach prop,$(1), \
2306 $(eval _varname := $(call word-colon,1,$(prop))) \
2307 $(eval _propname := $(call word-colon,2,$(prop))) \
2308 $(eval _value := $($(_varname))) \
2309 $(if $(_value), \
2310 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2311endef
2312
2313$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002314 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002315 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2316 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2317 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002318 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002319 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002320 $(hide) mkdir -p $(dir $@)
2321 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002322 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002323 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002324 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002325 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002326 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002327 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2328
Bob Badour5acd4362022-04-12 18:31:35 -07002329$(call declare-1p-target,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),build)
2330$(call declare-license-deps,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),\
2331 $(INSTALLED_BUILD_PROP_TARGET) $(INSTALLED_VENDOR_BUILD_PROP_TARGET) $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2332 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET))
2333
Yifan Hong33fd5d42020-09-24 18:18:26 -07002334# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2335# On device with dedicated recovery partition, the file should come from the boot
2336# ramdisk.
2337ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2338INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2339$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2340 $(copy-file-to-target)
Bob Badour5acd4362022-04-12 18:31:35 -07002341
2342$(call declare-1p-target,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),build)
2343$(call declare-license-deps,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),$(INSTALLED_RAMDISK_BUILD_PROP_TARGET))
Yifan Hong33fd5d42020-09-24 18:18:26 -07002344endif
2345
Yifan Hongc56931c2020-10-28 16:35:19 -07002346INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002347
Yifan Hong78860162020-10-28 14:15:21 -07002348ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002349INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002350# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002351ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002352ifdef INTERNAL_KERNEL_CMDLINE
2353 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002354endif # INTERNAL_KERNEL_CMDLINE != ""
2355endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002356ifdef BOARD_KERNEL_BASE
2357 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2358endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002359ifdef BOARD_KERNEL_PAGESIZE
2360 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2361endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002362ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002363ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2364 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2365else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002366 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2367endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002368endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002369ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2370 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2371endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002372ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2373 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2374endif
Yifan Hong3941a872020-10-28 16:33:06 -07002375endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002376ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2377 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2378endif
Doug Zongker4647f122009-07-02 09:00:54 -07002379
Yifan Hong881df392020-10-09 14:29:39 -07002380$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002381 $(INTERNAL_ROOT_FILES) \
2382 $(INSTALLED_RAMDISK_TARGET) \
2383 $(INTERNAL_RECOVERYIMAGE_FILES) \
2384 $(recovery_sepolicy) \
2385 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2386 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002387 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002388 $(recovery_resource_deps) \
2389 $(recovery_fstab)
2390 # Making recovery image
2391 mkdir -p $(TARGET_RECOVERY_OUT)
2392 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2393 # Copying baseline ramdisk...
2394 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2395 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2396 # Modifying ramdisk contents...
2397 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2398 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
2399 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2400 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2401 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2402 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2403 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2404 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2405 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2406 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2407 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2408 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2409 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2410 $(foreach item,$(recovery_fstab), \
2411 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2412 $(if $(strip $(recovery_wipe)), \
2413 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2414 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2415 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002416 $(hide) touch $@
2417
2418$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002419 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002420
Ying Wang747b9f12015-01-30 14:05:22 -08002421# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002422# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002423define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002424 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002425 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002426 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002427 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002428 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002429 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002430 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002431 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002432 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002433 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2434 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002435 )\
2436 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002437 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2438 $(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 +08002439 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002440 $(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 -07002441 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002442 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2443 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002444 $(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),\
2445 $(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 -08002446endef
2447
Dan Willemsend120ac62020-06-12 02:39:34 +00002448recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002449ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00002450 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002451endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002452ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002453 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002454endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002455ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002456 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002457endif
Tao Baof4866c72018-08-22 14:35:09 -07002458ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002459 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2460 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2461 else
2462 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2463 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002464endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002465ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002466 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002467endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002468ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002469 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002470endif
Tao Baof4866c72018-08-22 14:35:09 -07002471
Dan Willemsend120ac62020-06-12 02:39:34 +00002472ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002473$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002474$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002475 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002476 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Bob Badour70c07dd2022-02-12 15:39:22 -08002477
2478$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
2479$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2480
2481UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Tao Baof4866c72018-08-22 14:35:09 -07002482endif # BOARD_USES_RECOVERY_AS_BOOT
2483
Dan Willemsend120ac62020-06-12 02:39:34 +00002484$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002485 $(call build-recoveryimage-target, $@, \
2486 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002487
Tao Bao4594d0e2015-12-22 09:47:46 -08002488ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002489$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002490 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002491 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2492 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002493endif
Doug Zongker56588872012-08-20 15:38:58 -07002494
Bob Badour70c07dd2022-02-12 15:39:22 -08002495
2496$(call declare-1p-container,$(INSTALLED_RECOVERYIMAGE_TARGET),)
2497$(call declare-container-license-deps,$(INSTALLED_RECOVERYIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2498
2499UNMOUNTED_NOTICE_DEPS += $(INSTALLED_RECOVERYIMAGE_TARGET)
2500
Ying Wang747b9f12015-01-30 14:05:22 -08002501.PHONY: recoveryimage-nodeps
2502recoveryimage-nodeps:
2503 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002504 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2505 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002506
Chris Grossa784ef12019-04-22 11:09:57 -07002507else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002508RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002509endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002510
2511.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002512recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002513
Jiyong Park03eb0612017-10-04 21:22:41 +09002514ifneq ($(BOARD_NAND_PAGE_SIZE),)
2515$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002516endif
2517
Jiyong Park03eb0612017-10-04 21:22:41 +09002518ifneq ($(BOARD_NAND_SPARE_SIZE),)
2519$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002520endif
2521
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002522
Doug Zongker4647f122009-07-02 09:00:54 -07002523# -----------------------------------------------------------------
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002524# Build debug ramdisk and debug boot image.
Colin Cross79a76ec2022-03-21 15:06:11 -07002525INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002526ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
2527
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002528INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002529 $(ALL_DEFAULT_INSTALLED_MODULES))
2530
2531# Directories to be picked into the debug ramdisk.
2532# As these directories are all merged into one single cpio archive, the order
2533# matters. If there are multiple files with the same pathname, then the last one
2534# wins.
2535#
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002536# ramdisk-debug.img will merge the content from either ramdisk.img or
2537# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
2538# is set or not.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002539ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002540 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT)
2541 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002542else # BOARD_USES_RECOVERY_AS_BOOT == true
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002543 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT)
2544 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002545endif # BOARD_USES_RECOVERY_AS_BOOT != true
2546
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002547INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT)
2548INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES)
2549
2550# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
2551INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2552INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2553$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2554$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS)
2555$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2556 @echo "Installed file list: $@"
2557 $(hide) rm -f $@
2558 $(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT)
2559 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
2560 $(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2561 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2562
Bob Badour70c07dd2022-02-12 15:39:22 -08002563$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_DEBUG_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07002564$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_DEBUG_RAMDISK)))
Bob Badour70c07dd2022-02-12 15:39:22 -08002565
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002566ifdef BUILDING_DEBUG_BOOT_IMAGE
2567
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002568# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002569# the debug ramdisk, which is the original ramdisk plus additional
2570# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2571# When /force_debuggable is present, /init will load userdebug sepolicy
2572# and property files to allow adb root, if the device is unlocked.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002573INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
Bowgo Tsai0013f552019-03-20 17:59:52 +08002574
Bowgo Tsai610286a2021-04-23 11:31:32 +08002575$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002576$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2577 @echo "Target debug ramdisk: $@"
2578 $(hide) rm -f $@
2579 $(hide) mkdir -p $(dir $@)
2580 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002581
Bob Badour70c07dd2022-02-12 15:39:22 -08002582$(call declare-1p-container,$(INSTALLED_DEBUG_RAMDISK_TARGET),)
2583$(call declare-container-license-deps,$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2584
2585UNMOUNTED_NOTICE_DEPS += $(INSTALLED_DEBUG_RAMDISK_TARGET)
2586
Bowgo Tsai0013f552019-03-20 17:59:52 +08002587.PHONY: ramdisk_debug-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002588ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002589 @echo "make $@: ignoring dependencies"
2590 $(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET)
2591 $(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS)
2592 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002593
2594# -----------------------------------------------------------------
2595# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2596#
2597# Note: it's intentional to skip signing for boot-debug.img, because it
2598# can only be used if the device is unlocked with verification error.
Steve Muckleb3dda772020-03-11 16:03:07 -07002599ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002600 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002601 $(PRODUCT_OUT)/$(k).img)
2602else
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002603 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
Steve Muckleb3dda772020-03-11 16:03:07 -07002604endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002605
2606# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002607$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002608ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002609 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 +08002610else
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002611 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 +08002612endif
2613
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002614# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2615# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2616# Using a test key to sign boot-debug.img to continue booting with the mismatched
2617# public key, if the device is unlocked.
2618ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002619$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002620endif
2621
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002622BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2623INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2624# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002625# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002626define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002627$(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 +08002628$(AVBTOOL) add_hash_footer \
2629 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002630 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),$(2)))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002631 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2632 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002633$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002634endef
2635
Steve Muckleb3dda772020-03-11 16:03:07 -07002636# $(1): output file
2637define build-debug-bootimage-target
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002638 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002639 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002640 $(BOARD_MKBOOTIMG_ARGS) --output $1
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002641 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
Steve Muckleb3dda772020-03-11 16:03:07 -07002642endef
2643
Bowgo Tsai0013f552019-03-20 17:59:52 +08002644# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002645$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002646 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002647 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002648
Bob Badour70c07dd2022-02-12 15:39:22 -08002649$(call declare-1p-container,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),)
2650$(call declare-container-license-deps,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(INSTALLED_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2651
2652UNMOUNTED_NOTICE_DEPS += $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
2653
Bowgo Tsai0013f552019-03-20 17:59:52 +08002654.PHONY: bootimage_debug-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002655bootimage_debug-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002656 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002657 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002658
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002659endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002660
Bowgo Tsai6a683672020-02-14 19:00:15 +08002661# -----------------------------------------------------------------
2662# vendor debug ramdisk
2663# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Colin Cross79a76ec2022-03-21 15:06:11 -07002664INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002665ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2666
Bowgo Tsai610286a2021-04-23 11:31:32 +08002667INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
Bowgo Tsai610286a2021-04-23 11:31:32 +08002668 $(ALL_DEFAULT_INSTALLED_MODULES))
2669
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002670# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk.
2671INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT)
2672INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002673
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002674# Exclude recovery files in the default vendor ramdisk if including a standalone
2675# recovery ramdisk in vendor_boot.
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002676ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002677 ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2678 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT)
2679 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
2680 endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true
2681endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002682
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002683INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT)
2684INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
2685
2686# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created.
2687INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2688INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2689$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2690$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS)
2691$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2692 @echo "Installed file list: $@"
2693 $(hide) rm -f $@
2694 $(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2695 $(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2696 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2697
Bob Badour5acd4362022-04-12 18:31:35 -07002698$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK))
2699$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK))
Bob Badour70c07dd2022-02-12 15:39:22 -08002700
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002701INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
2702
Bowgo Tsai610286a2021-04-23 11:31:32 +08002703$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002704$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2705 $(hide) rm -f $@
2706 $(hide) mkdir -p $(dir $@)
2707 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002708
Petri Gyntherd7946d12021-03-10 12:38:15 -08002709INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2710$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002711 @echo "Target debug vendor ramdisk: $@"
Petri Gyntherd7946d12021-03-10 12:38:15 -08002712 $(copy-file-to-target)
Petri Gyntherd7946d12021-03-10 12:38:15 -08002713
Bob Badour70c07dd2022-02-12 15:39:22 -08002714$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),)
2715$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2716
2717VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2718
Bowgo Tsai6a683672020-02-14 19:00:15 +08002719# -----------------------------------------------------------------
2720# vendor_boot-debug.img.
2721INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2722
2723# The util to sign vendor_boot-debug.img with a test key.
2724BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2725INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2726# $(1): the vendor bootimage to sign
2727define test-key-sign-vendor-bootimage
2728$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2729$(AVBTOOL) add_hash_footer \
2730 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002731 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsai6a683672020-02-14 19:00:15 +08002732 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2733 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2734$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2735endef
2736
2737ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2738$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2739endif
2740
2741# 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 +08002742$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002743$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002744 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002745 $(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 +08002746 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2747 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2748
Bob Badour70c07dd2022-02-12 15:39:22 -08002749$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),)
2750$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2751
2752VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
2753
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002754endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai6a683672020-02-14 19:00:15 +08002755
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002756# Appends a few test harness specific properties into the adb_debug.prop.
2757ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2758ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2759
2760INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES)))
2761INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2762$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET)
2763 $(hide) rm -f $@
2764 $(hide) mkdir -p $(dir $@)
2765ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET
2766 $(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@
2767endif
2768 $(hide) echo "" >> $@
2769 $(hide) echo "#" >> $@
2770 $(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@
2771 $(hide) echo "#" >> $@
2772 $(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \
2773 echo "$(line)" >> $@;)
2774
Bob Badour2f66fd12022-03-09 17:30:24 -08002775$(call declare-1p-target,$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET))
2776
Colin Cross79a76ec2022-03-21 15:06:11 -07002777INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002778INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
2779 $(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002780 $(ALL_DEFAULT_INSTALLED_MODULES))
2781
2782# The order is important here. The test harness ramdisk staging directory has to
2783# come last so that it can override the adb_debug.prop in the debug ramdisk
2784# staging directory.
2785INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2786INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
2787
2788ifdef BUILDING_DEBUG_BOOT_IMAGE
2789
Bowgo Tsai0013f552019-03-20 17:59:52 +08002790# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002791# The test harness ramdisk, which is based off debug_ramdisk, plus a
2792# few additional test-harness-specific properties in adb_debug.prop.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002793INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002794
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002795$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS)
2796$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2797 @echo "Target test harness ramdisk: $@"
2798 $(hide) rm -f $@
2799 $(hide) mkdir -p $(dir $@)
2800 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002801
Bob Badour70c07dd2022-02-12 15:39:22 -08002802$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),)
2803$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS),$(PRODUCT_OUT)/:/)
2804
2805UNMOUNTED_NOTICE_DEPS += $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2806
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002807.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002808ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002809 @echo "make $@: ignoring dependencies"
2810 $(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2811 $(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS)
2812 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002813
2814# -----------------------------------------------------------------
2815# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2816#
2817# Note: it's intentional to skip signing for boot-test-harness.img, because it
2818# can only be used if the device is unlocked with verification error.
Steve Muckle4866bd62020-04-02 11:31:08 -07002819ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2820 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2821 $(PRODUCT_OUT)/$(k).img)
2822else
2823 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2824endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002825
2826# 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 +08002827$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002828INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2829
2830# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2831# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2832# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2833# public key, if the device is unlocked.
2834ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2835$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2836endif
2837
Steve Muckle4866bd62020-04-02 11:31:08 -07002838# $(1): output file
2839define build-boot-test-harness-target
2840 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002841 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002842 $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002843 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002844endef
2845
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002846# 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 +08002847$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002848 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002849 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002850
Bob Badour70c07dd2022-02-12 15:39:22 -08002851$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),)
2852$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2853
2854UNMOUNTED_NOTICE_DEPS += $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
2855
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002856.PHONY: bootimage_test_harness-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002857bootimage_test_harness-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002858 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002859 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002860
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002861endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002862
Bowgo Tsai87f60012021-07-29 23:35:33 +08002863# -----------------------------------------------------------------
2864# vendor test harness ramdisk, which is a vendor ramdisk combined with
2865# a test harness ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002866ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai87f60012021-07-29 23:35:33 +08002867
2868INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
2869
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002870# The order is important here. The test harness ramdisk staging directory has to
2871# come last so that it can override the adb_debug.prop in the debug ramdisk
2872# staging directory.
2873INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2874INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002875
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002876$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002877$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002878 $(hide) rm -f $@
2879 $(hide) mkdir -p $(dir $@)
2880 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai87f60012021-07-29 23:35:33 +08002881
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002882INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
2883$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2884 @echo "Target test harness vendor ramdisk: $@"
2885 $(copy-file-to-target)
2886
Bob Badour70c07dd2022-02-12 15:39:22 -08002887$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),)
2888$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2889
2890VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2891
Bowgo Tsai87f60012021-07-29 23:35:33 +08002892# -----------------------------------------------------------------
2893# vendor_boot-test-harness.img.
2894INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
2895
2896ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2897$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2898endif
2899
2900# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
2901$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
2902$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2903$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
2904 $(call pretty,"Target vendor_boot test harness image: $@")
2905 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
2906 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2907 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2908
Bob Badour70c07dd2022-02-12 15:39:22 -08002909$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),)
2910$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2911
2912VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
2913
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002914endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2915
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002916endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2917
Bowgo Tsai87f60012021-07-29 23:35:33 +08002918
Colin Crossbd382142020-08-26 15:08:57 -07002919# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2920# $1: from location (e.g $(TARGET_OUT)/vendor)
2921# $2: destination location (e.g. /vendor)
2922# $3: partition image name (e.g. vendor.img)
2923define create-partition-compat-symlink
2924$(eval \
2925$1:
2926 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2927 mkdir -p $(dir $1)
2928 if [ -d $1 ] && [ ! -h $1 ]; then \
2929 echo 'Non-symlink $1 detected!' 1>&2; \
2930 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2931 exit 1; \
2932 fi
2933 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002934$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002935)
2936$1
2937endef
2938
2939
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002940# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002941# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002942
Inseob Kim135c1f12022-01-06 17:22:07 +09002943# FSVerity metadata generation
2944# Generate fsverity metadata files (.fsv_meta) and build manifest
2945# (system/etc/security/fsverity/BuildManifest.apk) BEFORE filtering systemimage files below
2946ifeq ($(PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA),true)
2947
2948# Generate fsv_meta
2949fsverity-metadata-targets := $(sort $(filter \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08002950 $(TARGET_OUT)/framework/% \
Inseob Kim135c1f12022-01-06 17:22:07 +09002951 $(TARGET_OUT)/etc/boot-image.prof \
2952 $(TARGET_OUT)/etc/dirty-image-objects \
Nicolas Geoffray13f28212022-03-18 17:28:14 +00002953 $(TARGET_OUT)/etc/preloaded-classes \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08002954 $(TARGET_OUT)/etc/classpaths/%.pb, \
Colin Crossa1de5df2022-03-21 14:31:31 -07002955 $(ALL_DEFAULT_INSTALLED_MODULES)))
Inseob Kim135c1f12022-01-06 17:22:07 +09002956
2957define fsverity-generate-metadata
2958$(1).fsv_meta: PRIVATE_SRC := $(1)
2959$(1).fsv_meta: PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2960$(1).fsv_meta: $(HOST_OUT_EXECUTABLES)/fsverity_metadata_generator $(HOST_OUT_EXECUTABLES)/fsverity $(1)
2961 $$< --fsverity-path $$(PRIVATE_FSVERITY) --signature none \
2962 --hash-alg sha256 --output $$@ $$(PRIVATE_SRC)
2963endef
2964
2965$(foreach f,$(fsverity-metadata-targets),$(eval $(call fsverity-generate-metadata,$(f))))
2966ALL_DEFAULT_INSTALLED_MODULES += $(addsuffix .fsv_meta,$(fsverity-metadata-targets))
2967
2968# Generate BuildManifest.apk
2969FSVERITY_APK_KEY_PATH := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
2970FSVERITY_APK_OUT := $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk
2971FSVERITY_APK_MANIFEST_PATH := system/security/fsverity/AndroidManifest.xml
2972$(FSVERITY_APK_OUT): PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2973$(FSVERITY_APK_OUT): PRIVATE_AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002974$(FSVERITY_APK_OUT): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
Colin Cross658172d2022-01-27 12:45:13 -08002975$(FSVERITY_APK_OUT): PRIVATE_VERSION_CODE := $(PLATFORM_SDK_VERSION)
2976$(FSVERITY_APK_OUT): PRIVATE_VERSION_NAME := $(APPS_DEFAULT_VERSION_NAME)
Inseob Kim135c1f12022-01-06 17:22:07 +09002977$(FSVERITY_APK_OUT): PRIVATE_APKSIGNER := $(HOST_OUT_EXECUTABLES)/apksigner
2978$(FSVERITY_APK_OUT): PRIVATE_MANIFEST := $(FSVERITY_APK_MANIFEST_PATH)
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002979$(FSVERITY_APK_OUT): PRIVATE_FRAMEWORK_RES := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
Inseob Kim135c1f12022-01-06 17:22:07 +09002980$(FSVERITY_APK_OUT): PRIVATE_KEY := $(FSVERITY_APK_KEY_PATH)
2981$(FSVERITY_APK_OUT): PRIVATE_INPUTS := $(fsverity-metadata-targets)
2982$(FSVERITY_APK_OUT): $(HOST_OUT_EXECUTABLES)/fsverity_manifest_generator \
2983 $(HOST_OUT_EXECUTABLES)/fsverity $(HOST_OUT_EXECUTABLES)/aapt2 \
2984 $(HOST_OUT_EXECUTABLES)/apksigner $(FSVERITY_APK_MANIFEST_PATH) \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08002985 $(FSVERITY_APK_KEY_PATH).x509.pem $(FSVERITY_APK_KEY_PATH).pk8 \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002986 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08002987 $(fsverity-metadata-targets)
Inseob Kim135c1f12022-01-06 17:22:07 +09002988 $< --fsverity-path $(PRIVATE_FSVERITY) --aapt2-path $(PRIVATE_AAPT2) \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002989 --min-sdk-version $(PRIVATE_MIN_SDK_VERSION) \
Colin Cross658172d2022-01-27 12:45:13 -08002990 --version-code $(PRIVATE_VERSION_CODE) \
2991 --version-name $(PRIVATE_VERSION_NAME) \
Inseob Kim135c1f12022-01-06 17:22:07 +09002992 --apksigner-path $(PRIVATE_APKSIGNER) --apk-key-path $(PRIVATE_KEY) \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002993 --apk-manifest-path $(PRIVATE_MANIFEST) --framework-res $(PRIVATE_FRAMEWORK_RES) \
2994 --output $@ \
Inseob Kim135c1f12022-01-06 17:22:07 +09002995 --base-dir $(PRODUCT_OUT) $(PRIVATE_INPUTS)
2996
2997ALL_DEFAULT_INSTALLED_MODULES += $(FSVERITY_APK_OUT)
2998
2999endif # PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA
3000
Colin Cross79a76ec2022-03-21 15:06:11 -07003001INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen37a19862018-10-31 16:31:46 -07003002INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Dan Willemsena3f66322020-05-28 15:46:33 -07003003 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07003004
Colin Crossbd382142020-08-26 15:08:57 -07003005# Create symlink /system/vendor to /vendor if necessary.
3006ifdef BOARD_USES_VENDORIMAGE
3007 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
3008endif
3009
3010# Create symlink /system/product to /product if necessary.
3011ifdef BOARD_USES_PRODUCTIMAGE
3012 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
3013endif
3014
3015# Create symlink /system/system_ext to /system_ext if necessary.
3016ifdef BOARD_USES_SYSTEM_EXTIMAGE
3017 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
3018endif
3019
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003020# -----------------------------------------------------------------
3021# system_dlkm partition image
3022
3023# Create symlinks for system_dlkm on devices with a system_dlkm partition:
3024# /system/lib/modules -> /system_dlkm/lib/modules
3025#
3026# On devices with a system_dlkm partition,
3027# - /system/lib/modules is a symlink to a directory that stores system DLKMs.
3028# - The system_dlkm partition is mounted at /system_dlkm at runtime.
Ramji Jiyani13a41372022-01-27 07:05:08 +00003029ifdef BOARD_USES_SYSTEM_DLKMIMAGE
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003030 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/lib/modules,/system_dlkm/lib/modules,system_dlkm.img)
3031endif
3032
Ying Wang82cceba2012-08-13 15:03:00 -07003033FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003034
3035# ASAN libraries in the system image - add dependency.
3036ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07003037ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07003038 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
3039 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
3040 endif
3041endif
3042
Tom Cherryd14b8952018-08-09 14:26:00 -07003043FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07003044
Ying Wange5e8c5f2011-09-09 16:35:53 -07003045# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08003046ifdef BUILDING_SYSTEM_IMAGE
3047
Kiyoung Kim36481e02020-11-16 10:50:05 +09003048# Install system linker configuration
3049# Collect all available stub libraries installed in system and install with predefined linker configuration
3050SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
Colin Crossd4a054f2022-03-15 15:07:07 -07003051SYSTEM_LINKER_CONFIG_SOURCE := $(call intermediates-dir-for,ETC,system_linker_config)/system_linker_config
3052$(SYSTEM_LINKER_CONFIG): PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE := $(SYSTEM_LINKER_CONFIG_SOURCE)
3053$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE) | conv_linker_config
3054 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE) \
Kiyoung Kim36481e02020-11-16 10:50:05 +09003055 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
3056
Bob Badour2f66fd12022-03-09 17:30:24 -08003057$(call declare-1p-target,$(SYSTEM_LINKER_CONFIG),)
Colin Crossd4a054f2022-03-15 15:07:07 -07003058$(call declare-license-deps,$(SYSTEM_LINKER_CONFIG),$(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE))
Bob Badour2f66fd12022-03-09 17:30:24 -08003059
Kiyoung Kim36481e02020-11-16 10:50:05 +09003060FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
3061
Ying Wange5e8c5f2011-09-09 16:35:53 -07003062# installed file list
3063# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
3064# We put installed-files.txt ahead of image itself in the dependency graph
3065# so that we can get the size stat even if the build fails due to too large
3066# system image.
3067INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07003068INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
3069$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003070$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003071 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003072 mkdir -p $(dir $@)
3073 rm -f $@
3074 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
3075 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07003076
Bob Badour70c07dd2022-02-12 15:39:22 -08003077$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE)))
Bob Badour5acd4362022-04-12 18:31:35 -07003078$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON)))
Bob Badour70c07dd2022-02-12 15:39:22 -08003079
Ying Wange5e8c5f2011-09-09 16:35:53 -07003080.PHONY: installed-file-list
3081installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08003082
Ying Wange5e8c5f2011-09-09 16:35:53 -07003083systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003084 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003085BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
3086
The Android Open Source Project88b60792009-03-03 19:28:42 -08003087# $(1): output file
3088define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07003089 @echo "Target system fs image: $(1)"
3090 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003091 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07003092 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003093 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003094 $(BUILD_IMAGE) \
3095 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
3096 || ( mkdir -p $${DIST_DIR}; \
3097 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
3098 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08003099endef
3100
Dan Willemsen6b72c732019-06-12 21:33:38 +00003101ifeq ($(BOARD_AVB_ENABLE),true)
3102$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
3103endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07003104$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003105 $(call build-systemimage-target,$@)
3106
Bob Badour879cfa82021-04-15 10:41:38 -07003107$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
Bob Badour70c07dd2022-02-12 15:39:22 -08003108$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:/)
Bob Badour879cfa82021-04-15 10:41:38 -07003109
Tao Baoe9d61b02018-08-20 21:09:07 -07003110INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07003111SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003112
Tao Baoe9d61b02018-08-20 21:09:07 -07003113# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
3114# compatibility, in case device-specific Makefiles still refer to the old name.
3115INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
3116
Doug Zongker73ef8252009-07-23 15:12:53 -07003117# The system partition needs room for the recovery image as well. We
3118# now store the recovery image as a binary patch using the boot image
3119# as the source (since they are very similar). Generate the patch so
3120# we can see how big it's going to be, and include that in the system
3121# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07003122ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07003123ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07003124ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08003125ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08003126diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
3127else
3128diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
3129endif
Doug Zongker73ef8252009-07-23 15:12:53 -07003130intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
3131RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08003132$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
3133$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00003134 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07003135 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003136 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07003137 @echo "Construct recovery from boot"
3138 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07003139 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07003140else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
3141RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07003142endif # BOARD_USES_FULL_RECOVERY_IMAGE
3143endif # INSTALLED_RECOVERYIMAGE_TARGET
3144endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07003145
Yifan Hong9a3cad92020-04-27 19:06:59 -07003146$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003147 @echo "Install system fs image: $@"
3148 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003149 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003150
Bob Badour879cfa82021-04-15 10:41:38 -07003151$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
3152$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
3153
Tao Baoe9d61b02018-08-20 21:09:07 -07003154systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003155
Bob Badour70c07dd2022-02-12 15:39:22 -08003156SYSTEM_NOTICE_DEPS += $(INSTALLED_SYSTEMIMAGE_TARGET)
Bob Badour879cfa82021-04-15 10:41:38 -07003157
The Android Open Source Project88b60792009-03-03 19:28:42 -08003158.PHONY: systemimage-nodeps snod
3159systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07003160 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003161 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07003162 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00003163 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08003164ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00003165 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08003166endif
3167
Dan Willemsen67495202019-01-16 12:42:05 -08003168endif # BUILDING_SYSTEM_IMAGE
3169
Anton Hansson30e061b2018-11-12 13:36:46 +00003170.PHONY: sync syncsys
3171sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07003172
Ying Wang3a61eeb2016-03-11 10:32:01 -08003173# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07003174# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07003175.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07003176platform:
3177 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07003178
3179.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07003180platform-java:
3181 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07003182
Ying Wang3a61eeb2016-03-11 10:32:01 -08003183# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003184# data partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003185INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_DATA)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003186INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003187 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003188
Dan Willemsen67495202019-01-16 12:42:05 -08003189ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07003190userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003191 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07003192BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
3193
Ying Wangbd93d422011-10-28 17:02:30 -07003194define build-userdataimage-target
3195 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
3196 @mkdir -p $(TARGET_OUT_DATA)
3197 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003198 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003199 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003200 $(BUILD_IMAGE) \
3201 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
3202 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
3203 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07003204endef
3205
Joe Onorato64d85d02009-04-09 19:31:12 -07003206# We just build this directly to the install location.
3207INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003208INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
3209 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003210 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003211$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003212 $(build-userdataimage-target)
3213
Bob Badour70c07dd2022-02-12 15:39:22 -08003214$(call declare-1p-container,$(INSTALLED_USERDATAIMAGE_TARGET),)
3215$(call declare-container-license-deps,$(INSTALLED_USERDATAIMAGE_TARGET),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS),$(PRODUCT_OUT)/:/)
3216
3217UNMOUNTED_NOTICE_DEPS += $(INSTALLED_USERDATAIMAGE_TARGET)
3218
The Android Open Source Project88b60792009-03-03 19:28:42 -08003219.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07003220userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003221 $(build-userdataimage-target)
3222
Dan Willemsen67495202019-01-16 12:42:05 -08003223endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07003224
Andreas Gampe039b5c72017-03-24 16:06:31 -07003225# ASAN libraries in the system image - build rule.
3226ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
3227 $(TARGET_OUT_SHARED_LIBRARIES) \
3228 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
3229 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
3230 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07003231# Extra options: Enforce the system user for the files to avoid having to change ownership.
3232ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07003233# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
3234# enough space.
3235$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07003236 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 -07003237
The Android Open Source Project88b60792009-03-03 19:28:42 -08003238# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04003239# partition table image
3240ifdef BOARD_BPT_INPUT_FILES
3241
3242BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003243BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04003244
3245INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
3246 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003247 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04003248 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
3249
3250ifdef BOARD_BPT_DISK_SIZE
3251INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
3252endif
3253
3254define build-bptimage-target
3255 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
3256 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
3257endef
3258
3259INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003260$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
3261 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
3262
David Zeuthen25328622016-04-08 15:08:03 -04003263$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
3264 $(build-bptimage-target)
3265
Bob Badour70c07dd2022-02-12 15:39:22 -08003266$(call declare-1p-container,$(INSTALLED_BPTIMAGE_TARGET),)
3267$(call declare-container-license-deps,$(INSTALLED_BPTIMAGE_TARGET),$(BOARD_BPT_INPUT_FILES),$(PRODUCT_OUT)/:/)
3268
3269UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BPTIMAGE_TARGET)
3270
David Zeuthen25328622016-04-08 15:08:03 -04003271.PHONY: bptimage-nodeps
3272bptimage-nodeps:
3273 $(build-bptimage-target)
3274
3275endif # BOARD_BPT_INPUT_FILES
3276
3277# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07003278# cache partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003279INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_CACHE)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003280ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003281INTERNAL_CACHEIMAGE_FILES := \
3282 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
3283
3284cacheimage_intermediates := \
3285 $(call intermediates-dir-for,PACKAGING,cache)
3286BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
3287
3288define build-cacheimage-target
3289 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
3290 @mkdir -p $(TARGET_OUT_CACHE)
3291 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003292 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003293 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003294 $(BUILD_IMAGE) \
3295 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
3296 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
3297 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07003298endef
3299
3300# We just build this directly to the install location.
3301INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003302$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07003303 $(build-cacheimage-target)
3304
Bob Badour70c07dd2022-02-12 15:39:22 -08003305$(call declare-1p-container,$(INSTALLED_CACHEIMAGE_TARGET),)
3306$(call declare-container-license-deps,$(INSTALLED_CACHEIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES),$(PRODUCT_OUT)/:/)
3307
3308UNMOUNTED_NOTICE_DEPS += $(INSTALLED_CACHEIMAGE_TARGET)
3309
Ying Wang9f8e8db2011-11-04 11:37:01 -07003310.PHONY: cacheimage-nodeps
3311cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3312 $(build-cacheimage-target)
3313
Dan Willemsen67495202019-01-16 12:42:05 -08003314else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07003315# we need to ignore the broken cache link when doing the rsync
3316IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08003317endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003318
David Zeuthen0eb10972016-09-28 17:55:27 -04003319# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07003320# system_other partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003321INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_OTHER)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003322ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003323ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07003324# Marker file to identify that odex files are installed
3325INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
3326ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
3327$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
3328 $(hide) touch $@
Bob Badour2f66fd12022-03-09 17:30:24 -08003329
3330$(call declare-0p-target,$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER))
Alex Light4e358ab2016-06-16 14:47:10 -07003331endif
3332
Alex Light4e358ab2016-06-16 14:47:10 -07003333INTERNAL_SYSTEMOTHERIMAGE_FILES := \
3334 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003335 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07003336
Colin Cross6db5b0e2018-11-16 21:26:33 -08003337# system_other dex files are installed as a side-effect of installing system image files
3338INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
3339
Alex Light4e358ab2016-06-16 14:47:10 -07003340INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07003341INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
3342$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003343$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07003344 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003345 mkdir -p $(dir $@)
3346 rm -f $@
3347 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
3348 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07003349
Bob Badour70c07dd2022-02-12 15:39:22 -08003350$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEMOTHER)))
Bob Badour5acd4362022-04-12 18:31:35 -07003351$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEMOTHER)))
Bob Badour70c07dd2022-02-12 15:39:22 -08003352
Bowgo Tsai867ab662019-01-29 13:30:18 +08003353# Determines partition size for system_other.img.
3354ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
3355ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
3356INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
3357endif
3358endif
3359
3360ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
3361INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
3362endif
3363
Alex Light4e358ab2016-06-16 14:47:10 -07003364systemotherimage_intermediates := \
3365 $(call intermediates-dir-for,PACKAGING,system_other)
3366BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
3367
3368# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
3369define build-systemotherimage-target
3370 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
3371 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
3372 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003373 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003374 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003375 $(BUILD_IMAGE) \
3376 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
3377 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
3378 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07003379endef
3380
3381# We just build this directly to the install location.
3382INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003383ifneq (true,$(SANITIZE_LITE))
3384# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07003385$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
3386 $(build-systemotherimage-target)
Bob Badour70c07dd2022-02-12 15:39:22 -08003387
3388$(call declare-1p-container,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),)
3389$(call declare-container-license-deps,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES),$(PRODUCT_OUT)/:/)
3390
3391UNMOUNTED_NOTICE_DEPS += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003392endif
Alex Light4e358ab2016-06-16 14:47:10 -07003393
3394.PHONY: systemotherimage-nodeps
3395systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3396 $(build-systemotherimage-target)
3397
Dan Willemsen67495202019-01-16 12:42:05 -08003398endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003399
3400
3401# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07003402# vendor partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003403INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003404ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07003405INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07003406 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003407 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07003408
Ying Wang8da19e32015-09-15 14:22:12 -07003409
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003410# Create symlink /vendor/odm to /odm if necessary.
3411ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003412 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003413endif
3414
Yifan Honge51dff22020-06-23 17:26:57 -07003415# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
3416# /vendor/lib/modules -> /vendor_dlkm/lib/modules
3417#
3418# On devices with a vendor_dlkm partition,
3419# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
3420# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
3421# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3422# are hidden.
3423# On devices without a vendor_dlkm partition,
3424# - /vendor/lib/modules stores vendor DLKMs directly.
3425# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
3426# See system/core/rootdir/Android.mk for a list of created symlinks.
3427# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
3428# are not guaranteed to exist on all devices.
3429ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003430 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/lib/modules,/vendor_dlkm/lib/modules,vendor_dlkm.img)
Yifan Honge51dff22020-06-23 17:26:57 -07003431endif
3432
Colin Crossbd382142020-08-26 15:08:57 -07003433INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
3434INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3435$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
3436$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3437 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003438 mkdir -p $(dir $@)
3439 rm -f $@
3440 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
3441 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07003442
Bob Badour5acd4362022-04-12 18:31:35 -07003443$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR))
3444$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR))
Bob Badour70c07dd2022-02-12 15:39:22 -08003445
Ying Wanga0febe52013-03-20 11:02:05 -07003446vendorimage_intermediates := \
3447 $(call intermediates-dir-for,PACKAGING,vendor)
3448BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003449define build-vendorimage-target
3450 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3451 @mkdir -p $(TARGET_OUT_VENDOR)
3452 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003453 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003454 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003455 $(BUILD_IMAGE) \
3456 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3457 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003458 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003459endef
3460
3461# We just build this directly to the install location.
3462INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003463$(INSTALLED_VENDORIMAGE_TARGET): \
3464 $(INTERNAL_USERIMAGES_DEPS) \
3465 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003466 $(INSTALLED_FILES_FILE_VENDOR) \
3467 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003468 $(build-vendorimage-target)
3469
Bob Badour70c07dd2022-02-12 15:39:22 -08003470VENDOR_NOTICE_DEPS += $(INSTALLED_VENDORIMAGE_TARGET)
3471
Bob Badour5acd4362022-04-12 18:31:35 -07003472$(call declare-container-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)
Bob Badour70c07dd2022-02-12 15:39:22 -08003473$(call declare-container-license-deps,$(INSTALLED_VENDORIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(RECOVERY_FROM_BOOT_PATH),$(PRODUCT_OUT)/:/)
3474
Steven Morelanda2e734d2017-03-07 12:10:09 -08003475.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003476vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003477 $(build-vendorimage-target)
3478
Colin Cross91a52272017-06-20 16:57:52 -07003479sync: $(INTERNAL_VENDORIMAGE_FILES)
3480
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003481else ifdef BOARD_PREBUILT_VENDORIMAGE
3482INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3483$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
Bob Badour5acd4362022-04-12 18:31:35 -07003484$(if $(strip $(ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC)),,\
3485 $(if $(strip $(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
Bob Badourba337242022-05-27 19:40:41 -07003486 $(call declare-copy-target-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_PREBUILT_VENDORIMAGE)),\
Bob Badour5acd4362022-04-12 18:31:35 -07003487 $(call declare-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)))
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003488endif
Ying Wanga0febe52013-03-20 11:02:05 -07003489
Ying Wang9f8e8db2011-11-04 11:37:01 -07003490# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003491# product partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003492INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_PRODUCT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003493ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003494INTERNAL_PRODUCTIMAGE_FILES := \
3495 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003496 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003497
3498INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003499INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3500$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003501$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003502 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003503 mkdir -p $(dir $@)
3504 rm -f $@
3505 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3506 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003507
Bob Badour5acd4362022-04-12 18:31:35 -07003508$(call declare-0p-target,$(INSTALLED_FILES_FILE_PRODUCT))
3509$(call declare-0p-target,$(INSTALLED_FILES_JSON_PRODUCT))
Bob Badour70c07dd2022-02-12 15:39:22 -08003510
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003511productimage_intermediates := \
3512 $(call intermediates-dir-for,PACKAGING,product)
3513BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3514define build-productimage-target
3515 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3516 @mkdir -p $(TARGET_OUT_PRODUCT)
3517 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003518 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003519 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003520 $(BUILD_IMAGE) \
3521 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3522 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3523 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003524endef
3525
3526# We just build this directly to the install location.
3527INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003528$(INSTALLED_PRODUCTIMAGE_TARGET): \
3529 $(INTERNAL_USERIMAGES_DEPS) \
3530 $(INTERNAL_PRODUCTIMAGE_FILES) \
3531 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003532 $(build-productimage-target)
3533
Bob Badour70c07dd2022-02-12 15:39:22 -08003534PRODUCT_NOTICE_DEPS += $(INSTALLED_PRODUCTIMAGE_TARGET)
3535
3536$(call declare-1p-container,$(INSTALLED_PRODUCTIMAGE_TARGET),)
3537$(call declare-container-license-deps,$(INSTALLED_PRODUCTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT),$(PRODUCT_OUT)/:/)
3538
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003539.PHONY: productimage-nodeps pnod
3540productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3541 $(build-productimage-target)
3542
3543sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3544
3545else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3546INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3547$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3548endif
3549
3550# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003551# system_ext partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003552INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_EXT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Justin Yun6151e3f2019-06-25 15:58:13 +09003553ifdef BUILDING_SYSTEM_EXT_IMAGE
3554INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3555 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003556 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003557
Justin Yun6151e3f2019-06-25 15:58:13 +09003558INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3559INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3560$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3561$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003562 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003563 mkdir -p $(dir $@)
3564 rm -f $@
3565 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3566 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003567
Bob Badour5acd4362022-04-12 18:31:35 -07003568$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_EXT))
3569$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_EXT))
Bob Badour70c07dd2022-02-12 15:39:22 -08003570
Justin Yun6151e3f2019-06-25 15:58:13 +09003571system_extimage_intermediates := \
3572 $(call intermediates-dir-for,PACKAGING,system_ext)
3573BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3574define build-system_extimage-target
3575 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3576 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3577 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3578 $(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 -07003579 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003580 $(BUILD_IMAGE) \
3581 $(TARGET_OUT_SYSTEM_EXT) \
3582 $(system_extimage_intermediates)/system_ext_image_info.txt \
3583 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3584 $(TARGET_OUT)
3585 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003586endef
3587
3588# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003589INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003590$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3591 $(INTERNAL_USERIMAGES_DEPS) \
3592 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3593 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003594 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003595
Bob Badour70c07dd2022-02-12 15:39:22 -08003596SYSTEM_EXT_NOTICE_DEPS += $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
3597
3598$(call declare-1p-container,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),)
3599$(call declare-container-license-deps,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_EXT),$(PRODUCT_OUT)/:/)
3600
Justin Yun6151e3f2019-06-25 15:58:13 +09003601.PHONY: systemextimage-nodeps senod
3602systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3603 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003604
Justin Yun6151e3f2019-06-25 15:58:13 +09003605sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003606
Justin Yun6151e3f2019-06-25 15:58:13 +09003607else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3608INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3609$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003610endif
3611
3612# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003613# odm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003614INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003615ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003616INTERNAL_ODMIMAGE_FILES := \
3617 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003618 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003619
Colin Crossbd382142020-08-26 15:08:57 -07003620# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3621# /odm/lib/modules -> /odm_dlkm/lib/modules
3622#
3623# On devices with a odm_dlkm partition,
3624# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3625# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3626# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3627# are hidden.
3628# On devices without a odm_dlkm partition,
3629# - /odm/lib/modules stores odm DLKMs directly.
3630# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3631# See system/core/rootdir/Android.mk for a list of created symlinks.
3632# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3633# are not guaranteed to exist on all devices.
3634ifdef BOARD_USES_ODM_DLKMIMAGE
3635 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3636endif
3637
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003638INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3639INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3640$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003641$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003642 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003643 mkdir -p $(dir $@)
3644 rm -f $@
3645 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3646 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003647
Bob Badour5acd4362022-04-12 18:31:35 -07003648$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM))
3649$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM))
Bob Badour70c07dd2022-02-12 15:39:22 -08003650
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003651odmimage_intermediates := \
3652 $(call intermediates-dir-for,PACKAGING,odm)
3653BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3654define build-odmimage-target
3655 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3656 @mkdir -p $(TARGET_OUT_ODM)
3657 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003658 $(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
3659 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003660 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003661 $(BUILD_IMAGE) \
3662 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3663 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3664 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003665endef
3666
3667# We just build this directly to the install location.
3668INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003669$(INSTALLED_ODMIMAGE_TARGET): \
3670 $(INTERNAL_USERIMAGES_DEPS) \
3671 $(INTERNAL_ODMIMAGE_FILES) \
3672 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003673 $(build-odmimage-target)
3674
Bob Badour70c07dd2022-02-12 15:39:22 -08003675ODM_NOTICE_DEPS += $(INSTALLED_ODMIMAGE_TARGET)
3676
3677$(call declare-1p-container,$(INSTALLED_ODMIMAGE_TARGET),)
3678$(call declare-container-license-deps,$(INSTALLED_ODMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM),$(PRODUCT_OUT)/:/)
3679
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003680.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003681odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003682 $(build-odmimage-target)
3683
3684sync: $(INTERNAL_ODMIMAGE_FILES)
3685
3686else ifdef BOARD_PREBUILT_ODMIMAGE
3687INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3688$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3689endif
3690
3691# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003692# vendor_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003693INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003694ifdef BUILDING_VENDOR_DLKM_IMAGE
3695INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3696 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003697 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003698
3699INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3700INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3701$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3702$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3703 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003704 mkdir -p $(dir $@)
3705 rm -f $@
3706 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3707 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003708
Bob Badour5acd4362022-04-12 18:31:35 -07003709$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DLKM))
3710$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DLKM))
Bob Badour70c07dd2022-02-12 15:39:22 -08003711
Yifan Hongcfb917a2020-05-07 14:58:20 -07003712vendor_dlkmimage_intermediates := \
3713 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3714BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3715define build-vendor_dlkmimage-target
3716 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3717 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3718 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003719 $(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
3720 vendor_dlkm, skip_fsck=true)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003721 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3722 $(BUILD_IMAGE) \
3723 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3724 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3725 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3726endef
3727
3728# We just build this directly to the install location.
3729INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3730$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3731 $(INTERNAL_USERIMAGES_DEPS) \
3732 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3733 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3734 $(build-vendor_dlkmimage-target)
3735
Bob Badour70c07dd2022-02-12 15:39:22 -08003736VENDOR_DLKM_NOTICE_DEPS += $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
3737
3738$(call declare-1p-container,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),)
3739$(call declare-container-license-deps,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR_DLKM),$(PRODUCT_OUT)/:/)
3740
Yifan Hongcfb917a2020-05-07 14:58:20 -07003741.PHONY: vendor_dlkmimage-nodeps vdnod
3742vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3743 $(build-vendor_dlkmimage-target)
3744
3745sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3746
3747else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3748INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3749$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3750endif
3751
3752# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003753# odm_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003754INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003755ifdef BUILDING_ODM_DLKM_IMAGE
3756INTERNAL_ODM_DLKMIMAGE_FILES := \
3757 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003758 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003759
3760INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3761INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3762$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3763$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3764 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003765 mkdir -p $(dir $@)
3766 rm -f $@
3767 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3768 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003769
Bob Badour5acd4362022-04-12 18:31:35 -07003770$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM_DLKM))
3771$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM_DLKM))
Bob Badour70c07dd2022-02-12 15:39:22 -08003772
Yifan Hongf496f1b2020-07-15 16:52:59 -07003773odm_dlkmimage_intermediates := \
3774 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3775BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3776define build-odm_dlkmimage-target
3777 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3778 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3779 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003780 $(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
3781 odm_dlkm, skip_fsck=true)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003782 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3783 $(BUILD_IMAGE) \
3784 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3785 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3786 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3787endef
3788
3789# We just build this directly to the install location.
3790INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3791$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3792 $(INTERNAL_USERIMAGES_DEPS) \
3793 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3794 $(INSTALLED_FILES_FILE_ODM_DLKM)
3795 $(build-odm_dlkmimage-target)
3796
Bob Badour70c07dd2022-02-12 15:39:22 -08003797ODM_DLKM_NOTICE_DEPS += $(INSTALLED_ODM_DLKMIMAGE_TARGET)
3798
3799$(call declare-1p-container,$(INSTALLED_ODM_DLKMIMAGE_TARGET),)
3800$(call declare-container-license-deps,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM_DLKM),$(PRODUCT_OUT)/:/)
3801
Yifan Hongf496f1b2020-07-15 16:52:59 -07003802.PHONY: odm_dlkmimage-nodeps odnod
3803odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3804 $(build-odm_dlkmimage-target)
3805
3806sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3807
3808else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3809INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3810$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3811endif
3812
Ramji Jiyani13a41372022-01-27 07:05:08 +00003813# -----------------------------------------------------------------
3814# system_dlkm partition image
3815
Colin Cross79a76ec2022-03-21 15:06:11 -07003816INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Ramji Jiyani13a41372022-01-27 07:05:08 +00003817ifdef BUILDING_SYSTEM_DLKM_IMAGE
3818
3819INTERNAL_SYSTEM_DLKMIMAGE_FILES := \
3820 $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,\
3821 $(ALL_DEFAULT_INSTALLED_MODULES))
3822
3823INSTALLED_FILES_FILE_SYSTEM_DLKM := $(PRODUCT_OUT)/installed-files-system_dlkm.txt
3824INSTALLED_FILES_JSON_SYSTEM_DLKM := $(INSTALLED_FILES_FILE_SYSTEM_DLKM:.txt=.json)
3825$(INSTALLED_FILES_FILE_SYSTEM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_DLKM)
3826$(INSTALLED_FILES_FILE_SYSTEM_DLKM): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3827 @echo Installed file list: $@
3828 mkdir -p $(dir $@)
3829 if [ -d "$(BOARD_SYSTEM_DLKM_SRC)" ]; then rsync -rupE $(BOARD_SYSTEM_DLKM_SRC)/ $(TARGET_OUT_SYSTEM_DLKM); fi
3830 rm -f $@
3831 $(FILESLIST) $(TARGET_OUT_SYSTEM_DLKM) > $(@:.txt=.json)
3832 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3833
Bob Badour5acd4362022-04-12 18:31:35 -07003834$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_DLKM))
3835$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_DLKM))
Bob Badour70c07dd2022-02-12 15:39:22 -08003836
Ramji Jiyani13a41372022-01-27 07:05:08 +00003837system_dlkmimage_intermediates := \
3838 $(call intermediates-dir-for,PACKAGING,system_dlkm)
3839BUILT_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3840define build-system_dlkmimage-target
3841 $(call pretty,"Target system_dlkm fs image: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)")
3842 @mkdir -p $(TARGET_OUT_SYSTEM_DLKM)
3843 @mkdir -p $(system_dlkmimage_intermediates) && rm -rf $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt
3844 $(call generate-image-prop-dictionary, $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt, \
3845 system_dlkm, skip_fsck=true)
3846 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3847 $(BUILD_IMAGE) \
3848 $(TARGET_OUT_SYSTEM_DLKM) $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt \
3849 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3850 $(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
3851endef
3852
3853# We just build this directly to the install location.
3854INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
3855$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): \
3856 $(INTERNAL_USERIMAGES_DEPS) \
3857 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
3858 $(INSTALLED_FILES_FILE_SYSTEM_DLKM)
3859 $(build-system_dlkmimage-target)
3860
3861.PHONY: system_dlkmimage-nodeps sdnod
3862system_dlkmimage-nodeps sdnod: | $(INTERNAL_USERIMAGES_DEPS)
3863 $(build-system_dlkmimage-target)
3864
3865sync: $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
3866
3867else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
3868INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3869$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_DLKMIMAGE),$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)))
3870endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07003871
3872# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003873# dtbo image
3874ifdef BOARD_PREBUILT_DTBOIMAGE
3875INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3876
3877ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003878$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003879 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3880 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003881 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003882 $(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003883 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3884 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08003885
3886$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_TARGET),)
3887$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_TARGET),$(BOARD_PREBUILT_DTBOIMAGE),$(PRODUCT_OUT)/:/)
3888
3889UNMOUNTED_NOTICE_DEPS += $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003890else
3891$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3892 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3893endif
3894
Tao Bao0da43472018-08-22 22:53:41 -07003895endif # BOARD_PREBUILT_DTBOIMAGE
3896
Andrew Scull9b103e42020-11-29 14:04:28 +00003897# -----------------------------------------------------------------
3898# Protected VM firmware image
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003899ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00003900INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00003901INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
Pierre-Clément Tosi3bda0d62021-09-21 13:49:35 +02003902INTERNAL_PREBUILT_PVMFWIMAGE := packages/modules/Virtualization/pvmfw/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00003903INTERNAL_PVMFW_EMBEDDED_AVBKEY := external/avb/test/data/testkey_rsa4096_pub.bin
Andrew Scull9b103e42020-11-29 14:04:28 +00003904
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003905ifdef BOARD_PREBUILT_PVMFWIMAGE
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003906PREBUILT_PVMFWIMAGE_TARGET := $(BOARD_PREBUILT_PVMFWIMAGE)
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01003907else
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003908PREBUILT_PVMFWIMAGE_TARGET := $(INTERNAL_PREBUILT_PVMFWIMAGE)
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003909endif
Andrew Scull9b103e42020-11-29 14:04:28 +00003910
3911ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003912$(INSTALLED_PVMFWIMAGE_TARGET): $(PREBUILT_PVMFWIMAGE_TARGET) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH)
3913 cp $< $@
Andrew Scull9b103e42020-11-29 14:04:28 +00003914 $(AVBTOOL) add_hash_footer \
3915 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003916 $(call get-partition-size-argument,$(BOARD_PVMFWIMAGE_PARTITION_SIZE)) \
Andrew Scull9b103e42020-11-29 14:04:28 +00003917 --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \
3918 $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08003919
3920$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
3921$(call declare-container-license-deps,$(INSTALLED_PVMFWIMAGE_TARGET),$(PREBUILT_PVMFWIMAGE_TARGET),$(PRODUCT_OUT)/:/)
3922
3923UNMOUNTED_NOTICE_DEPS += $(INSTALLED_PVMFWIMAGE_TARGET)
Andrew Scull9b103e42020-11-29 14:04:28 +00003924else
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003925$(eval $(call copy-one-file,$(PREBUILT_PVMFWIMAGE_TARGET),$(INSTALLED_PVMFWIMAGE_TARGET)))
Andrew Scull9b103e42020-11-29 14:04:28 +00003926endif
3927
Andrew Scullbbc930b2022-02-17 22:34:27 +00003928$(INSTALLED_PVMFWIMAGE_TARGET): $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)
3929
3930$(eval $(call copy-one-file,$(INTERNAL_PVMFW_EMBEDDED_AVBKEY),$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)))
3931
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003932endif # BOARD_USES_PVMFWIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00003933
Tao Bao0da43472018-08-22 22:53:41 -07003934# Returns a list of image targets corresponding to the given list of partitions. For example, it
3935# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3936# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003937# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003938define images-for-partitions
Bowgo Tsai4f62aa02022-01-04 14:21:39 +08003939$(strip $(foreach item,$(1),\
3940 $(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
3941 $(if $(filter $(item),init_boot),$(INSTALLED_INIT_BOOT_IMAGE_TARGET),\
Ramji Jiyani13a41372022-01-27 07:05:08 +00003942 $(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))))
Tao Bao0da43472018-08-22 22:53:41 -07003943endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003944
3945# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003946# custom images
3947INSTALLED_CUSTOMIMAGES_TARGET :=
3948
3949ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3950INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3951
3952# Sign custom image.
3953# $(1): the prebuilt custom image.
3954# $(2): the mount point of the prebuilt custom image.
3955# $(3): the signed custom image target.
3956define sign_custom_image
3957$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3958 @echo Target custom image: $(3)
3959 mkdir -p $(dir $(3))
3960 cp $(1) $(3)
3961ifeq ($(BOARD_AVB_ENABLE),true)
3962 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3963 $(AVBTOOL) add_hashtree_footer \
3964 --image $(3) \
3965 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3966 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003967 $(call get-partition-size-argument,$(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE)) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003968 --partition_name $(2) \
3969 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3970 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3971endif
3972INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3973endef
3974
3975$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3976 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3977 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3978endif
3979
3980# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003981# vbmeta image
3982ifeq ($(BOARD_AVB_ENABLE),true)
3983
3984BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003985AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003986
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003987ifdef BOARD_AVB_KEY_PATH
3988$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3989else
3990# If key path isn't specified, use the 4096-bit test key.
3991BOARD_AVB_ALGORITHM := SHA256_RSA4096
3992BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3993endif
3994
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003995# AVB signing for system_other.img.
3996ifdef BUILDING_SYSTEM_OTHER_IMAGE
3997ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3998$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3999else
4000# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
4001BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
4002BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
4003endif
4004
Bowgo Tsaie4544b12019-02-27 10:15:51 +08004005$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
4006 @echo Extracting system_other avb key: $@
4007 @rm -f $@
4008 @mkdir -p $(dir $@)
4009 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08004010
Bob Badour70c07dd2022-02-12 15:39:22 -08004011$(eval $(call declare-0p-target,$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET),))
4012
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004013ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
4014BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
4015endif
4016
4017BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
4018endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
4019
Tao Bao744c4c72018-08-20 21:09:07 -07004020INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07004021 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07004022 $(BOARD_AVB_VBMETA_VENDOR)
4023
4024# Not allowing the same partition to appear in multiple groups.
4025ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07004026 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07004027endif
4028
cfig1aeef722019-09-20 22:45:06 +08004029# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
4030# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
4031# details.
Yifan Hong65afc072020-04-17 10:08:10 -07004032ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08004033ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4034$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07004035 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08004036 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
4037endif
4038endif
4039
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004040# Appends os version as a AVB property descriptor.
4041SYSTEM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4042BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
4043 --prop com.android.build.system.os_version:$(SYSTEM_OS_VERSION)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004044
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004045PRODUCT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4046BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
4047 --prop com.android.build.product.os_version:$(PRODUCT_OS_VERSION)
4048
4049SYSTEM_EXT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4050BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
4051 --prop com.android.build.system_ext.os_version:$(SYSTEM_EXT_OS_VERSION)
4052
4053INIT_BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4054BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4055 --prop com.android.build.init_boot.os_version:$(INIT_BOOT_OS_VERSION)
4056
4057BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4058BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4059 --prop com.android.build.boot.os_version:$(BOOT_OS_VERSION)
4060
4061VENDOR_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4062BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4063 --prop com.android.build.vendor.os_version:$(VENDOR_OS_VERSION)
4064
4065ODM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4066BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4067 --prop com.android.build.odm.os_version:$(ODM_OS_VERSION)
4068
4069VENDOR_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4070BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4071 --prop com.android.build.vendor_dlkm.os_version:$(VENDOR_DLKM_OS_VERSION)
4072
4073ODM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4074BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4075 --prop com.android.build.odm_dlkm.os_version:$(ODM_DLKM_OS_VERSION)
4076
4077SYSTEM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4078BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4079 --prop com.android.build.system_dlkm.os_version:$(SYSTEM_DLKM_OS_VERSION)
4080
4081# Appends fingerprint and security patch level as a AVB property descriptor.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004082BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004083 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004084 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
4085
4086BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004087 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004088 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
4089
Justin Yun6151e3f2019-06-25 15:58:13 +09004090BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004091 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004092 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004093
Bowgo Tsai9b548012019-05-14 16:57:03 +08004094BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsai8c7f8202022-02-22 14:47:45 +08004095 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004096
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004097BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004098 --prop com.android.build.init_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004099
Tao Bao19b02fe2019-10-09 00:04:28 -07004100BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
4101 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4102
Lucas Weif57333f2022-02-24 10:30:15 +08004103BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS += \
4104 --prop com.android.build.vendor_kernel_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4105
Tao Bao19b02fe2019-10-09 00:04:28 -07004106BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
4107 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4108
Bowgo Tsai9b548012019-05-14 16:57:03 +08004109BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004110 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004111
4112BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004113 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004114
Yifan Hongcfb917a2020-05-07 14:58:20 -07004115BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004116 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004117
Yifan Hongf496f1b2020-07-15 16:52:59 -07004118BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004119 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004120
Ramji Jiyani13a41372022-01-27 07:05:08 +00004121BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004122 --prop com.android.build.system_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004123
Tao Bao19b02fe2019-10-09 00:04:28 -07004124BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
4125 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4126
Andrew Scull9b103e42020-11-29 14:04:28 +00004127BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4128 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4129
Bowgo Tsai9b548012019-05-14 16:57:03 +08004130# The following vendor- and odm-specific images needs explicit SPL set per board.
Devin Moore380d9e42021-11-04 19:01:19 +00004131# TODO(b/210875415) Is this security_patch property used? Should it be removed from
4132# boot.img when there is no platform ramdisk included in it?
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004133ifdef BOOT_SECURITY_PATCH
4134BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4135 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004136endif
4137
4138ifdef INIT_BOOT_SECURITY_PATCH
4139BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4140 --prop com.android.build.init_boot.security_patch:$(INIT_BOOT_SECURITY_PATCH)
4141else ifdef BOOT_SECURITY_PATCH
Devin Moore380d9e42021-11-04 19:01:19 +00004142BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4143 --prop com.android.build.init_boot.security_patch:$(BOOT_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004144endif
4145
4146ifdef VENDOR_SECURITY_PATCH
4147BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4148 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
4149endif
4150
4151ifdef ODM_SECURITY_PATCH
4152BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4153 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
4154endif
4155
Yifan Hongcfb917a2020-05-07 14:58:20 -07004156ifdef VENDOR_DLKM_SECURITY_PATCH
4157BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4158 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
4159endif
4160
Yifan Hongf496f1b2020-07-15 16:52:59 -07004161ifdef ODM_DLKM_SECURITY_PATCH
4162BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4163 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
4164endif
4165
Ramji Jiyani13a41372022-01-27 07:05:08 +00004166ifdef SYSTEM_DLKM_SECURITY_PATCH
4167BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4168 --prop com.android.build.system_dlkm.security_patch:$(SYSTEM_DLKM_SECURITY_PATCH)
4169endif
4170
Andrew Scull9b103e42020-11-29 14:04:28 +00004171ifdef PVMFW_SECURITY_PATCH
4172BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4173 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
4174endif
4175
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004176BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Devin Moore380d9e42021-11-04 19:01:19 +00004177INIT_BOOT_FOOTER_ARGS := BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07004178VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Lucas Weif57333f2022-02-24 10:30:15 +08004179VENDOR_KERNEL_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004180DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00004181PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004182SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
4183VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05004184RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004185PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09004186SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004187ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07004188VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07004189ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Ramji Jiyani13a41372022-01-27 07:05:08 +00004190SYSTEM_DLKM_FOOTER_ARGS := BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004191
Tao Bao0da43472018-08-22 22:53:41 -07004192# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004193# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07004194define _check-and-set-avb-chain-args
4195$(eval part := $(1))
4196$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004197
4198$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
4199$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
4200$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
4201$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4202$(if $($(_key_path)),,$(error $(_key_path) is not defined))
4203$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
4204$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
4205$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4206
4207# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
4208$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
4209$(eval $(_signing_args) := \
4210 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
4211
cfig1aeef722019-09-20 22:45:06 +08004212# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
4213# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07004214$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08004215 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4216 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004217
Tao Bao744c4c72018-08-20 21:09:07 -07004218# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07004219# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07004220$(if $(filter $(part),$(part:vbmeta_%=%)),\
4221 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
4222 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004223endef
4224
Tao Bao0da43472018-08-22 22:53:41 -07004225# Checks and sets the required build variables for an AVB partition. The partition will be
4226# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07004227# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
4228# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004229# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
4230# but vbmeta would capture the image descriptor of only the first boot
4231# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07004232# $(1): Partition name, e.g. boot or system.
4233define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07004234$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07004235$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07004236 $(if $(_in_chained_vbmeta),\
4237 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07004238 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07004239 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004240 $(if $(filter boot,$(1)),\
4241 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4242 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
4243 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4244 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07004245endef
4246
Hongguang Chenf23364d2020-04-27 18:36:36 -07004247# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
4248# $(1): the custom partition to enable AVB chain.
4249define check-and-set-custom-avb-chain-args
4250$(eval part := $(1))
4251$(eval PART=$(call to-upper,$(part)))
4252$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4253$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4254
4255INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4256 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
4257endef
4258
Tao Baob1a2e352018-08-14 16:17:12 -07004259ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004260$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07004261endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004262
Devin Moore380d9e42021-11-04 19:01:19 +00004263ifdef INSTALLED_INIT_BOOT_IMAGE_TARGET
4264$(eval $(call check-and-set-avb-args,init_boot))
4265endif
4266
Steve Mucklee1b10862019-07-10 10:49:37 -07004267ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4268$(eval $(call check-and-set-avb-args,vendor_boot))
4269endif
4270
Lucas Weif57333f2022-02-24 10:30:15 +08004271ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
4272$(eval $(call check-and-set-avb-args,vendor_kernel_boot))
4273endif
4274
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004275ifdef INSTALLED_SYSTEMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004276$(eval $(call check-and-set-avb-args,system))
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004277endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004278
4279ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004280$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004281endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004282
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004283ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004284$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004285endif
4286
Justin Yun6151e3f2019-06-25 15:58:13 +09004287ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4288$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07004289endif
4290
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004291ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004292$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004293endif
4294
Yifan Hongcfb917a2020-05-07 14:58:20 -07004295ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
4296$(eval $(call check-and-set-avb-args,vendor_dlkm))
4297endif
4298
Yifan Hongf496f1b2020-07-15 16:52:59 -07004299ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
4300$(eval $(call check-and-set-avb-args,odm_dlkm))
4301endif
4302
Ramji Jiyani13a41372022-01-27 07:05:08 +00004303ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
4304$(eval $(call check-and-set-avb-args,system_dlkm))
4305endif
4306
Yueyao Zhu211c9012017-04-27 00:34:50 -07004307ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004308$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004309endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07004310
Andrew Scull9b103e42020-11-29 14:04:28 +00004311ifdef INSTALLED_PVMFWIMAGE_TARGET
4312$(eval $(call check-and-set-avb-args,pvmfw))
4313endif
4314
David Zeuthen8fecb282017-12-01 16:24:01 -05004315ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004316$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05004317endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08004318
David Anderson7709ab22018-10-15 14:41:34 -07004319# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
4320ifdef BOARD_AVB_VBMETA_SYSTEM
4321$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07004322endif
4323
4324ifdef BOARD_AVB_VBMETA_VENDOR
4325$(eval $(call check-and-set-avb-args,vbmeta_vendor))
4326endif
4327
Hongguang Chenf23364d2020-04-27 18:36:36 -07004328ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4329$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4330 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
4331endif
4332
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004333# Add kernel cmdline descriptor for kernel to mount system.img as root with
4334# dm-verity. This works when system.img is either chained or not-chained:
4335# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
4336# cmdline descriptor to system.img
4337# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
4338# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08004339ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07004340ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004341BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08004342endif
David Anderson8916a2a2018-09-18 15:46:59 -07004343endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08004344
Tao Bao0da43472018-08-22 22:53:41 -07004345BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07004346BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07004347BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
4348
4349ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07004350# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07004351BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07004352endif
Tao Bao0da43472018-08-22 22:53:41 -07004353
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004354ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004355BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004356endif
4357
David Anderson7709ab22018-10-15 14:41:34 -07004358ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
4359BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
4360 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07004361endif
4362
4363ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
4364BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
4365 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07004366endif
4367
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004368# $(1): the directory to extract public keys to
4369define extract-avb-chain-public-keys
4370 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
4371 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
4372 --output $(1)/boot.avbpubkey)
Devin Moore380d9e42021-11-04 19:01:19 +00004373 $(if $(BOARD_AVB_INIT_BOOT_KEY_PATH),\
4374 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_INIT_BOOT_KEY_PATH) \
4375 --output $(1)/init_boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07004376 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
4377 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
4378 --output $(1)/vendor_boot.avbpubkey)
Lucas Weif57333f2022-02-24 10:30:15 +08004379 $(if $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH),\
4380 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH) \
4381 --output $(1)/vendor_kernel_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004382 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
4383 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
4384 --output $(1)/system.avbpubkey)
4385 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
4386 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
4387 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004388 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
4389 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
4390 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09004391 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
4392 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
4393 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004394 $(if $(BOARD_AVB_ODM_KEY_PATH),\
4395 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
4396 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004397 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
4398 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
4399 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004400 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
4401 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
4402 --output $(1)/odm_dlkm.avbpubkey)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004403 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
4404 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH) \
4405 --output $(1)/system_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004406 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
4407 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
4408 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00004409 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
4410 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
4411 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05004412 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
4413 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
4414 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07004415 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
4416 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4417 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07004418 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
4419 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4420 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07004421 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
4422 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4423 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
4424 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004425endef
4426
Tao Bao744c4c72018-08-20 21:09:07 -07004427# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
4428# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07004429# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09004430# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
4431# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07004432# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004433# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07004434# $(2): Output filename.
4435define build-chained-vbmeta-image
4436 $(call pretty,"Target chained vbmeta image: $@")
4437 $(hide) $(AVBTOOL) make_vbmeta_image \
4438 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
4439 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
4440 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
4441 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
4442 --output $@
4443endef
4444
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004445ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07004446ifdef BOARD_AVB_VBMETA_SYSTEM
4447INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
4448$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004449 $(AVBTOOL) \
4450 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
4451 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07004452 $(call build-chained-vbmeta-image,vbmeta_system)
Bob Badour70c07dd2022-02-12 15:39:22 -08004453
4454$(call declare-1p-container,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET),)
4455
4456SYSTEM_NOTICE_DEPS += $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004457endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004458endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07004459
4460ifdef BOARD_AVB_VBMETA_VENDOR
4461INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
4462$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004463 $(AVBTOOL) \
4464 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
4465 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07004466 $(call build-chained-vbmeta-image,vbmeta_vendor)
Bob Badour70c07dd2022-02-12 15:39:22 -08004467
4468$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
4469
4470UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004471endif
4472
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004473define build-vbmetaimage-target
4474 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004475 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
4476 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004477 $(hide) $(AVBTOOL) make_vbmeta_image \
4478 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07004479 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004480 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
4481 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004482 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004483endef
4484
Paul Trautrim4e143232019-08-13 16:30:57 +09004485ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004486INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07004487$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4488 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
4489
David Zeuthen8fecb282017-12-01 16:24:01 -05004490$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004491 $(AVBTOOL) \
4492 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00004493 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004494 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Lucas Weif57333f2022-02-24 10:30:15 +08004495 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004496 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4497 $(INSTALLED_VENDORIMAGE_TARGET) \
4498 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004499 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004500 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004501 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004502 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004503 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004504 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004505 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004506 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004507 $(INSTALLED_RECOVERYIMAGE_TARGET) \
4508 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
4509 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
4510 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4511 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4512 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004513 $(build-vbmetaimage-target)
4514
Bob Badour70c07dd2022-02-12 15:39:22 -08004515$(call declare-1p-container,$(INSTALLED_VBMETAIMAGE_TARGET),)
4516
4517UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETAIMAGE_TARGET)
4518
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004519.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08004520vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4521 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004522vbmetaimage-nodeps:
4523 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09004524endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004525
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004526endif # BOARD_AVB_ENABLE
4527
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004528# List of files from all images
4529INTERNAL_ALLIMAGES_FILES := \
4530 $(FULL_SYSTEMIMAGE_DEPS) \
4531 $(INTERNAL_RAMDISK_FILES) \
4532 $(INTERNAL_USERDATAIMAGE_FILES) \
4533 $(INTERNAL_VENDORIMAGE_FILES) \
4534 $(INTERNAL_PRODUCTIMAGE_FILES) \
4535 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4536 $(INTERNAL_ODMIMAGE_FILES) \
4537 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4538 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004539 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004540
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004541# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004542# Check VINTF of build
4543
Ramji Jiyani13a41372022-01-27 07:05:08 +00004544# Note: vendor_dlkm, odm_dlkm, and system_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004545ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07004546
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004547intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
4548check_vintf_all_deps :=
4549
Yifan Hongaf9b0702020-01-21 12:46:57 -08004550# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
4551# because they are only used for prebuilt images.
4552check_vintf_common_srcs_patterns := \
4553 $(TARGET_OUT)/etc/vintf/% \
4554 $(TARGET_OUT_VENDOR)/etc/vintf/% \
4555 $(TARGET_OUT_ODM)/etc/vintf/% \
4556 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
4557 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
4558
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004559check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08004560check_vintf_common_srcs_patterns :=
4561
4562check_vintf_has_system :=
4563check_vintf_has_vendor :=
4564
Yifan Hong28ffd732020-03-13 13:11:10 -07004565ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
4566$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
4567endif
4568ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
4569$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
4570endif
4571
Yifan Hong605ea042020-01-14 21:36:00 +00004572# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08004573check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
4574ifneq ($(check_vintf_system_deps),)
4575check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00004576
Yifan Hongfd150d32021-03-09 12:19:11 -08004577check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00004578check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004579$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00004580 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
Bob Badour5acd4362022-04-12 18:31:35 -07004581$(call declare-0p-target,$(check_vintf_system_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004582check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00004583
Yifan Hongfd150d32021-03-09 12:19:11 -08004584vintffm_log := $(intermediates)/vintffm.log
Yifan Hong7a157b02020-10-20 17:08:11 +00004585check_vintf_all_deps += $(vintffm_log)
4586$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
4587 @( $< --check --dirmap /system:$(TARGET_OUT) \
4588 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
4589
Bob Badour5acd4362022-04-12 18:31:35 -07004590$(call declare-0p-target,$(vintffm_log))
4591
Yifan Hongaf9b0702020-01-21 12:46:57 -08004592endif # check_vintf_system_deps
4593check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004594
4595# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004596check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
4597ifneq ($(check_vintf_vendor_deps),)
4598check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08004599check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00004600check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07004601# Check vendor SKU=(empty) case when:
4602# - DEVICE_MANIFEST_FILE is not empty; OR
4603# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004604$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004605 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4606 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004607 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004608$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07004609 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4610 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4611 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4612 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Bob Badour5acd4362022-04-12 18:31:35 -07004613$(call declare-0p-target,$(check_vintf_vendor_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004614check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08004615endif # check_vintf_vendor_deps
4616check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004617
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004618# -- Kernel version and configurations.
4619ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
4620
Yifan Hong605ea042020-01-14 21:36:00 +00004621BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
4622BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
4623
4624my_board_extracted_kernel :=
4625
4626# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
4627# from INSTALLED_KERNEL_TARGET.
4628ifdef BOARD_KERNEL_CONFIG_FILE
4629ifdef BOARD_KERNEL_VERSION
4630$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
4631 cp $< $@
4632$(BUILT_KERNEL_VERSION_FILE):
4633 echo $(BOARD_KERNEL_VERSION) > $@
4634
Bob Badour5acd4362022-04-12 18:31:35 -07004635$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4636$(call declare-0p-target,$(BUILT_KERNEL_VERSION_FILE))
4637
Yifan Hong605ea042020-01-14 21:36:00 +00004638my_board_extracted_kernel := true
4639endif # BOARD_KERNEL_VERSION
4640endif # BOARD_KERNEL_CONFIG_FILE
4641
4642ifneq ($(my_board_extracted_kernel),true)
Yifan Hong605ea042020-01-14 21:36:00 +00004643# Tools for decompression that is not in PATH.
4644# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
4645# Algorithms that are in the script but not in this list will be found in PATH.
4646my_decompress_tools := \
4647 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
4648
Yifan Hongb1627772021-07-14 15:01:50 -07004649endif # my_board_extracted_kernel
4650
4651ifneq ($(my_board_extracted_kernel),true)
4652ifdef INSTALLED_KERNEL_TARGET
Yifan Hong605ea042020-01-14 21:36:00 +00004653$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4654$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4655$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07004656$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
4657 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00004658 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08004659 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00004660
Bob Badour5acd4362022-04-12 18:31:35 -07004661$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4662
Yifan Hongb1627772021-07-14 15:01:50 -07004663my_board_extracted_kernel := true
Yifan Hong605ea042020-01-14 21:36:00 +00004664endif # INSTALLED_KERNEL_TARGET
Yifan Hongb1627772021-07-14 15:01:50 -07004665endif # my_board_extracted_kernel
4666
4667ifneq ($(my_board_extracted_kernel),true)
4668ifdef INSTALLED_BOOTIMAGE_TARGET
4669$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4670$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4671$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
4672$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
4673$(BUILT_KERNEL_CONFIGS_FILE): \
4674 $(HOST_OUT_EXECUTABLES)/unpack_bootimg \
4675 $(EXTRACT_KERNEL) \
4676 $(INSTALLED_BOOTIMAGE_TARGET)
4677 $(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
4678 $(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
4679 --output-configs $@ \
4680 --output-release $(BUILT_KERNEL_VERSION_FILE)
4681
Bob Badour5acd4362022-04-12 18:31:35 -07004682$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4683
Yifan Hongb1627772021-07-14 15:01:50 -07004684my_board_extracted_kernel := true
4685endif # INSTALLED_BOOTIMAGE_TARGET
4686endif # my_board_extracted_kernel
4687
4688ifneq ($(my_board_extracted_kernel),true)
4689$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
4690 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
4691 cannot be built into OTA update package. You can fix this by: \
4692 (1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
4693 so that kernel information will be extracted from the built kernel; or \
4694 (2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
4695 (3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
4696 BOARD_KERNEL_VERSION manually; or \
4697 (4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
4698# Clear their values to indicate that these two files does not exist.
4699BUILT_KERNEL_CONFIGS_FILE :=
4700BUILT_KERNEL_VERSION_FILE :=
4701endif
4702
4703my_decompress_tools :=
4704my_board_extracted_kernel :=
Yifan Hong605ea042020-01-14 21:36:00 +00004705
Yifan Hongc0f904e2021-03-17 11:25:31 -07004706endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4707
4708# -- Check VINTF compatibility of build.
4709# Skip partial builds; only check full builds. Only check if:
4710# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
4711# - system / vendor VINTF metadata exists
4712# - Building product / system_ext / odm images if board has product / system_ext / odm images
4713ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4714ifeq ($(check_vintf_has_system),true)
4715ifeq ($(check_vintf_has_vendor),true)
4716ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
4717ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
4718ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
4719
4720check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
4721check_vintf_all_deps += $(check_vintf_compatible_log)
4722
4723check_vintf_compatible_args :=
4724check_vintf_compatible_deps := $(check_vintf_common_srcs)
4725
4726ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004727ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004728check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004729check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004730endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004731endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4732
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004733check_vintf_compatible_args += \
4734 --dirmap /system:$(TARGET_OUT) \
4735 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4736 --dirmap /odm:$(TARGET_OUT_ODM) \
4737 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4738 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
4739
4740ifdef PRODUCT_SHIPPING_API_LEVEL
4741check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4742endif # PRODUCT_SHIPPING_API_LEVEL
4743
4744$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4745$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004746# Check ODM SKU=(empty) case when:
4747# - ODM_MANIFEST_FILES is not empty; OR
4748# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004749$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004750 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
4751 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004752 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07004753# Check vendor SKU=(empty) case when:
4754# - DEVICE_MANIFEST_FILE is not empty; OR
4755# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004756$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004757 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4758 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004759 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004760$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08004761 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
4762 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004763 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
4764 @echo -n -e 'Args: \n ' >> $@
4765 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07004766 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4767 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004768 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004769 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
4770 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4771 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004772
Bob Badour5acd4362022-04-12 18:31:35 -07004773$(call declare-0p-target,$(check_vintf_compatible_log))
4774
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004775check_vintf_compatible_log :=
4776check_vintf_compatible_args :=
4777check_vintf_compatible_deps :=
4778
4779endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4780endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4781endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004782endif # check_vintf_has_vendor
4783endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004784endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4785
4786# Add all logs of VINTF checks to dist builds
4787droid_targets: $(check_vintf_all_deps)
4788$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4789
4790# Helper alias to check all VINTF of current build.
4791.PHONY: check-vintf-all
4792check-vintf-all: $(check_vintf_all_deps)
4793 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4794
Yifan Hongaf9b0702020-01-21 12:46:57 -08004795check_vintf_has_vendor :=
4796check_vintf_has_system :=
4797check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004798check_vintf_all_deps :=
4799intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004800endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004801
4802# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004803# Check image sizes <= size of super partition
4804
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004805ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004806
4807ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004808
Tianjie16bcac12021-05-13 15:44:43 -07004809PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
4810
4811# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
4812ifdef BUILDING_SYSTEM_OTHER_IMAGE
4813PARTITIONS_AND_OTHER_IN_SUPER += system_other
4814endif # BUILDING_SYSTEM_OTHER_IMAGE
4815
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004816# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004817# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004818define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004819 mkdir -p $(dir $(1))
4820 rm -f $(1)
4821 $(call dump-super-image-info, $(1))
Tianjie16bcac12021-05-13 15:44:43 -07004822 $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004823 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004824 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004825endef
4826
Yifan Hongd11953c2021-03-11 14:47:48 -08004827check_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 -07004828droid_targets: $(check_all_partition_sizes_log)
4829$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004830
Yifan Hong30910932019-10-25 20:36:55 -07004831$(check_all_partition_sizes_log): \
4832 $(CHECK_PARTITION_SIZES) \
Tianjie16bcac12021-05-13 15:44:43 -07004833 $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
Yifan Hong30910932019-10-25 20:36:55 -07004834 $(call check-all-partition-sizes-target, \
4835 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4836 $@)
4837
Bob Badour5acd4362022-04-12 18:31:35 -07004838$(call declare-0p-target,$(check_all_partition_sizes_log))
4839
Yifan Hong30910932019-10-25 20:36:55 -07004840.PHONY: check-all-partition-sizes
4841check-all-partition-sizes: $(check_all_partition_sizes_log)
4842
4843.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004844check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004845 $(call check-all-partition-sizes-target, \
4846 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004847
Yifan Hong2dae5722018-07-31 12:47:27 -07004848endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004849
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004850endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004851
4852# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004853# bring in the installer image generation defines if necessary
4854ifeq ($(TARGET_USE_DISKINSTALLER),true)
4855include bootable/diskinstaller/config.mk
4856endif
4857
4858# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004859# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004860
Ying Wangbd2d0242015-09-22 11:17:52 -07004861ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004862 build_ota_package := false
4863 build_otatools_package := false
4864else
Tao Bao9be20c72019-04-08 21:11:59 -07004865 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004866 build_ota_package := true
4867 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4868 build_ota_package := false
4869 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004870 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004871 build_ota_package := false
4872 endif
4873 ifeq ($(TARGET_PRODUCT),sdk)
4874 build_ota_package := false
4875 endif
Yifan Hongf32f65c2021-07-14 14:19:12 -07004876 # A target without a kernel may be one of the following:
Yifan Hong8c1e5262021-07-19 16:35:05 +00004877 # - A generic target. In this case, the OTA package usually isn't built.
4878 # PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
4879 # generation.
4880 # - A real device target, with TARGET_NO_KERNEL set to true and
4881 # BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
4882 # an OTA package.
Tao Bao9be20c72019-04-08 21:11:59 -07004883 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4884 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4885 build_ota_package := false
4886 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004887 ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4888 ifeq ($(TARGET_NO_KERNEL),true)
4889 build_ota_package := false
4890 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004891 endif # INSTALLED_BOOTIMAGE_TARGET == ""
Yifan Hongbf777872021-07-19 16:28:49 +00004892 ifeq ($(recovery_fstab),)
4893 build_ota_package := false
4894 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004895 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004896
Tao Bao9be20c72019-04-08 21:11:59 -07004897 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004898 build_otatools_package := true
4899 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4900 build_otatools_package := false
4901 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004902endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004903
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004904ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004905
4906INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004907 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004908 add_img_to_target_files \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004909 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004910 append2simg \
4911 avbtool \
4912 blk_alloc_to_base_fs \
4913 boot_signer \
4914 brillo_update_payload \
4915 brotli \
4916 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004917 build_image \
4918 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004919 build_verity_metadata \
4920 build_verity_tree \
4921 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004922 check_ota_package_signature \
4923 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004924 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004925 checkvintf \
4926 delta_generator \
4927 e2fsck \
4928 e2fsdroid \
4929 fc_sort \
4930 fec \
Woody Line4164192022-03-21 18:29:41 +08004931 fsck.erofs \
Jaegeuk Kim01da65f2021-06-08 18:24:46 -07004932 fsck.f2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07004933 fs_config \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08004934 generate_gki_certificate \
Tao Bao96daeeb2019-05-01 21:17:13 -07004935 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08004936 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07004937 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004938 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004939 imgdiff \
4940 libconscrypt_openjdk_jni \
4941 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004942 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07004943 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07004944 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07004945 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07004946 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004947 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004948 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004949 mkbootfs \
4950 mkbootimg \
4951 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004952 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08004953 mkfs.erofs \
Tao Bao96daeeb2019-05-01 21:17:13 -07004954 mkf2fsuserimg.sh \
4955 mksquashfs \
4956 mksquashfsimage.sh \
4957 mkuserimg_mke2fs \
Kelvin Zhang83eb9f72022-03-15 11:12:50 -07004958 ota_extractor \
Tao Bao8821d642019-08-05 12:05:45 -07004959 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08004960 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08004961 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07004962 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004963 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004964 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004965 sign_apex \
4966 sign_target_files_apks \
Jooyung Han8caba5e2021-10-27 03:58:09 +09004967 sign_virt_apex \
Tao Bao96daeeb2019-05-01 21:17:13 -07004968 signapk \
4969 simg2img \
4970 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07004971 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07004972 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08004973 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07004974 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07004975 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004976 verity_signer \
4977 verity_verifier \
4978 zipalign \
Kelvin Zhangb673bbf2021-08-20 10:09:20 -07004979 zucchini \
Tao Bao5e04c382017-02-22 16:38:19 -08004980
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004981# Additional tools to unpack and repack the apex file.
4982INTERNAL_OTATOOLS_MODULES += \
4983 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00004984 apex_compression_tool \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004985 deapexer \
4986 debugfs_static \
4987 merge_zips \
4988 resize2fs \
4989 soong_zip \
4990
Anton Hansson8dab0a62019-03-28 15:45:40 +00004991ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004992INTERNAL_OTATOOLS_MODULES += \
4993 futility \
4994 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004995endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004996
Tao Bao96daeeb2019-05-01 21:17:13 -07004997INTERNAL_OTATOOLS_FILES := \
4998 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004999
Ying Wang06898662010-06-17 17:52:18 -07005000.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07005001otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07005002
Tao Bao96daeeb2019-05-01 21:17:13 -07005003# For each module, recursively resolve its host shared library dependencies. Then we have a full
5004# list of modules whose installed files need to be packed.
5005INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
5006 $(sort $(INTERNAL_OTATOOLS_MODULES) \
5007 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005008
Tao Bao96daeeb2019-05-01 21:17:13 -07005009INTERNAL_OTATOOLS_PACKAGE_FILES := \
5010 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
5011
5012INTERNAL_OTATOOLS_PACKAGE_FILES += \
5013 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
5014 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07005015
5016ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07005017INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07005018 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07005019 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07005020endif
5021ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07005022INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07005023 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
5024 -name "atx_metadata.bin"))
5025endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005026ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005027INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00005028 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07005029endif
5030
Tao Bao96daeeb2019-05-01 21:17:13 -07005031INTERNAL_OTATOOLS_RELEASETOOLS := \
5032 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
5033 \( -type f -o -type l \) -print))
5034
5035BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
5036$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
5037$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
5038$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
5039$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07005040$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005041 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07005042 rm -rf $@ $(PRIVATE_ZIP_ROOT)
5043 mkdir -p $(dir $@)
5044 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
5045 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08005046 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07005047 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005048
Bob Badour5acd4362022-04-12 18:31:35 -07005049$(call declare-1p-container,$(BUILT_OTATOOLS_PACKAGE),build)
5050$(call declare-container-license-deps,$(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS),$(BUILT_OTATOOLS_PACKAGE):)
5051
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005052.PHONY: otatools-package
5053otatools-package: $(BUILT_OTATOOLS_PACKAGE)
5054
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005055endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005056
The Android Open Source Project88b60792009-03-03 19:28:42 -08005057# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07005058# misc_info.txt
5059
5060INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
5061
5062ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
5063# default to common dir for device vendor
5064tool_extensions := $(TARGET_DEVICE_DIR)/../common
5065else
5066tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
5067endif
5068.KATI_READONLY := tool_extensions
5069
Steve Muckle903a1ca2020-05-07 17:32:10 -07005070# $1: boot image file name
5071define misc_boot_size
5072$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
5073endef
5074
Daniel Normane1e48082019-06-27 13:55:23 -07005075$(INSTALLED_MISC_INFO_TARGET):
5076 rm -f $@
5077 $(call pretty,"Target misc_info.txt: $@")
5078 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
5079 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
5080ifdef BOARD_FLASH_BLOCK_SIZE
5081 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
5082endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07005083ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
5084 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
5085 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07005086endif
5087ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
5088 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07005089else
5090 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005091endif
Devin Moore380d9e42021-11-04 19:01:19 +00005092ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
5093 $(hide) echo "init_boot=true" >> $@
5094 $(hide) echo "init_boot_size=$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)" >> $@
5095endif
J. Avila98cd4cc2020-06-10 20:09:10 +00005096ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
5097 echo "lz4_ramdisks=true" >> $@
5098endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005099ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5100 echo "vendor_boot=true" >> $@
5101 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
5102endif
Lucas Weif57333f2022-02-24 10:30:15 +08005103ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
5104 echo "vendor_kernel_boot=true" >> $@
5105 echo "vendor_kernel_boot_size=$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)" >> $@
5106endif
Daniel Normane1e48082019-06-27 13:55:23 -07005107ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5108 $(hide) echo "no_recovery=true" >> $@
5109endif
5110ifdef BOARD_INCLUDE_RECOVERY_DTBO
5111 $(hide) echo "include_recovery_dtbo=true" >> $@
5112endif
5113ifdef BOARD_INCLUDE_RECOVERY_ACPIO
5114 $(hide) echo "include_recovery_acpio=true" >> $@
5115endif
5116ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
5117 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
5118endif
5119ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
5120 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
5121 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5122else
5123 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5124endif
5125 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
5126 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
Jacky Liubeb0b692021-12-29 16:29:05 +08005127ifdef PRODUCT_EXTRA_OTA_KEYS
5128 $(hide) echo "extra_ota_keys=$(PRODUCT_EXTRA_OTA_KEYS)" >> $@
5129endif
Daniel Normane1e48082019-06-27 13:55:23 -07005130ifdef PRODUCT_EXTRA_RECOVERY_KEYS
5131 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
5132endif
5133 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07005134 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005135 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Devin Moore380d9e42021-11-04 19:01:19 +00005136 $(hide) echo 'mkbootimg_init_args=$(BOARD_MKBOOTIMG_INIT_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005137ifdef BOARD_GKI_SIGNING_KEY_PATH
5138 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
5139 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005140 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
5141endif
Daniel Normane1e48082019-06-27 13:55:23 -07005142 $(hide) echo "multistage_support=1" >> $@
5143 $(hide) echo "blockimgdiff_versions=3,4" >> $@
5144ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
5145 $(hide) echo "build_generic_ota_package=true" >> $@
5146endif
5147ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
5148 # OTA scripts are only interested in fingerprint related properties
5149 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
5150endif
5151ifneq (,$(filter address, $(SANITIZE_TARGET)))
5152 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
5153 $(hide) echo "userdata_img_with_data=true" >> $@
5154endif
5155ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
5156 $(hide) echo "full_recovery_image=true" >> $@
5157endif
Bill Peckhame868aec2019-09-17 17:06:47 -07005158ifdef BOARD_USES_VENDORIMAGE
5159 $(hide) echo "board_uses_vendorimage=true" >> $@
5160endif
Daniel Normane1e48082019-06-27 13:55:23 -07005161ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08005162ifeq ($(BUILDING_VBMETA_IMAGE),true)
5163 $(hide) echo "avb_building_vbmeta_image=true" >> $@
5164endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005165 $(hide) echo "avb_enable=true" >> $@
5166 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
5167 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
5168 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
5169 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5170ifdef BOARD_AVB_BOOT_KEY_PATH
5171 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
5172 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
5173 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5174endif # BOARD_AVB_BOOT_KEY_PATH
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08005175 $(hide) echo "avb_init_boot_add_hash_footer_args=$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5176ifdef BOARD_AVB_INIT_BOOT_KEY_PATH
5177 $(hide) echo "avb_init_boot_key_path=$(BOARD_AVB_INIT_BOOT_KEY_PATH)" >> $@
5178 $(hide) echo "avb_init_boot_algorithm=$(BOARD_AVB_INIT_BOOT_ALGORITHM)" >> $@
5179 $(hide) echo "avb_init_boot_rollback_index_location=$(BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5180endif # BOARD_AVB_INIT_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07005181 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5182ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
5183 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
5184 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
5185 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5186endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Lucas Weif57333f2022-02-24 10:30:15 +08005187 echo "avb_vendor_kernel_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5188ifdef BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
5189 echo "avb_vendor_kernel_boot_key_path=$(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH)" >> $@
5190 echo "avb_vendor_kernel_boot_algorithm=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ALGORITHM)" >> $@
5191 echo "avb_vendor_kernel_boot_rollback_index_location=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5192endif # BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07005193 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
5194ifdef BOARD_AVB_RECOVERY_KEY_PATH
5195 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
5196 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
5197 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
5198endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07005199ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
5200 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
5201 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5202 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
5203 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
5204 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
5205 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
5206 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
5207 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
5208endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07005209ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
5210 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
5211 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
5212 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
5213 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
5214 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
5215endif # BOARD_AVB_VBMETA_SYSTEM
5216ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
5217 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
Bowgo Tsaic85a2012022-06-07 11:36:35 +08005218 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS)" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005219 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
5220 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
5221 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
5222endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
5223endif # BOARD_AVB_ENABLE
5224ifdef BOARD_BPT_INPUT_FILES
5225 $(hide) echo "board_bpt_enable=true" >> $@
5226 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
5227 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
5228endif
5229ifdef BOARD_BPT_DISK_SIZE
5230 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
5231endif
5232 $(call generate-userimage-prop-dictionary, $@)
5233ifeq ($(AB_OTA_UPDATER),true)
5234 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
5235 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
5236 $(hide) echo "ab_update=true" >> $@
5237endif
Yifan Hong65afc072020-04-17 10:08:10 -07005238ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
5239 $(hide) echo "allow_non_ab=true" >> $@
5240endif
Daniel Normane1e48082019-06-27 13:55:23 -07005241ifdef BOARD_PREBUILT_DTBOIMAGE
5242 $(hide) echo "has_dtbo=true" >> $@
5243ifeq ($(BOARD_AVB_ENABLE),true)
5244 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
5245 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
5246ifdef BOARD_AVB_DTBO_KEY_PATH
5247 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
5248 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
5249 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
5250endif # BOARD_AVB_DTBO_KEY_PATH
5251endif # BOARD_AVB_ENABLE
5252endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005253ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005254 $(hide) echo "has_pvmfw=true" >> $@
5255ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi592a3ca2021-10-04 11:34:11 +02005256 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@
Andrew Scull9b103e42020-11-29 14:04:28 +00005257 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
5258ifdef BOARD_AVB_PVMFW_KEY_PATH
5259 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
5260 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
5261 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
5262endif # BOARD_AVB_PVMFW_KEY_PATH
5263endif # BOARD_AVB_ENABLE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005264endif # BOARD_USES_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005265 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07005266 @# VINTF checks
5267ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
5268 $(hide) echo "vintf_enforce=true" >> $@
5269endif
5270ifdef ODM_MANIFEST_SKUS
5271 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
5272endif
Yifan Hong28ffd732020-03-13 13:11:10 -07005273ifdef ODM_MANIFEST_FILES
5274 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
5275endif
5276ifdef DEVICE_MANIFEST_SKUS
5277 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
5278endif
5279ifdef DEVICE_MANIFEST_FILE
5280 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
5281endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005282ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
5283 $(hide) echo "bootloader_in_update_package=true" >> $@
5284endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07005285ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
5286 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
5287endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05005288ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5289 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
5290endif
Jose Galmes9c8f6eb2021-07-21 09:34:08 -07005291ifeq ($(BUILDING_WITH_VSDK),true)
5292 $(hide) echo "building_with_vsdk=true" >> $@
5293endif
5294ifeq ($(TARGET_FLATTEN_APEX),false)
5295 $(hide) echo "target_flatten_apex=false" >> $@
5296endif
Daniel Normane1e48082019-06-27 13:55:23 -07005297
Bob Badour70c07dd2022-02-12 15:39:22 -08005298$(call declare-0p-target,$(INSTALLED_MISC_INFO_TARGET))
5299
Daniel Normane1e48082019-06-27 13:55:23 -07005300.PHONY: misc_info
5301misc_info: $(INSTALLED_MISC_INFO_TARGET)
5302
Bill Peckham315b98a2021-06-15 19:35:06 -07005303droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
Daniel Normane1e48082019-06-27 13:55:23 -07005304
5305# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005306# A zip of the directories that map to the target filesystem.
5307# This zip can be used to create an OTA package or filesystem image
5308# as a post-build step.
5309#
5310name := $(TARGET_PRODUCT)
5311ifeq ($(TARGET_BUILD_TYPE),debug)
5312 name := $(name)_debug
5313endif
5314name := $(name)-target_files-$(FILE_NAME_TAG)
5315
5316intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
5317BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
5318$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
5319$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005320 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005321
5322# $(1): Directory to copy
5323# $(2): Location to copy it to
5324# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
5325define package_files-copy-root
5326 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
5327 mkdir -p $(2) && \
5328 $(ACP) -rd $(strip $(1))/* $(2); \
5329 fi
5330endef
5331
Tao Baoa04fca32015-11-30 12:22:24 -08005332built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07005333
5334# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08005335ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07005336built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07005337 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07005338endif
5339
The Android Open Source Project88b60792009-03-03 19:28:42 -08005340$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
5341
Dan Willemsen653bea92017-03-21 15:47:37 -07005342tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07005343$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07005344
HÃ¥kan Kvist8cabc712022-05-02 07:43:34 +02005345updater_dep :=
Sen Jiang4438fd92016-03-07 16:51:01 -08005346ifeq ($(AB_OTA_UPDATER),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005347updater_dep += system/update_engine/update_engine.conf
Bob Badour5acd4362022-04-12 18:31:35 -07005348$(call declare-1p-target,system/update_engine/update_engine.conf,system/update_engine)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005349updater_dep += external/zucchini/version_info.h
Bob Badour5acd4362022-04-12 18:31:35 -07005350$(call declare-license-metadata,external/zucchini/version_info.h,legacy_notice,notice,external/zucchini/LICENSE,external/zucchini)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005351updater_dep += $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so
Yifan Hong65afc072020-04-17 10:08:10 -07005352endif
5353
5354# Build OTA tools if non-A/B is allowed
5355ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005356updater_dep += $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07005357endif
Yifan Hong65afc072020-04-17 10:08:10 -07005358
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09005359$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07005360
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005361# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07005362# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005363ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5364$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07005365else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
5366$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005367else
5368$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
5369endif
5370
Dan Willemsen653bea92017-03-21 15:47:37 -07005371ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07005372 ifdef OSRELEASED_DIRECTORY
5373 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
5374 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
5375 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
5376 endif
Tao Baoa835f382019-07-18 15:55:30 -07005377
5378 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
5379 # additionally include radio or bootloader partitions).
5380 ifeq ($(AB_OTA_PARTITIONS),)
5381 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
5382 endif
5383endif
5384
5385ifneq ($(AB_OTA_PARTITIONS),)
5386 ifneq ($(AB_OTA_UPDATER),true)
5387 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
5388 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07005389endif
5390
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005391# Run fs_config while creating the target files package
5392# $1: root directory
5393# $2: add prefix
5394define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08005395(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 -08005396endef
5397
Yifan Hong60bfcc42019-11-01 11:39:45 -07005398define filter-out-missing-vendor
5399$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
5400endef
Petri Gynther09865a42021-03-10 18:23:39 -08005401define filter-out-missing-vendor_dlkm
5402$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
5403endef
5404define filter-out-missing-odm
5405$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
5406endef
5407define filter-out-missing-odm_dlkm
5408$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
5409endef
Ramji Jiyani13a41372022-01-27 07:05:08 +00005410define filter-out-missing-system_dlkm
5411$(if $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(1),$(filter-out system_dlkm,$(1)))
5412endef
5413# Filter out vendor,vendor_dlkm,odm,odm_dlkm,system_dlkm from the list for AOSP targets.
Petri Gynther09865a42021-03-10 18:23:39 -08005414# $(1): list
5415define filter-out-missing-partitions
5416$(call filter-out-missing-vendor,\
5417 $(call filter-out-missing-vendor_dlkm,\
5418 $(call filter-out-missing-odm,\
Ramji Jiyani13a41372022-01-27 07:05:08 +00005419 $(call filter-out-missing-odm_dlkm,\
5420 $(call filter-out-missing-system_dlkm,$(1))))))
Petri Gynther09865a42021-03-10 18:23:39 -08005421endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07005422
5423# Information related to dynamic partitions and virtual A/B. This information
5424# is needed for building the super image (see dump-super-image-info) and
5425# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08005426# $(1): file
5427define dump-dynamic-partitions-info
5428 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
5429 echo "use_dynamic_partitions=true" >> $(1))
5430 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
5431 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08005432 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
5433 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
5434 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00005435 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
5436 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08005437 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
5438 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005439 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
5440 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5441 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
5442 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5443 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
5444 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005445 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005446 $(if $(BOARD_SUPER_PARTITION_GROUPS),
5447 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
5448 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
5449 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
5450 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005451 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 -07005452 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
5453 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07005454 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
5455 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005456 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
5457 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005458 $(if $(BOARD_SUPER_PARTITION_SIZE), \
5459 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
5460 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
5461 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
5462 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
5463 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
5464 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
5465 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005466 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
5467 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05005468 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
5469 echo "virtual_ab_compression=true" >> $(1))
Kelvin Zhangfa91e982022-02-09 11:19:16 -08005470# This value controls the compression algorithm used for VABC
5471# valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
5472# e.g. "none", "gz", "brotli"
5473 $(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD), \
5474 echo "virtual_ab_compression_method=$(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005475 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
5476 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005477endef
5478
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005479# By conditionally including the dependency of the target files package on the
5480# full system image deps, we speed up builds that do not build the system
5481# image.
5482ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005483 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005484else
5485 # releasetools may need the system build.prop even when building a
5486 # system-image-less product.
5487 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BUILD_PROP_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005488endif
5489
5490ifdef BUILDING_USERDATA_IMAGE
5491 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
5492endif
5493
5494ifdef BUILDING_SYSTEM_OTHER_IMAGE
5495 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
5496endif
5497
5498ifdef BUILDING_VENDOR_BOOT_IMAGE
5499 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005500 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Devin Moore55af5062021-06-09 10:44:44 -07005501 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Colin Crosse6431202021-02-24 11:44:55 -08005502 # The vendor ramdisk may be built from the recovery ramdisk.
5503 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
5504 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
5505 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07005506endif
5507
5508ifdef BUILDING_RECOVERY_IMAGE
5509 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08005510 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07005511 # commands in build-recoveryimage-target, which would touch the files under
5512 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
5513 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5514 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5515 else
5516 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
5517 endif
5518 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
5519endif
5520
5521# Conditionally depend on the image files if the image is being built so the
5522# target-files.zip rule doesn't wait on the image creation rule, or the image
5523# if it is coming from a prebuilt.
5524
5525ifdef BUILDING_VENDOR_IMAGE
5526 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
5527else ifdef BOARD_PREBUILT_VENDORIMAGE
5528 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
5529endif
5530
5531ifdef BUILDING_PRODUCT_IMAGE
5532 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
5533else ifdef BOARD_PREBUILT_PRODUCTIMAGE
5534 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
5535endif
5536
5537ifdef BUILDING_SYSTEM_EXT_IMAGE
5538 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
5539else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
5540 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
5541endif
5542
Devin Moore380d9e42021-11-04 19:01:19 +00005543ifneq (,$(BUILDING_BOOT_IMAGE)$(BUILDING_INIT_BOOT_IMAGE))
Colin Cross43f2eb22020-08-26 18:41:29 -07005544 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Devin Moore380d9e42021-11-04 19:01:19 +00005545endif # BUILDING_BOOT_IMAGE != "" || BUILDING_INIT_BOOT_IMAGE != ""
5546
Yifan Hong49968aa2020-11-09 11:52:52 -08005547ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07005548 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5549endif
5550
5551ifdef BUILDING_ODM_IMAGE
5552 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
5553else ifdef BOARD_PREBUILT_ODMIMAGE
5554 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
5555endif
5556
5557ifdef BUILDING_VENDOR_DLKM_IMAGE
5558 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005559else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005560 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
5561endif
5562
5563ifdef BUILDING_ODM_DLKM_IMAGE
5564 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005565else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005566 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005567endif
5568
Ramji Jiyani13a41372022-01-27 07:05:08 +00005569ifdef BUILDING_SYSTEM_DLKM_IMAGE
5570 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
5571else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5572 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
5573endif
5574
Isaac Chen9e09d472019-07-05 17:30:41 +08005575ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07005576 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
5577 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08005578endif
5579
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005580ifdef BOARD_PREBUILT_BOOTLOADER
5581$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005582droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005583endif
5584
The Android Open Source Project88b60792009-03-03 19:28:42 -08005585# Depending on the various images guarantees that the underlying
5586# directories are up-to-date.
5587$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005588 $(INSTALLED_RADIOIMAGE_TARGET) \
5589 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005590 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005591 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00005592 $(INSTALLED_PVMFWIMAGE_TARGET) \
Andrew Scullbbc930b2022-02-17 22:34:27 +00005593 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07005594 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005595 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
5596 $(INSTALLED_KERNEL_TARGET) \
Enrico Granatab582e0f2020-10-14 15:17:20 -06005597 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005598 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005599 $(INSTALLED_2NDBOOTLOADER_TARGET) \
5600 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08005601 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005602 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005603 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5604 $(PRODUCT_VENDOR_BASE_FS_PATH) \
5605 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09005606 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005607 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07005608 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07005609 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00005610 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00005611 $(LPMAKE) \
5612 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07005613 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005614 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005615 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005616 $(SOONG_ZIP) \
5617 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07005618 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07005619 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005620 $(BUILT_KERNEL_CONFIGS_FILE) \
5621 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005622 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005623 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005624 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005625 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07005626ifneq (,$(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 -08005627 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005628 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005629# Exclude recovery files in the default vendor ramdisk if including a standalone
5630# recovery ramdisk in vendor_boot.
5631ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005632 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005633 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005634endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005635ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005636ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07005637 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07005638else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07005639 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
5640endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005641endif
Yifan Hong78860162020-10-28 14:15:21 -07005642ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005643ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005644 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005645endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005646ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08005647ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07005648 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08005649else
Steve Mucklee1b10862019-07-10 10:49:37 -07005650 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005651endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005652endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005653ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07005654 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005655endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005656ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005657 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005658endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005659ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07005660ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07005661 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07005662endif # INTERNAL_KERNEL_CMDLINE != ""
5663endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07005664ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005665 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005666endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005667ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005668 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005669endif
Yifan Hong3941a872020-10-28 16:33:06 -07005670endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005671endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08005672 @# Components of the boot image
5673 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07005674 $(hide) mkdir -p $(zip_root)/ROOT
5675 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005676 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08005677 @# If we are using recovery as boot, this is already done when processing recovery.
5678ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07005679ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005680 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005681 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07005682endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005683ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005684 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08005685endif
Yifan Hong46aff092020-10-28 13:50:47 -07005686ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07005687 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07005688else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07005689 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08005690ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005691 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005692endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005693ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005694 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005695endif
Doug Zongker38a649f2009-06-17 09:07:09 -07005696ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005697 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005698endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005699ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005700 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005701endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005702endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07005703endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07005704 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
5705 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07005706 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07005707ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5708 mkdir -p $(zip_root)/VENDOR_BOOT
5709 $(call package_files-copy-root, \
5710 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
5711ifdef INSTALLED_DTBIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005712ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
Steve Mucklee1b10862019-07-10 10:49:37 -07005713 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
5714endif
Lucas Weif57333f2022-02-24 10:30:15 +08005715endif # end of INSTALLED_DTBIMAGE_TARGET
Devin Moore50509012021-01-13 10:45:04 -08005716ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
5717 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
5718endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005719ifdef BOARD_KERNEL_BASE
5720 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
5721endif
5722ifdef BOARD_KERNEL_PAGESIZE
5723 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
5724endif
5725 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005726ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
5727 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
5728 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005729 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
5730 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
5731 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
5732 $(if $(prebuilt_ramdisk), \
5733 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
5734 $(call package_files-copy-root, \
5735 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
5736 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
5737 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005738endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07005739endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005740ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
5741 mkdir -p $(zip_root)/VENDOR_KERNEL_BOOT
5742 $(call package_files-copy-root, \
5743 $(TARGET_VENDOR_KERNEL_RAMDISK_OUT),$(zip_root)/VENDOR_KERNEL_BOOT/RAMDISK)
5744ifdef INSTALLED_DTBIMAGE_TARGET
5745 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_KERNEL_BOOT/dtb
5746endif
5747ifdef BOARD_KERNEL_PAGESIZE
5748 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_KERNEL_BOOT/pagesize
5749endif
5750endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08005751ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005752 @# Contents of the system image
5753 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005754 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005755else ifdef INSTALLED_BUILD_PROP_TARGET
5756 @# Copy the system build.prop even if not building a system image
5757 @# because add_img_to_target_files may need it to build other partition
5758 @# images.
5759 $(hide) mkdir -p "$(zip_root)/SYSTEM"
5760 $(hide) cp "$(INSTALLED_BUILD_PROP_TARGET)" "$(patsubst $(TARGET_OUT)/%,$(zip_root)/SYSTEM/%,$(INSTALLED_BUILD_PROP_TARGET))"
Dan Willemsen67495202019-01-16 12:42:05 -08005761endif
5762ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005763 @# Contents of the data image
5764 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005765 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08005766endif
5767ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07005768 @# Contents of the vendor image
5769 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005770 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07005771endif
Dan Willemsen67495202019-01-16 12:42:05 -08005772ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005773 @# Contents of the product image
5774 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005775 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005776endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005777ifdef BUILDING_SYSTEM_EXT_IMAGE
5778 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01005779 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09005780 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01005781endif
Dan Willemsen67495202019-01-16 12:42:05 -08005782ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005783 @# Contents of the odm image
5784 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005785 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005786endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005787ifdef BUILDING_VENDOR_DLKM_IMAGE
5788 @# Contents of the vendor_dlkm image
5789 $(hide) $(call package_files-copy-root, \
5790 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
5791endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005792ifdef BUILDING_ODM_DLKM_IMAGE
5793 @# Contents of the odm_dlkm image
5794 $(hide) $(call package_files-copy-root, \
5795 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
5796endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005797ifdef BUILDING_SYSTEM_DLKM_IMAGE
5798 @# Contents of the system_dlkm image
5799 $(hide) $(call package_files-copy-root, \
5800 $(TARGET_OUT_SYSTEM_DLKM),$(zip_root)/SYSTEM_DLKM)
5801endif
Dan Willemsen67495202019-01-16 12:42:05 -08005802ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07005803 @# Contents of the system_other image
5804 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005805 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07005806endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005807 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07005808 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07005809 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granatab582e0f2020-10-14 15:17:20 -06005810ifdef BUILDING_RAMDISK_IMAGE
5811ifeq (true,$(BOARD_IMG_USE_RAMDISK))
5812 @# Contents of the ramdisk image
5813 $(hide) mkdir -p $(zip_root)/IMAGES
5814 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
5815endif
5816endif
Yifan Hong65afc072020-04-17 10:08:10 -07005817ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08005818ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07005819 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07005820 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07005821endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08005822endif
Doug Zongker8678df42009-06-15 14:30:14 -07005823 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08005824 @# build them.
5825 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07005826 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005827 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005828ifneq ($(tool_extension),)
5829 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
5830endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07005831 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005832 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07005833 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00005834ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
5835 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5836 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005837endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005838ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
5839 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
5840 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005841endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005842ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
5843 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
5844 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005845endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005846ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
5847 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
5848 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01005849endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005850ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
5851 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
5852 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005853endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005854ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
5855 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
5856 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
5857endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005858ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
5859 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
5860 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
5861endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005862ifneq ($(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH),)
5863 $(hide) cp $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
5864 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH))
5865endif
Yifan Hong65afc072020-04-17 10:08:10 -07005866ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07005867ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07005868 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07005869 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07005870endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08005871endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005872ifeq ($(AB_OTA_UPDATER),true)
5873 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07005874 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Kelvin Zhangc06f0622021-11-30 12:38:39 -08005875 $(hide) cp $(TOPDIR)external/zucchini/version_info.h $(zip_root)/META/zucchini_config.txt
Kelvin Zhang6877e812022-01-06 11:12:04 -08005876 $(hide) cp $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so $(zip_root)/META/liblz4.so
Cole Faust90099992022-02-17 11:35:27 -08005877 $(hide) for part in $(sort $(AB_OTA_PARTITIONS)); do \
Alex Deymo8925d332015-10-01 17:38:09 -07005878 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
5879 done
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005880 $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
Sen Jiang8f22e2a2015-11-12 13:53:25 -08005881 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
5882 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005883ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07005884 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
5885 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
5886 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005887endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005888endif
Steve Fungdfbab492015-09-24 18:12:33 -07005889ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07005890 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07005891 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07005892endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07005893ifdef BOARD_PREBUILT_VENDORIMAGE
5894 $(hide) mkdir -p $(zip_root)/IMAGES
5895 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
5896endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005897ifdef BOARD_PREBUILT_PRODUCTIMAGE
5898 $(hide) mkdir -p $(zip_root)/IMAGES
5899 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
5900endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005901ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01005902 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09005903 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01005904endif
Devin Moore380d9e42021-11-04 19:01:19 +00005905ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
Devin Moorecda41f02022-01-05 00:08:39 +00005906 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5907 $(hide) cp $(INSTALLED_INIT_BOOT_IMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Devin Moore380d9e42021-11-04 19:01:19 +00005908endif
Ramji Jiyani034e7772022-01-24 04:00:29 +00005909
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005910ifndef BOARD_PREBUILT_BOOTIMAGE
Yi-Yo Chiang81939002022-01-08 23:46:40 +08005911ifneq (,$(strip $(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES))))
Yifan Hong49968aa2020-11-09 11:52:52 -08005912ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07005913 $(hide) mkdir -p $(zip_root)/IMAGES
5914 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08005915endif # INSTALLED_BOOTIMAGE_TARGET
5916endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005917else # BOARD_PREBUILT_BOOTIMAGE is defined
5918 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5919 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5920endif # BOARD_PREBUILT_BOOTIMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005921ifdef BOARD_PREBUILT_ODMIMAGE
5922 $(hide) mkdir -p $(zip_root)/IMAGES
5923 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
5924endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07005925ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07005926 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07005927 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5928endif
5929ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
5930 $(hide) mkdir -p $(zip_root)/IMAGES
5931 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07005932endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005933ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5934 $(hide) mkdir -p $(zip_root)/IMAGES
5935 $(hide) cp $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5936endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07005937ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07005938 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5939 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08005940endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01005941ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005942 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5943 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Andrew Scullbbc930b2022-02-17 22:34:27 +00005944 $(hide) cp $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) $(zip_root)/PREBUILT_IMAGES/
Pierre-Clément Tosic7b83782022-05-12 16:25:34 +01005945 $(hide) mkdir -p $(zip_root)/PVMFW
5946 $(hide) cp $(PREBUILT_PVMFWIMAGE_TARGET) $(zip_root)/PVMFW/
Pierre-Clément Tosid8248af2021-10-07 12:18:17 +02005947endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005948ifdef BOARD_PREBUILT_BOOTLOADER
5949 $(hide) mkdir -p $(zip_root)/IMAGES
5950 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
5951endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07005952ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
5953 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5954 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5955 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
5956endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07005957 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
5958 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
5959 @# INSTALLED_RADIOIMAGE_TARGET.
5960 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
5961 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005962 @# Run fs_config on all the system, vendor, boot ramdisk,
5963 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08005964ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005965 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08005966endif
5967ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005968 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
5969endif
Dan Willemsen67495202019-01-16 12:42:05 -08005970ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005971 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
5972endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005973ifdef BUILDING_SYSTEM_EXT_IMAGE
5974 $(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 +01005975endif
Dan Willemsen67495202019-01-16 12:42:05 -08005976ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005977 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
5978endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005979ifdef BUILDING_VENDOR_DLKM_IMAGE
5980 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
5981endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005982ifdef BUILDING_ODM_DLKM_IMAGE
5983 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
5984endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005985ifdef BUILDING_SYSTEM_DLKM_IMAGE
5986 $(hide) $(call fs_config,$(zip_root)/SYSTEM_DLKM,system_dlkm/) > $(zip_root)/META/system_dlkm_filesystem_config.txt
5987endif
Tom Cherryd14b8952018-08-09 14:26:00 -07005988 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005989 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005990ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07005991 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005992 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005993endif
Devin Moore380d9e42021-11-04 19:01:19 +00005994ifdef BUILDING_INIT_BOOT_IMAGE
5995 $(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK)
5996 $(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt
5997ifdef BOARD_KERNEL_PAGESIZE
5998 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize
5999endif # BOARD_KERNEL_PAGESIZE
6000endif # BUILDING_INIT_BOOT_IMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07006001ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
6002 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
6003endif
Tom Cherry2929cad2018-09-20 11:04:37 -07006004ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
6005 @# BOOT/RAMDISK also exists and contains the first stage ramdisk if not using BOARD_BUILD_SYSTEM_ROOT_IMAGE.
Tao Baoda01b212018-02-28 21:20:08 -08006006 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
6007endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006008ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
6009 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
6010endif
Dan Willemsen67495202019-01-16 12:42:05 -08006011ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006012 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
6013endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07006014 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07006015ifdef BUILT_KERNEL_CONFIGS_FILE
6016 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
6017endif
6018ifdef BUILT_KERNEL_VERSION_FILE
6019 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
6020endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07006021 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
6022ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6023 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
6024endif
Tao Baocbd6d492019-10-07 22:46:02 -07006025 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
6026 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08006027ifeq ($(BUILD_QEMU_IMAGES),true)
6028 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
6029 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
6030endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08006031 @# Zip everything up, preserving symlinks and placing META/ files first to
6032 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006033 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07006034 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08006035 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07006036
Ying Wanga0febe52013-03-20 11:02:05 -07006037.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08006038target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
6039
Bob Badour5acd4362022-04-12 18:31:35 -07006040$(call declare-1p-container,$(BUILT_TARGET_FILES_PACKAGE),)
6041$(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED_RADIOIMAGE_TARGET) \
6042 $(INSTALLED_RECOVERYIMAGE_TARGET) \
6043 $(INSTALLED_CACHEIMAGE_TARGET) \
6044 $(INSTALLED_DTBOIMAGE_TARGET) \
6045 $(INSTALLED_PVMFWIMAGE_TARGET) \
6046 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
6047 $(INSTALLED_CUSTOMIMAGES_TARGET) \
6048 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
6049 $(INSTALLED_KERNEL_TARGET) \
6050 $(INSTALLED_RAMDISK_TARGET) \
6051 $(INSTALLED_DTBIMAGE_TARGET) \
6052 $(INSTALLED_2NDBOOTLOADER_TARGET) \
6053 $(BOARD_PREBUILT_DTBOIMAGE) \
6054 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
6055 $(BOARD_RECOVERY_ACPIO) \
6056 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
6057 $(PRODUCT_VENDOR_BASE_FS_PATH) \
6058 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
6059 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
6060 $(PRODUCT_ODM_BASE_FS_PATH) \
6061 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
6062 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
6063 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
6064 $(LPMAKE) \
6065 $(SELINUX_FC) \
6066 $(INSTALLED_MISC_INFO_TARGET) \
6067 $(APKCERTS_FILE) \
6068 $(SOONG_APEX_KEYS_FILE) \
6069 $(HOST_OUT_EXECUTABLES)/fs_config \
6070 $(ADD_IMG_TO_TARGET_FILES) \
6071 $(MAKE_RECOVERY_PATCH) \
6072 $(BUILT_KERNEL_CONFIGS_FILE) \
6073 $(BUILT_KERNEL_VERSION_FILE),$(BUILT_TARGET_FILES_PACKAGE):)
6074
Ying Wang4709d7c2014-04-14 17:25:43 -07006075$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07006076
Dan Albert4d323332016-10-14 13:23:06 -07006077# -----------------------------------------------------------------
6078# NDK Sysroot Package
6079NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07006080$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07006081 @echo Package NDK sysroot...
6082 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
6083
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006084ifeq ($(HOST_OS),linux)
Dan Albert4d323332016-10-14 13:23:06 -07006085$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006086endif
Dan Albert4d323332016-10-14 13:23:06 -07006087
Ying Wang09c4b682015-08-11 11:24:19 -07006088ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07006089# -----------------------------------------------------------------
6090# OTA update package
6091
Yifan Hong50e79542018-11-08 17:44:12 -08006092# $(1): output file
6093# $(2): additional args
6094define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07006095PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07006096 $(OTA_FROM_TARGET_FILES) \
6097 --verbose \
6098 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
6099 --path $(HOST_OUT) \
6100 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
6101 $(2) \
6102 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08006103endef
6104
Tianjie6bd3b1a2020-10-16 18:53:47 -07006105product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07006106ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006107 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07006108endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07006109name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07006110
6111INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08006112INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
6113
Bob Badour5acd4362022-04-12 18:31:35 -07006114$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
6115
Doug Zongker8678df42009-06-15 14:30:14 -07006116$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08006117$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07006118$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07006119 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08006120 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07006121
Bob Badour5acd4362022-04-12 18:31:35 -07006122$(call declare-1p-container,$(INTERNAL_OTA_PACKAGE_TARGET),)
6123$(call declare-container-license-deps,$(INTERNAL_OTA_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6124
Doug Zongker8678df42009-06-15 14:30:14 -07006125.PHONY: otapackage
6126otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
6127
Tao Bao519d1822018-12-27 12:47:23 -08006128ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006129name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08006130
6131INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08006132$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07006133$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
6134 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07006135 $(OTA_FROM_TARGET_FILES) \
6136 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08006137 @echo "Package OTA (retrofit dynamic partitions): $@"
6138 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
6139
Bob Badour5acd4362022-04-12 18:31:35 -07006140$(call declare-1p-container,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),)
6141$(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)/:/)
6142
Yifan Hong50e79542018-11-08 17:44:12 -08006143.PHONY: otardppackage
6144
6145otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
6146
Tao Bao519d1822018-12-27 12:47:23 -08006147endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08006148
Tianjie6bd3b1a2020-10-16 18:53:47 -07006149ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
6150name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
6151
6152INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6153$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
6154$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
6155 @echo "Package partial OTA: $@"
6156 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
6157
Bob Badour5acd4362022-04-12 18:31:35 -07006158$(call declare-1p-container,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),)
6159$(call declare-container-license-deps,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6160
6161
Tianjie6bd3b1a2020-10-16 18:53:47 -07006162.PHONY: partialotapackage
6163partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
6164
6165endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
6166
Ying Wang09c4b682015-08-11 11:24:19 -07006167endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07006168
Ying Wang09a00a62010-10-20 14:01:09 -07006169# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01006170# A zip of the appcompat directory containing logs
6171APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
6172# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006173ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07006174$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
6175 $(INTERNAL_RAMDISK_FILES) \
6176 $(INTERNAL_USERDATAIMAGE_FILES) \
6177 $(INTERNAL_VENDORIMAGE_FILES) \
6178 $(INTERNAL_PRODUCTIMAGE_FILES) \
6179 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01006180endif
6181$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
6182$(APPCOMPAT_ZIP): $(SOONG_ZIP)
6183 @echo "appcompat logs: $@"
6184 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6185 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
6186 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
6187 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
6188
Jeongik Cha2522c362021-04-27 23:52:15 +09006189# The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
6190ifeq ($(BUILD_OS),linux)
Jeongik Cha62519de2021-05-13 13:29:39 +09006191ifneq ($(DEX2OAT),)
Jeongik Cha2522c362021-04-27 23:52:15 +09006192dexpreopt_tools_deps := $(DEXPREOPT_GEN_DEPS) $(DEXPREOPT_GEN) $(AAPT2)
Eric Miao1d0fd2c2021-11-08 19:34:50 +00006193dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/dexdump
6194dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/oatdump
Jeongik Cha2522c362021-04-27 23:52:15 +09006195DEXPREOPT_TOOLS_ZIP := $(PRODUCT_OUT)/dexpreopt_tools.zip
6196$(DEXPREOPT_TOOLS_ZIP): $(dexpreopt_tools_deps)
6197$(DEXPREOPT_TOOLS_ZIP): PRIVATE_DEXPREOPT_TOOLS_DEPS := $(dexpreopt_tools_deps)
6198$(DEXPREOPT_TOOLS_ZIP): $(SOONG_ZIP)
6199 $(hide) mkdir -p $(dir $@)
6200 $(hide) $(SOONG_ZIP) -d -o $@ -j $(addprefix -f ,$(PRIVATE_DEXPREOPT_TOOLS_DEPS)) -f $$(realpath $(DEX2OAT))
Bob Badour5acd4362022-04-12 18:31:35 -07006201$(call declare-1p-target,$(DEXPREOPT_TOOLS_ZIP),)
Jeongik Cha62519de2021-05-13 13:29:39 +09006202endif # DEX2OAT is set
6203endif # BUILD_OS == linux
Jeongik Cha2522c362021-04-27 23:52:15 +09006204
Jeongik Chaa8056d62021-04-07 23:57:16 +09006205DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
Jeongik Chab26bf582021-06-08 11:31:31 +09006206
6207$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
6208 $(INSTALLED_VENDORIMAGE_TARGET) \
6209 $(INSTALLED_ODMIMAGE_TARGET) \
6210 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6211
6212ifeq (,$(TARGET_BUILD_UNBUNDLED))
6213$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
6214 $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
6215
6216endif
Jeongik Chaa8056d62021-04-07 23:57:16 +09006217
6218$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
6219 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Chab26bf582021-06-08 11:31:31 +09006220
6221ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006222ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006223 $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006224endif
6225ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006226 $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006227endif
Jeongik Chab26bf582021-06-08 11:31:31 +09006228endif #!TARGET_BUILD_UNBUNDLED
Jeongik Chaa8056d62021-04-07 23:57:16 +09006229 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
6230
Jeongik Chab26bf582021-06-08 11:31:31 +09006231.PHONY: dexpreopt_config_zip
6232dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
6233
Bob Badour5acd4362022-04-12 18:31:35 -07006234$(call declare-1p-target,$(DEXPREOPT_CONFIG_ZIP),)
6235
Dario Frenid1011272018-07-23 20:20:15 +01006236# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006237# A zip of the symbols directory. Keep the full paths to make it
6238# more obvious where these files came from.
Colin Crossac7febc2022-04-06 01:11:20 +00006239# Also produces a textproto containing mappings from elf IDs to symbols
6240# filename, which will allow finding the appropriate symbols to deobfuscate
6241# a stack trace frame.
The Android Open Source Project88b60792009-03-03 19:28:42 -08006242#
Colin Crossac7febc2022-04-06 01:11:20 +00006243
The Android Open Source Project88b60792009-03-03 19:28:42 -08006244name := $(TARGET_PRODUCT)
6245ifeq ($(TARGET_BUILD_TYPE),debug)
6246 name := $(name)_debug
6247endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006248
Colin Crossac7febc2022-04-06 01:11:20 +00006249# The path to the zip file containing binaries with symbols.
6250SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols-$(FILE_NAME_TAG).zip
6251# The path to a file containing mappings from elf IDs to filenames.
6252SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping-$(FILE_NAME_TAG).textproto
6253.KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING
Colin Cross6cdc5d22017-10-20 11:37:33 -07006254# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006255ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006256$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07006257endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006258$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
Colin Crossac7febc2022-04-06 01:11:20 +00006259$(SYMBOLS_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)
6260$(SYMBOLS_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006261 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006262 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006263 $(hide) mkdir -p $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE)) $(PRIVATE_MAPPING_PACKAGING_DIR)
6264 # Find all of the files in the symbols directory and zip them into the symbols zip.
Jiyong Park88e09802019-03-21 15:19:16 +09006265 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07006266 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006267 # Find all of the files in the symbols mapping directory and merge them into the symbols mapping textproto.
6268 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6269 $(hide) $(SYMBOLS_MAP) -merge $(SYMBOLS_MAPPING) -ignore_missing_files @$(PRIVATE_LIST_FILE)
6270$(SYMBOLS_ZIP): .KATI_IMPLICIT_OUTPUTS := $(SYMBOLS_MAPPING)
6271
Bob Badour5acd4362022-04-12 18:31:35 -07006272$(call declare-1p-container,$(SYMBOLS_ZIP),)
6273ifeq (,$(TARGET_BUILD_UNBUNDLED))
6274$(call declare-container-license-deps,$(SYMBOLS_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6275endif
6276
Ryan Campbell81c9d292016-09-12 13:56:50 -07006277# -----------------------------------------------------------------
6278# A zip of the coverage directory.
6279#
Oliver Nguyene91ab232019-04-30 15:14:44 -07006280name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07006281ifeq ($(TARGET_BUILD_TYPE),debug)
6282name := $(name)_debug
6283endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07006284COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006285ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006286$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07006287endif
6288$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
6289$(COVERAGE_ZIP): $(SOONG_ZIP)
6290 @echo "Package coverage: $@"
6291 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6292 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
6293 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
6294 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006295
Bob Badourf2529722022-03-18 11:34:03 -07006296$(call declare-1p-container,$(COVERAGE_ZIP),)
Bob Badour5acd4362022-04-12 18:31:35 -07006297ifeq (,$(TARGET_BUILD_UNBUNDLED))
Bob Badourf2529722022-03-18 11:34:03 -07006298$(call declare-container-license-deps,$(COVERAGE_ZIP),$(INTERNAL_ALLIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badour5acd4362022-04-12 18:31:35 -07006299endif
Bob Badourf2529722022-03-18 11:34:03 -07006300
6301SYSTEM_NOTICE_DEPS += $(COVERAGE_ZIP)
6302
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006303#------------------------------------------------------------------
6304# Export the LLVM profile data tool and dependencies for Clang coverage processing
6305#
6306ifeq (true,$(CLANG_COVERAGE))
6307 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006308 LLVM_COV := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006309 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006310 # Use llvm-profdata.zip for backwards compatibility with tradefed code.
6311 LLVM_COVERAGE_TOOLS_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006312
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006313 $(LLVM_COVERAGE_TOOLS_ZIP): $(SOONG_ZIP)
6314 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX) -f $(LLVM_COV)
6315
6316 $(call dist-for-goals,droidcore-unbundled apps_only,$(LLVM_COVERAGE_TOOLS_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006317endif
6318
The Android Open Source Project88b60792009-03-03 19:28:42 -08006319# -----------------------------------------------------------------
6320# A zip of the Android Apps. Not keeping full path so that we don't
6321# include product names when distributing
6322#
6323name := $(TARGET_PRODUCT)
6324ifeq ($(TARGET_BUILD_TYPE),debug)
6325 name := $(name)_debug
6326endif
6327name := $(name)-apps-$(FILE_NAME_TAG)
6328
6329APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07006330$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006331 @echo "Package apps: $@"
6332 $(hide) rm -rf $@
6333 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006334 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
6335 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00006336 echo "No apps to zip up. Generating empty apps archive." ; \
6337 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006338 else \
Anton Hansson6d814982018-11-26 18:12:05 +00006339 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006340 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07006341
Ying Wangbc415dd2012-08-15 12:22:44 -07006342ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07006343#------------------------------------------------------------------
6344# An archive of classes for use in generating code-coverage reports
6345# These are the uninstrumented versions of any classes that were
6346# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07006347# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006348
Colin Crossa6bc3a82017-09-27 14:28:41 -07006349JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Colin Cross330b1fe2021-04-06 18:04:06 -07006350$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
6351$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
6352$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
6353$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006354$(JACOCO_REPORT_CLASSES_ALL) :
6355 @echo "Collecting uninstrumented classes"
Colin Cross330b1fe2021-04-06 18:04:06 -07006356 mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
6357 $(SOONG_ZIP) -o $@ -L 0 \
6358 -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
6359 -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
6360 -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
6361 -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006362
Jiyong Park3c875602021-01-21 12:46:56 +09006363ifeq (,$(TARGET_BUILD_UNBUNDLED))
6364 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
6365endif
Ying Wangbc415dd2012-08-15 12:22:44 -07006366endif # EMMA_INSTRUMENT=true
6367
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006368
Ying Wangae9115a2013-08-22 20:52:47 -07006369#------------------------------------------------------------------
6370# A zip of Proguard obfuscation dictionary files.
Colin Crossac7febc2022-04-06 01:11:20 +00006371# Also produces a textproto containing mappings from the hashes of the
6372# dictionary contents (which are also stored in the dex files on the
6373# devices) to the filename of the proguard dictionary, which will allow
6374# finding the appropriate dictionary to deobfuscate a stack trace frame.
Ying Wangae9115a2013-08-22 20:52:47 -07006375#
Colin Crossac7febc2022-04-06 01:11:20 +00006376
6377# The path to the zip file containing proguard dictionaries.
Ying Wangc62c92c2013-08-28 18:38:25 -07006378PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Crossac7febc2022-04-06 01:11:20 +00006379# The path to the zip file containing mappings from dictionary hashes to filenames.
6380PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping-$(FILE_NAME_TAG).textproto
6381.KATI_READONLY := PROGUARD_DICT_ZIP PROGUARD_DICT_MAPPING
Colin Cross114e8df2019-09-05 17:19:35 -07006382# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006383ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006384$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07006385endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006386$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
Colin Crossac7febc2022-04-06 01:11:20 +00006387$(PROGUARD_DICT_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)
6388$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_filelist)/filelist
6389$(PROGUARD_DICT_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
Ying Wangae9115a2013-08-22 20:52:47 -07006390 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossac7febc2022-04-06 01:11:20 +00006391 rm -rf $@ $(PRIVATE_LIST_FILE)
6392 mkdir -p $(PRIVATE_PACKAGING_DIR) $(PRIVATE_MAPPING_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6393 # Zip all of the files in the proguard dictionary directory.
6394 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -D $(PRIVATE_PACKAGING_DIR)
6395 # Find all of the files in the proguard dictionary mapping directory and merge them into the mapping textproto.
6396 # Strip the PRIVATE_PACKAGING_DIR off the filenames to match soong_zip's -C argument.
6397 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6398 $(SYMBOLS_MAP) -merge $(PROGUARD_DICT_MAPPING) -strip_prefix $(PRIVATE_PACKAGING_DIR)/ -ignore_missing_files @$(PRIVATE_LIST_FILE)
6399$(PROGUARD_DICT_ZIP): .KATI_IMPLICIT_OUTPUTS := $(PROGUARD_DICT_MAPPING)
Ying Wangae9115a2013-08-22 20:52:47 -07006400
Bob Badour5acd4362022-04-12 18:31:35 -07006401$(call declare-1p-container,$(PROGUARD_DICT_ZIP),)
6402ifeq (,$(TARGET_BUILD_UNBUNDLED))
6403$(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6404endif
6405
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006406#------------------------------------------------------------------
6407# A zip of Proguard usage files.
6408#
6409PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
6410# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
6411ifeq (,$(TARGET_BUILD_UNBUNDLED))
6412$(PROGUARD_USAGE_ZIP): \
6413 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6414 $(INSTALLED_RAMDISK_TARGET) \
6415 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00006416 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006417 $(INSTALLED_USERDATAIMAGE_TARGET) \
6418 $(INSTALLED_VENDORIMAGE_TARGET) \
6419 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6420 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6421 $(INSTALLED_ODMIMAGE_TARGET) \
6422 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6423 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00006424 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006425 $(updater_dep)
6426endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006427$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
6428$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006429$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
6430 @echo "Packaging Proguard usage files."
Colin Cross330b1fe2021-04-06 18:04:06 -07006431 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6432 find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006433 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07006434
Bob Badour5acd4362022-04-12 18:31:35 -07006435$(call declare-1p-container,$(PROGUARD_USAGE_ZIP),)
6436ifeq (,$(TARGET_BUILD_UNBUNDLED))
6437$(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(INSTALLED_SYSTEMIMAGE_TARGET) \
6438 $(INSTALLED_RAMDISK_TARGET) \
6439 $(INSTALLED_BOOTIMAGE_TARGET) \
6440 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
6441 $(INSTALLED_USERDATAIMAGE_TARGET) \
6442 $(INSTALLED_VENDORIMAGE_TARGET) \
6443 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6444 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6445 $(INSTALLED_ODMIMAGE_TARGET) \
6446 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6447 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
6448 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
6449 $(updater_dep),$(PROGUARD_USAGE_ZIP):/)
6450endif
6451
Tao Bao48a2feb2019-06-28 11:00:05 -07006452ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6453
6454# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
6455# $(1): output file
6456define dump-super-image-info
6457 $(call dump-dynamic-partitions-info,$(1))
6458 $(if $(filter true,$(AB_OTA_UPDATER)), \
6459 echo "ab_update=true" >> $(1))
6460endef
6461
6462endif # PRODUCT_USE_DYNAMIC_PARTITIONS
6463
The Android Open Source Project88b60792009-03-03 19:28:42 -08006464# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07006465# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08006466
6467ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6468
6469# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
6470ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6471
6472ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07006473
6474# For real devices and for dist builds, build super image from target files to an intermediate directory.
6475INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
6476$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
6477$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
6478 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08006479 PATH=$(dir $(LPMAKE)):$$PATH \
6480 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07006481
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006482# Skip packing it in dist package because it is in update package.
6483ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07006484$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006485endif
Yifan Hongacd862a2019-04-16 15:44:30 -07006486
6487.PHONY: superimage_dist
6488superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07006489
6490endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07006491endif # BOARD_SUPER_PARTITION_SIZE != ""
6492endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08006493
Yifan Hongacd862a2019-04-16 15:44:30 -07006494# -----------------------------------------------------------------
6495# super partition image for development
6496
6497ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6498ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6499ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
6500
6501# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
6502# $(1): built image path
6503# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
6504define build-superimage-target
6505 mkdir -p $(dir $(2))
6506 rm -rf $(2)
6507 $(call dump-super-image-info,$(2))
6508 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
6509 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09006510 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
6511 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07006512 mkdir -p $(dir $(1))
6513 PATH=$(dir $(LPMAKE)):$$PATH \
6514 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
6515endef
6516
6517INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
6518INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
6519 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
6520
changho.shina8f9f112019-10-15 13:26:19 +09006521ifdef BUILDING_SYSTEM_OTHER_IMAGE
6522ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
6523INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
6524endif
6525endif
6526
Yifan Hongacd862a2019-04-16 15:44:30 -07006527# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
6528# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
6529# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
6530# virtual devices.
6531ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
6532$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6533 $(call pretty,"Target super fs image for debug: $@")
6534 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08006535 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006536
Bill Peckham315b98a2021-06-15 19:35:06 -07006537droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
Yifan Hongacd862a2019-04-16 15:44:30 -07006538
6539# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
6540.PHONY: superimage
6541superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08006542
6543$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006544endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
6545
6546# Build $(PRODUCT_OUT)/super.img without dependencies.
6547.PHONY: superimage-nodeps supernod
6548superimage-nodeps supernod: intermediates :=
6549superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6550 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
6551 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
6552 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
6553
6554endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
6555endif # BOARD_SUPER_PARTITION_SIZE != ""
6556endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
6557
6558# -----------------------------------------------------------------
6559# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00006560ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006561
Yifan Hong8b79d162018-11-29 12:32:00 -08006562INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
6563$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
6564$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
6565 $(call pretty,"Target empty super fs image: $@")
6566 mkdir -p $(intermediates)
6567 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07006568 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08006569 PATH=$(dir $(LPMAKE)):$$PATH \
6570 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08006571
6572$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6573
Bob Badour70c07dd2022-02-12 15:39:22 -08006574$(call declare-0p-target,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6575
Yo Chiange86bab42021-03-25 10:12:28 +00006576endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006577
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006578
6579# -----------------------------------------------------------------
6580# The update package
6581
6582name := $(TARGET_PRODUCT)
6583ifeq ($(TARGET_BUILD_TYPE),debug)
6584 name := $(name)_debug
6585endif
6586name := $(name)-img-$(FILE_NAME_TAG)
6587
6588INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6589
Tao Bao57f8ed62019-08-14 23:08:18 -07006590$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
6591 $(call pretty,"Package: $@")
6592 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
6593 $(IMG_FROM_TARGET_FILES) \
6594 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
6595 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006596
Bob Badour5acd4362022-04-12 18:31:35 -07006597$(call declare-1p-container,$(INTERNAL_UPDATE_PACKAGE_TARGET),)
6598$(call declare-container-license-deps,$(INTERNAL_UPDATE_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES),$(PRODUCT_OUT)/:/)
6599
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006600.PHONY: updatepackage
6601updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07006602$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006603
6604
Yifan Hong2b891ac2018-11-29 12:06:31 -08006605# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006606# dalvik something
6607.PHONY: dalvikfiles
6608dalvikfiles: $(INTERNAL_DALVIK_MODULES)
6609
Bo Huf0d50bb2017-08-01 19:02:09 +00006610ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00006611MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08006612MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00006613SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08006614
6615ifdef INSTALLED_SYSTEMIMAGE_TARGET
6616INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08006617INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
6618$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
6619 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
6620 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08006621$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08006622 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
6623 @echo Create system-qemu.img now
6624 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08006625 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00006626
6627systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006628droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08006629endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006630ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00006631INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006632$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00006633 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006634 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00006635
6636vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006637droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
Bo Huf0d50bb2017-08-01 19:02:09 +00006638endif
bohu8fd437c2020-03-30 20:16:13 -07006639
6640ifdef INSTALLED_RAMDISK_TARGET
6641ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
6642ifdef INTERNAL_VENDOR_RAMDISK_TARGET
6643INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
6644$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
6645 @echo Create ramdisk-qemu.img
6646 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
6647
Bill Peckham315b98a2021-06-15 19:35:06 -07006648droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
bohu8fd437c2020-03-30 20:16:13 -07006649endif
6650endif
6651endif
6652
Anton Hansson32c76fe2018-12-13 14:34:18 +00006653ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006654INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006655$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006656 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006657 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006658
6659productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006660droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006661endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006662ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
6663INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
6664$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
6665 @echo Create system_ext-qemu.img
6666 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01006667
Justin Yun6151e3f2019-06-25 15:58:13 +09006668systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006669droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01006670endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006671ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006672INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
6673$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6674 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006675 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006676
6677odmimage: $(INSTALLED_QEMU_ODMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006678droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006679endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006680
Yifan Hongcfb917a2020-05-07 14:58:20 -07006681ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
6682INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
6683$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6684 @echo Create vendor_dlkm-qemu.img
6685 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
6686
6687vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006688droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07006689endif
6690
Yifan Hongf496f1b2020-07-15 16:52:59 -07006691ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
6692INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
6693$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6694 @echo Create odm_dlkm-qemu.img
6695 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
6696
6697odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006698droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07006699endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006700
Ramji Jiyani13a41372022-01-27 07:05:08 +00006701ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
6702INSTALLED_QEMU_SYSTEM_DLKMIMAGE := $(PRODUCT_OUT)/system_dlkm-qemu.img
6703$(INSTALLED_QEMU_SYSTEM_DLKMIMAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6704 @echo Create system_dlkm-qemu.img
6705 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET))
6706
6707system_dlkmimage: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6708droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6709endif
6710
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006711QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08006712$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
6713 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006714 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08006715 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
6716 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006717
6718systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
Bill Peckham315b98a2021-06-15 19:35:06 -07006719droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08006720
Bo Huf0d50bb2017-08-01 19:02:09 +00006721endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006722# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006723# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07006724ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006725INTERNAL_EMULATOR_PACKAGE_FILES += \
6726 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006727 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07006728 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6729 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006730
6731name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
6732
6733INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6734
Ying Wang5d887702015-11-04 10:06:25 -08006735$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006736 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07006737 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006738
Ying Wang7d8c5352012-07-26 10:15:21 -07006739endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08006740
The Android Open Source Project88b60792009-03-03 19:28:42 -08006741
6742# -----------------------------------------------------------------
6743# The SDK
6744
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006745ifneq ($(filter sdk,$(MAKECMDGOALS)),)
6746
The Android Open Source Project88b60792009-03-03 19:28:42 -08006747# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07006748sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006749
6750# Build a name that looks like:
6751#
6752# linux-x86 --> android-sdk_12345_linux-x86
6753# darwin-x86 --> android-sdk_12345_mac-x86
6754# windows-x86 --> android-sdk_12345_windows
6755#
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006756ifneq ($(HOST_OS),linux)
6757 $(error Building the monolithic SDK is only supported on Linux)
6758endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006759sdk_name := android-sdk_$(FILE_NAME_TAG)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006760INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH)
Joe Onorato03fbe402009-04-13 08:31:16 -07006761sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006762
6763sdk_dep_file := $(sdk_dir)/sdk_deps.mk
6764
6765ATREE_FILES :=
6766-include $(sdk_dep_file)
6767
6768# if we don't have a real list, then use "everything"
6769ifeq ($(strip $(ATREE_FILES)),)
6770ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006771 $(ALL_DOCS) \
6772 $(ALL_SDK_FILES)
6773endif
6774
6775atree_dir := development/build
6776
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01006777
Dan Willemsen53c98f72021-10-16 16:49:06 -07006778sdk_atree_files := $(atree_dir)/sdk.exclude.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08006779
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02006780# development/build/sdk-android-<abi>.atree is used to differentiate
6781# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
6782# files like the kernel image. We use TARGET_CPU_ABI because we don't
6783# have a better way to distinguish between CPU models.
6784ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
6785 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
6786endif
6787
Anton Hansson8dab0a62019-03-28 15:45:40 +00006788ifneq ($(PRODUCT_SDK_ATREE_FILES),)
6789sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08006790else
6791sdk_atree_files += $(atree_dir)/sdk.atree
6792endif
6793
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07006794include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07006795
The Android Open Source Project88b60792009-03-03 19:28:42 -08006796deps := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006797 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01006798 $(SDK_METADATA_FILES) \
Anton Hansson55a8f022022-05-12 08:45:29 +00006799 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006800 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08006801 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006802 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07006803 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07006804 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006805
6806INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
6807$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
6808$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
6809$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
6810$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
6811
6812# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
6813#
6814#SDK_GNU_ERROR := true
6815
Ying Wang5d887702015-11-04 10:06:25 -08006816$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006817 @echo "Package SDK: $@"
6818 $(hide) rm -rf $(PRIVATE_DIR) $@
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07006819 $(hide) for f in $(strip $(target_gnu_MODULES)); do \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006820 if [ -f $$f ]; then \
6821 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
6822 including GNU target $$f >&2; \
6823 FAIL=$(SDK_GNU_ERROR); \
6824 fi; \
6825 done; \
6826 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07006827 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08006828 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00006829 ATREE_STRIP="$(HOST_STRIP) -x" \
6830 $(HOST_OUT_EXECUTABLES)/atree \
6831 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
6832 -m $(PRIVATE_DEP_FILE) \
6833 -I . \
6834 -I $(PRODUCT_OUT) \
6835 -I $(HOST_OUT) \
6836 -I $(TARGET_COMMON_OUT_ROOT) \
6837 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
6838 -v "OUT_DIR=$(OUT_DIR)" \
6839 -v "HOST_OUT=$(HOST_OUT)" \
6840 -v "TARGET_ARCH=$(TARGET_ARCH)" \
6841 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
6842 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
6843 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
6844 -o $(PRIVATE_DIR) && \
Anton Hansson6d814982018-11-26 18:12:05 +00006845 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
6846 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
6847 chmod -R ug+rwX $(PRIVATE_DIR) && \
6848 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006849 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
6850
Raphaelc4d47312011-02-15 16:09:36 -08006851MAIN_SDK_DIR := $(sdk_dir)
6852MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006853
6854endif # sdk in MAKECMDGOALS
Raphael3d224a02010-04-16 17:50:09 -07006855
The Android Open Source Project88b60792009-03-03 19:28:42 -08006856# -----------------------------------------------------------------
6857# Findbugs
6858INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
6859INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
6860$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
6861 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006862 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006863 > $@
6864$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
6865 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006866 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07006867 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08006868
6869# -----------------------------------------------------------------
6870# Findbugs
6871
6872# -----------------------------------------------------------------
6873# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07006874ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006875include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01006876-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07006877-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006878-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07006879# Also the project-specific tasks
6880-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
6881-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006882-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07006883# Also add test specifc tasks
6884include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07006885include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07006886endif
Raphaelc4d47312011-02-15 16:09:36 -08006887
Ying Wang67132ba2015-10-28 16:42:39 -07006888include $(BUILD_SYSTEM)/product-graph.mk
6889
Raphaelc4d47312011-02-15 16:09:36 -08006890# -----------------------------------------------------------------
6891# Create SDK repository packages. Must be done after tasks/* since
6892# we need the addon rules defined.
6893ifneq ($(sdk_repo_goal),)
6894include $(TOPDIR)development/build/tools/sdk_repo.mk
6895endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07006896
6897# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07006898# Soong generates the list of all shared libraries that are depended on by fuzz
6899# targets. It saves this list as a source:destination pair to
6900# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
6901# build of the unstripped shared library, and the destination is the
6902# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
6903# where fuzz target shared libraries are to be "reinstalled". The
6904# copy-many-files below generates the rules to copy the unstripped shared
6905# libraries to the device or host "reinstallation" directory. These rules are
6906# depended on by each module in soong_cc_prebuilt.mk, where the module will have
6907# a dependency on each shared library that it needs to be "reinstalled".
6908FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
6909
6910# -----------------------------------------------------------------
hamzeh5dfe7a22021-04-29 12:44:16 -07006911# The rule to build all fuzz targets for C++ and Rust, and package them.
Mitch Phillipsceefc442019-09-26 16:37:59 -07006912# Note: The packages are created in Soong, and in a perfect world,
6913# we'd be able to create the phony rule there. But, if we want to
6914# have dist goals for the fuzz target, we need to have the PHONY
6915# target defined in make. MakeVarsContext.DistForGoal doesn't take
6916# into account that a PHONY rule create by Soong won't be available
6917# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08006918# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07006919# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08006920.PHONY: haiku
6921haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
6922$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
hamzeh5dfe7a22021-04-29 12:44:16 -07006923
Muhammad Haseeb Ahmadcced1362022-01-13 03:17:39 +00006924.PHONY: haiku-java
6925haiku-java: $(SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_TARGETS)
6926$(call dist-for-goals,haiku-java,$(SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES))
6927
hamzeh5dfe7a22021-04-29 12:44:16 -07006928.PHONY: haiku-rust
6929haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
6930$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))
Bob Badour70c07dd2022-02-12 15:39:22 -08006931
6932
6933# -----------------------------------------------------------------
6934# OS Licensing
6935
6936include $(BUILD_SYSTEM)/os_licensing.mk
6937
6938# When appending new code to this file, please insert above OS Licensing