blob: 8767222a1841f5bbee440646ed8448f454c91826 [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
Bill Peckham315b98a2021-06-15 19:35:06 -070097$(call dist-for-goals,droidcore-unbundled,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
Dan Willemsen7537fd02018-10-16 23:15:08 -070098
99pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -0800100product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -0700101unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -0700102unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800103
104# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800105# Returns the max allowed size for an image suitable for hash verification
106# (e.g., boot.img, recovery.img, etc).
107# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
108# $(1): partition size to flash the image
109define get-hash-image-max-size
110$(if $(1), \
111 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
112 $(eval _hash_meta_size := 69632), \
113 $(eval _hash_meta_size := 0)) \
114 $(1)-$(_hash_meta_size))
115endef
116
117# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800118# Define rules to copy headers defined in copy_headers.mk
119# If more than one makefile declared a header, print a warning,
120# then copy the last one defined. This matches the previous make
121# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700122has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800123$(foreach dest,$(ALL_COPIED_HEADERS), \
124 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800125 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800126 $(if $(call streq,$(_src),$(_srcs)),, \
127 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800128 $(warning _ Using $(_src)) \
129 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
130 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
131 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
132 $(warning _ Ignoring $(src)) \
133 $(warning __ from $(firstword $(_makefiles))) \
134 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
135 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800136 $(eval $(call copy-one-header,$(_src),$(dest))))
137all_copied_headers: $(ALL_COPIED_HEADERS)
138
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700139ifdef has_dup_copy_headers
140 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700141 $(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 -0700142endif
143
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800144$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
145
Dan Willemsen6f60f022016-02-23 13:40:07 -0800146# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800147# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100148ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800149gen := $(OUT_DOCS)/index.html
150ALL_DOCS += $(gen)
151$(gen): frameworks/base/docs/docs-redirect-index.html
152 @mkdir -p $(dir $@)
153 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700154endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800155
Dan Albert303e6032017-10-04 10:20:20 -0700156ndk_doxygen_out := $(OUT_NDK_DOCS)
157ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
158ndk_docs_src_dir := frameworks/native/docs
159ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
160ifneq ($(wildcard $(ndk_docs_src_dir)),)
161ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
162 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
163$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
164 @mkdir -p $(ndk_doxygen_out)
165 @echo "Generating NDK docs to $(ndk_doxygen_out)"
166 @( cat $(ndk_doxyfile); \
167 echo "INPUT=$(ndk_headers)"; \
168 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
169 ) | doxygen -
170
171# Note: Not a part of the docs target because we don't have doxygen available.
172# You can run this target locally if you have doxygen installed.
173ndk-docs: $(ndk_doxygen_out)/index.html
174.PHONY: ndk-docs
175endif
176
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700177ifeq ($(HOST_OS),linux)
Colin Crossd60401a2019-04-18 14:46:48 -0700178$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700179endif
Dan Willemsenad6a1542018-12-14 01:04:19 -0800180
Andres Moralesb8876e12015-05-06 20:44:22 -0700181INSTALLED_RECOVERYIMAGE_TARGET :=
Yifan Hong881df392020-10-09 14:29:39 -0700182# Build recovery image if
183# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
184# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
185# with recovery resources.
186# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
187# but not the final recovery image.
Chris Grossa784ef12019-04-22 11:09:57 -0700188ifdef BUILDING_RECOVERY_IMAGE
189ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong881df392020-10-09 14:29:39 -0700190ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -0700191INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
192endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700193endif
Yifan Hong881df392020-10-09 14:29:39 -0700194endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700195
Jiyong Parke1346862020-05-18 14:31:30 +0900196include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100197
198# ----------------------------------------------------------------
199
200# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800201# sdk-build.prop
202#
203# There are certain things in build.prop that we don't want to
204# ship with the sdk; remove them.
205
206# This must be a list of entire property keys followed by
207# "=" characters, without any internal spaces.
208sdk_build_prop_remove := \
209 ro.build.user= \
210 ro.build.host= \
211 ro.product.brand= \
212 ro.product.manufacturer= \
213 ro.product.device=
214# TODO: Remove this soon-to-be obsolete property
215sdk_build_prop_remove += ro.build.product=
216INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
217$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
218 @echo SDK buildinfo: $@
219 @mkdir -p $(dir $@)
220 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000221 $(sdk_build_prop_remove)))" $< > $@.tmp
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700222 $(hide) for x in $(strip $(sdk_build_prop_remove)); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000223 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800224 $(hide) mv $@.tmp $@
225
226# -----------------------------------------------------------------
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800227# declare recovery ramdisk files
228ifeq ($(BUILDING_RECOVERY_IMAGE),true)
229INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
230endif
231
232# -----------------------------------------------------------------
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800233# Declare vendor ramdisk fragments
234INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
235
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800236ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
237 ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
238 $(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \
239 BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set)
240 endif
241 INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery
242 VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT)
243 VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
244 BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY
245 .KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR
246endif
247
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800248# Validation check and assign default --ramdisk_type.
249$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
250 $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
251 $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
252 $(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))) \
253 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
254 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
255 $(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
256 $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
257 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
258)
259
260# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
261$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
262 $(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
263 $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
264 $(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)) \
265 $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
266 ) \
267)
268INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
269
Yi-Yo Chiang378b7792021-04-09 20:09:13 +0800270# Strip the list in case of any whitespace.
271INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \
272 $(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS))
273
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800274# Assign --ramdisk_name for each vendor ramdisk fragment.
275$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
276 $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
277 $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
278 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
279 $(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
280)
281
282# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700283# kernel modules
284
285# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
286DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
287
J. Avilaa2ceec62020-05-12 23:40:02 +0000288define copy-and-strip-kernel-module
289$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000290 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000291endef
292
Colin Cross4f60e362019-06-05 11:53:43 -0700293# $(1): modules list
294# $(2): output dir
295# $(3): mount point
296# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700297# $(5): module load list
298# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800299# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000300# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700301# $(9): module directory name
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800302# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700303define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700304 $(if $(9), \
305 $(eval _dir := $(9)/), \
306 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000307 $(foreach module,$(1), \
308 $(eval _src := $(module)) \
309 $(if $(8), \
310 $(eval _src := $(8)/$(notdir $(module))) \
311 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700312 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700313 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700314 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
315 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
316 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
317 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700318endef
319
320# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700321# $(2): mount point
322# $(3): staging dir
323# $(4): module load list
324# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800325# $(6): module archive
326# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700327# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800328# TODO(b/144844424): If a module archive is being used, this step (which
329# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
330# the output directory. This should be moved to a module with a
331# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
332# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700333define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700334$(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 -0700335$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700336$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
Steve Muckle474e4d02019-06-19 12:56:48 -0700337$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700338$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700339$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700340$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
Steve Muckle474e4d02019-06-19 12:56:48 -0700341$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800342$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
343$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
344$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700345 @echo depmod $$(PRIVATE_STAGING_DIR)
346 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700347 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800348 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700349 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800350 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700351 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800352 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
353 )
354 $(if $(1),\
355 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
356 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
357 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
358 done; \
359 )
Colin Cross4f60e362019-06-05 11:53:43 -0700360 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
361 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700362 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
363 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700364endef
365
Steve Muckle474e4d02019-06-19 12:56:48 -0700366# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700367# $(2): modules list
368# $(3): module load list
369# $(4): module load list filename
370# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700371define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700372 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
373 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700374endef
375
376# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700377# $(2): modules list
378# $(3): module load list
379# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700380define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700381$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
382$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
383 @echo load-list $$(@)
384 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700385endef
386
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800387# $(1): source options file
388# $(2): destination pathname
389# Returns a build rule that checks the syntax of and installs a kernel modules
390# options file. Strip and squeeze any extra space and blank lines.
391# For use via $(eval).
392define build-image-kernel-modules-options-file
393$(2): $(1)
394 @echo "libmodprobe options $$(@)"
395 $(hide) mkdir -p "$$(dir $$@)"
396 $(hide) rm -f "$$@"
397 $(hide) awk <"$$<" >"$$@" \
398 '/^#/ { print; next } \
399 NF == 0 { next } \
400 NF < 2 || $$$$1 != "options" \
401 { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
402 exit_status = 1; next } \
403 { $$$$1 = $$$$1; print } \
404 END { exit exit_status }'
405endef
406
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800407# $(1): source blocklist file
408# $(2): destination pathname
409# Returns a build rule that checks the syntax of and installs a kernel modules
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800410# blocklist file. Strip and squeeze any extra space and blank lines.
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800411# For use via $(eval).
412define build-image-kernel-modules-blocklist-file
413$(2): $(1)
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800414 @echo "libmodprobe blocklist $$(@)"
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800415 $(hide) mkdir -p "$$(dir $$@)"
416 $(hide) rm -f "$$@"
417 $(hide) awk <"$$<" >"$$@" \
418 '/^#/ { print; next } \
419 NF == 0 { next } \
420 NF != 2 || $$$$1 != "blocklist" \
421 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
422 exit_status = 1; next } \
423 { $$$$1 = $$$$1; print } \
424 END { exit exit_status }'
425endef
426
Steve Muckle2335d762020-05-28 18:39:38 -0700427# $(1): image name
428# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
429# $(3): mount point
430# $(4): module load filename
431# $(5): stripped staging directory
432# $(6): kernel module directory name (top is an out of band value for no directory)
433define build-image-kernel-modules-dir
434$(if $(filter top,$(6)),\
435 $(eval _kver :=)$(eval _sep :=),\
436 $(eval _kver := $(6))$(eval _sep :=_))\
437$(if $(5),\
438 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
439 $(eval _stripped_staging_dir :=))\
440$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
441 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
442 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800443 $(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 +0800444$(if $(_kver), \
445 $(eval _dir := $(_kver)/), \
446 $(eval _dir :=)) \
447$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
448 $(eval $(call build-image-kernel-modules-options-file, \
449 $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
450 $(2)/lib/modules/$(_dir)modules.options)) \
451 $(2)/lib/modules/$(_dir)modules.options) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800452$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
453 $(eval $(call build-image-kernel-modules-blocklist-file, \
454 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800455 $(2)/lib/modules/$(_dir)modules.blocklist)) \
456 $(2)/lib/modules/$(_dir)modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700457endef
458
459# $(1): kernel module directory name (top is an out of band value for no directory)
460define build-recovery-as-boot-load
461$(if $(filter top,$(1)),\
462 $(eval _kver :=)$(eval _sep :=),\
463 $(eval _kver := $(1))$(eval _sep :=_))\
464 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
465 $(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))))
466endef
467
468# $(1): kernel module directory name (top is an out of band value for no directory)
469define build-vendor-ramdisk-recovery-load
470$(if $(filter top,$(1)),\
471 $(eval _kver :=)$(eval _sep :=),\
472 $(eval _kver := $(1))$(eval _sep :=_))\
473 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
474 $(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))))
475endef
476
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700477# $(1): kernel module directory name (top is an out of band value for no directory)
478define build-vendor-charger-load
479$(if $(filter top,$(1)),\
480 $(eval _kver :=)$(eval _sep :=),\
481 $(eval _kver := $(1))$(eval _sep :=_))\
482 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
483 $(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))))
484endef
485
Steve Mucklee1b10862019-07-10 10:49:37 -0700486ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
487 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
488 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700489 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700490 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
491endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700492
Steve Muckle69280d22019-07-11 12:23:38 -0700493ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
494 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700495endif
496
Steve Mucklee1b10862019-07-10 10:49:37 -0700497ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700498 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700499 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700500 endif
501endif
502
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800503ifneq ($(BOARD_DO_NOT_STRIP_RECOVERY_MODULES),true)
504 RECOVERY_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery_stripped)
505else
506 RECOVERY_STRIPPED_MODULE_STAGING_DIR :=
507endif
508
J. Avilaa2ceec62020-05-12 23:40:02 +0000509ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
510 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
511else
512 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
513endif
Colin Cross4f60e362019-06-05 11:53:43 -0700514
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700515ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
516 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
517else
518 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
519endif
520
Steve Muckle2335d762020-05-28 18:39:38 -0700521BOARD_KERNEL_MODULE_DIRS += top
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800522$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800523 $(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 +0800524 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800525 $(if $(vendor_ramdisk_fragment), \
526 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
527 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
528 $(eval ### else ###), \
529 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
530 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800531 $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
532 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
533 $(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))) \
534 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
535 $(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 -0700536 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800537 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
538 $(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 -0700539
540# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800541# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700542# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900543# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700544# $2 certificate
545# $3 private key
546# $4 compressed
547# $5 partition tag
548# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100549define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700550$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
551$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
552$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
553$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700554
555endef
556
Jaewoong Jung704b4542020-06-29 19:37:53 -0700557# -----------------------------------------------------------------
558# Merge an individual apkcerts output into the final apkcerts.txt output.
559# Use a macro to make it compatible with _apkcerts_write_line
560# $1 apkcerts file to be merged
561# $2 output file
562define _apkcerts_merge
563$(hide) cat $1 >> $2
564
565endef
566
The Android Open Source Project88b60792009-03-03 19:28:42 -0800567name := $(TARGET_PRODUCT)
568ifeq ($(TARGET_BUILD_TYPE),debug)
569 name := $(name)_debug
570endif
571name := $(name)-apkcerts-$(FILE_NAME_TAG)
572intermediates := \
573 $(call intermediates-dir-for,PACKAGING,apkcerts)
574APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700575all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
576$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800577# We don't need to really build all the modules.
578# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700579$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580 @echo APK certs list: $@
581 @mkdir -p $(dir $@)
582 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700583 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700584 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
585 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
586 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700587 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700588 $(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 +0900589 $(if $(filter true,$(PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA)),\
590 $(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 -0700591 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700592 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800593
594.PHONY: apkcerts-list
595apkcerts-list: $(APKCERTS_FILE)
596
Ying Wang15e487a2011-02-15 10:56:18 -0800597ifneq (,$(TARGET_BUILD_APPS))
598 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900599 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800600endif
Ying Wangefb21682010-07-23 16:42:13 -0700601
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900602
The Android Open Source Project88b60792009-03-03 19:28:42 -0800603# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700604# build system stats
605BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
606$(BUILD_SYSTEM_STATS):
607 @rm -f $@
608 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
609 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
Bill Peckham315b98a2021-06-15 19:35:06 -0700610$(call dist-for-goals,droidcore-unbundled,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700611
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700612# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800613# build /product/etc/security/avb/system_other.avbpubkey if needed
614ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800615ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800616INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
617ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800618endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800619endif # BUILDING_SYSTEM_OTHER_IMAGE
620
621# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700622# Modules ready to be converted to Soong, ordered by how many
623# modules depend on them.
624SOONG_CONV := $(sort $(SOONG_CONV))
625SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
626$(SOONG_CONV_DATA):
627 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700628 @$(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 -0700629
Colin Crossfdea8932017-12-06 14:38:40 -0800630SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700631SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
632$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
633 @rm -f $@
634 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
Bill Peckham315b98a2021-06-15 19:35:06 -0700635$(call dist-for-goals,droidcore-unbundled,$(SOONG_TO_CONVERT))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700636
Joe Onorato02fb89a2020-06-27 00:10:23 -0700637MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
638MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
639$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
640$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
641 @rm -f $@
642 $(hide) $(MK2BP_CATALOG_SCRIPT) \
643 --device=$(TARGET_DEVICE) \
644 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
645 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
646 --out_dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700647 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700648 > $@
Bill Peckham315b98a2021-06-15 19:35:06 -0700649$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_HTML))
Joe Onorato02fb89a2020-06-27 00:10:23 -0700650
Joe Onorato31986072020-08-10 09:58:49 -0700651MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
652$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
653 @rm -f $@
654 $(hide) $(MK2BP_CATALOG_SCRIPT) \
655 --device=$(TARGET_DEVICE) \
656 --out_dir="$(OUT_DIR)" \
657 --mode=csv \
658 > $@
Bill Peckham315b98a2021-06-15 19:35:06 -0700659$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_CSV))
Joe Onorato31986072020-08-10 09:58:49 -0700660
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700661# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800662# Modules use -Wno-error, or added default -Wall -Werror
663WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
664$(WALL_WERROR):
665 @rm -f $@
666 echo "# Modules using -Wno-error" >> $@
667 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800668 echo "# Modules added default -Wall" >> $@
669 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
670
Bill Peckham315b98a2021-06-15 19:35:06 -0700671$(call dist-for-goals,droidcore-unbundled,$(WALL_WERROR))
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800672
673# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700674# C/C++ flag information for modules
Bill Peckham315b98a2021-06-15 19:35:06 -0700675$(call dist-for-goals,droidcore-unbundled,$(SOONG_MODULES_CFLAG_ARTIFACTS))
Jesse Paid0046922019-09-13 17:02:32 -0700676
677# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800678# Modules missing profile files
679PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
680$(PGO_PROFILE_MISSING):
681 @rm -f $@
682 echo "# Modules missing PGO profile files" >> $@
683 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
684
685$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
686
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000687CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
688$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
689 rm -f $@
690 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
691$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
692
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800693# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700694# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700695# for future OTA packages installed by this system. Actual product
696# deliverables will be re-signed by hand. We expect this file to
697# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700698DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700699
700
Jeff Browne33ba4c2011-07-11 22:11:46 -0700701# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800702# if they don't do anything.
703.PHONY: systemimage
704systemimage:
705
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800706# -----------------------------------------------------------------
707
708.PHONY: event-log-tags
709
Joe Onoratob7510532010-07-14 10:22:54 -0700710# Produce an event logs tag file for everything we know about, in order
711# to properly allocate numbers. Then produce a file that's filtered
712# for what's going to be installed.
713
714all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
715
Colin Crossdc8f8e42012-04-12 13:25:54 -0700716event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
717
Joe Onoratob7510532010-07-14 10:22:54 -0700718# Include tags from all packages that we know about
719all_event_log_tags_src := \
720 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
721
Dan Willemsena3f66322020-05-28 15:46:33 -0700722$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
723$(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 -0700724 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900725 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700726
Doug Zongkera34fa952011-02-23 12:17:29 -0800727# Include tags from all packages included in this product, plus all
728# tags that are part of the system (ie, not in a vendor/ or device/
729# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800730event_log_tags_src := \
731 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800732 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800733 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800734 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
735 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800736
Dan Willemsena3f66322020-05-28 15:46:33 -0700737$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700738$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700739$(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 -0800740 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900741 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800742
Bob Badour2f66fd12022-03-09 17:30:24 -0800743$(eval $(call declare-0p-target,$(event_log_tags_file)))
744
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800745event-log-tags: $(event_log_tags_file)
746
747ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
748
Joe Onoratob7510532010-07-14 10:22:54 -0700749
The Android Open Source Project88b60792009-03-03 19:28:42 -0800750# #################################################################
751# Targets for boot/OS images
752# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800753ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
754 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000755 ifdef BOARD_PREBUILT_BOOTLOADER
756 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
757 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
758 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800759 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
760 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
761 else
762 INSTALLED_2NDBOOTLOADER_TARGET :=
763 endif
764else
765 INSTALLED_BOOTLOADER_MODULE :=
766 INSTALLED_2NDBOOTLOADER_TARGET :=
767endif # TARGET_NO_BOOTLOADER
768ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700769 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
770 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
771 $(PRODUCT_OUT)/$(k))
772 else
773 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
774 endif
Ying Wangc6349742014-01-13 16:14:20 -0800775else
776 INSTALLED_KERNEL_TARGET :=
777endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800778
779# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700780# the root dir
781INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800782 $(ALL_GENERATED_SOURCES) \
783 $(ALL_DEFAULT_INSTALLED_MODULES))
784
Luis Hector Chavezff489932018-07-03 15:41:40 -0700785INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
786INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
787$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700788$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700789 @echo Installed file list: $@
SzuWei Linc230b0b2021-12-30 13:48:01 +0800790 mkdir -p $(TARGET_ROOT_OUT)
Petri Gynther728e0bd2021-03-06 13:29:28 -0800791 mkdir -p $(dir $@)
792 rm -f $@
793 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
794 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700795
Bob Badoure9bdbc52022-03-10 11:31:07 -0800796$(call declare-0p-target,$(INSTALLED_FILES_FILE_ROOT))
797
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700798ifeq ($(HOST_OS),linux)
Dan Willemsen39b81cd2021-09-16 14:23:07 -0700799$(call dist-for-goals, sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700800endif
Luis Hector Chavezff489932018-07-03 15:41:40 -0700801
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800802#------------------------------------------------------------------
803# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700804ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800805INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700806ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800807$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800808 cat $^ > $@
809endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700810endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800811
Tom Cherryd14b8952018-08-09 14:26:00 -0700812# -----------------------------------------------------------------
813# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800814ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700815INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
816 $(ALL_GENERATED_SOURCES) \
817 $(ALL_DEFAULT_INSTALLED_MODULES))
818
819INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
820INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
821$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700822$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700823 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800824 mkdir -p $(TARGET_RAMDISK_OUT)
825 mkdir -p $(dir $@)
826 rm -f $@
827 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
828 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700829
Bob Badour70c07dd2022-02-12 15:39:22 -0800830$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RAMDISK)))
831
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700832ifeq ($(HOST_OS),linux)
Cole Faustfdc2cd32022-01-10 18:32:17 -0800833$(call dist-for-goals, sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700834endif
Joe Onorato64d85d02009-04-09 19:31:12 -0700835BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
836
J. Avila3f6560e2020-05-11 20:20:03 +0000837ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
838# -l enables the legacy format used by the Linux kernel
839COMPRESSION_COMMAND_DEPS := $(LZ4)
840COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
841RAMDISK_EXT := .lz4
842else
843COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
844COMPRESSION_COMMAND := $(MINIGZIP)
845RAMDISK_EXT := .gz
846endif
847
Joe Onorato64d85d02009-04-09 19:31:12 -0700848# We just build this directly to the install location.
849INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900850$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
J. Avila3f6560e2020-05-11 20:20:03 +0000851$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800852 $(call pretty,"Target ramdisk: $@")
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900853 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
854ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
855 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
856endif
J. Avila3f6560e2020-05-11 20:20:03 +0000857 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800858
Bob Badour70c07dd2022-02-12 15:39:22 -0800859$(call declare-1p-container,$(INSTALLED_RAMDISK_TARGET),)
860$(call declare-container-license-deps,$(INSTALLED_RAMDISK_TARGET),$(INTERNAL_RAMDISK_FILE),$(PRODUCT_OUT)/:/)
861
862UNMOUNTED_NOTICE_DEPS += $(INSTALLED_RAMDISK_TARGET)
863
Ying Wangad7fd292013-08-08 16:34:29 -0700864.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000865ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700866 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000867 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800868
Dan Willemsen67495202019-01-16 12:42:05 -0800869endif # BUILDING_RAMDISK_IMAGE
870
The Android Open Source Project88b60792009-03-03 19:28:42 -0800871# -----------------------------------------------------------------
872# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700873
874# This is defined here since we may be building recovery as boot
875# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700876ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
877 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
878else
879 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
880endif
881
Yifan Hong0674a6e2020-10-22 14:37:01 -0700882INTERNAL_PREBUILT_BOOTIMAGE :=
883
884my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
885ifdef my_installed_prebuilt_gki_apex
886 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
887 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
888 endif # len(my_installed_prebuilt_gki_apex) > 1
889
890 ifdef BOARD_PREBUILT_BOOTIMAGE
891 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
892 endif # BOARD_PREBUILT_BOOTIMAGE defined
893
894 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
895 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
896 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
897
898 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
899
900else # my_installed_prebuilt_gki_apex not defined
901
Steve Muckle04b6f052020-08-09 14:36:56 -0700902# $1: boot image target
903# returns the kernel used to make the bootimage
904define bootimage-to-kernel
905 $(if $(BOARD_KERNEL_BINARIES),\
906 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
907 $(INSTALLED_KERNEL_TARGET))
908endef
909
Steve Muckle903a1ca2020-05-07 17:32:10 -0700910ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
911 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
912endif
913
914# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800915# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700916define get-bootimage-partition-size
Peter Collingbourne730200e2022-02-16 13:32:53 -0800917$(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
918endef
919
920# $1: partition size
921define get-partition-size-argument
922 $(if $(1),--partition_size $(1),--dynamic_partition_size)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700923endef
Chris Grossa784ef12019-04-22 11:09:57 -0700924
925ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800926INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700927 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700928
Devin Moore380d9e42021-11-04 19:01:19 +0000929INTERNAL_INIT_BOOT_IMAGE_ARGS :=
930
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700931ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Devin Moore380d9e42021-11-04 19:01:19 +0000932 ifneq ($(BUILDING_INIT_BOOT_IMAGE),true)
933 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
934 else
935 INTERNAL_INIT_BOOT_IMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
936 endif
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700937endif
938
Steve Mucklee1b10862019-07-10 10:49:37 -0700939ifndef BUILDING_VENDOR_BOOT_IMAGE
940ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
941 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
942endif
943endif
944
The Android Open Source Project88b60792009-03-03 19:28:42 -0800945INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
946
Anton Hansson8dab0a62019-03-28 15:45:40 +0000947ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700948ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000949VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700950 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
951endif
952endif
953
Anton Hansson72e36f02019-02-26 17:36:30 +0000954INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700955
Yifan Hong46aff092020-10-28 13:50:47 -0700956# kernel cmdline/base/pagesize in boot.
957# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
958# device-specific.
959# - If not using GKI:
960# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
961# - Otherwise, put them in boot.
962ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -0700963 ifdef GENERIC_KERNEL_CMDLINE
964 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
965 endif
Yifan Hong46aff092020-10-28 13:50:47 -0700966else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
967 ifdef INTERNAL_KERNEL_CMDLINE
968 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
969 endif
970 ifdef BOARD_KERNEL_BASE
971 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
972 endif
973 ifdef BOARD_KERNEL_PAGESIZE
974 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
975 endif
976endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700977
Bowgo Tsai662a2c62022-03-14 17:59:55 +0800978ifdef BOARD_GKI_SIGNING_KEY_PATH
979 # GKI boot images will not set system version & SPL value in the header.
980 # They can be set by the device manufacturer in the AVB properties instead.
981 INTERNAL_MKBOOTIMG_VERSION_ARGS :=
982else
983 INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -0700984 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +0000985 --os_patch_level $(PLATFORM_SECURITY_PATCH)
Bowgo Tsai662a2c62022-03-14 17:59:55 +0800986endif # BOARD_GKI_SIGNING_KEY_PATH
Sami Tolvanen3303d902016-03-15 16:49:30 +0000987
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +0800988# $(1): image target to certify
989# $(2): out certificate target
990# $(3): image name
991# $(4): additional AVB arguments
992define generate_generic_boot_image_certificate
993 rm -rf "$(2)"
994 mkdir -p "$(dir $(2))"
995 $(GENERATE_GKI_CERTIFICATE) $(INTERNAL_GKI_CERTIFICATE_ARGS) \
996 --additional_avb_args "$(4)" \
997 --name "$(3)" --output "$(2)" "$(1)"
998endef
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800999
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001000INTERNAL_GKI_CERTIFICATE_ARGS :=
1001INTERNAL_GKI_CERTIFICATE_DEPS :=
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001002ifdef BOARD_GKI_SIGNING_KEY_PATH
1003 ifndef BOARD_GKI_SIGNING_ALGORITHM
1004 $(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
1005 endif
1006
1007 INTERNAL_GKI_CERTIFICATE_ARGS := \
1008 --key "$(BOARD_GKI_SIGNING_KEY_PATH)" \
1009 --algorithm "$(BOARD_GKI_SIGNING_ALGORITHM)" \
1010 --avbtool "$(AVBTOOL)"
1011
1012 # Quote and pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string argument.
1013 ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
1014 INTERNAL_GKI_CERTIFICATE_ARGS += --additional_avb_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
1015 endif
1016
1017 INTERNAL_GKI_CERTIFICATE_DEPS := \
1018 $(GENERATE_GKI_CERTIFICATE) \
1019 $(BOARD_GKI_SIGNING_KEY_PATH) \
1020 $(AVBTOOL)
1021
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001022endif
1023
Chris Grossa784ef12019-04-22 11:09:57 -07001024# Define these only if we are building boot
1025ifdef BUILDING_BOOT_IMAGE
1026INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1027
The Android Open Source Project88b60792009-03-03 19:28:42 -08001028ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001029$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001030endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -04001031
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001032$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
1033
1034ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -04001035
Steve Muckle04b6f052020-08-09 14:36:56 -07001036# $1: boot image target
1037define build_boot_board_avb_enabled
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001038 $(eval kernel := $(call bootimage-to-kernel,$(1)))
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001039 $(MKBOOTIMG) --kernel $(kernel) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001040 $(if $(BOARD_GKI_SIGNING_KEY_PATH), \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001041 $(eval boot_signature := $(call intermediates-dir-for,PACKAGING,generic_boot)/$(notdir $(1)).boot_signature) \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001042 $(eval kernel_signature := $(call intermediates-dir-for,PACKAGING,generic_kernel)/$(notdir $(kernel)).boot_signature) \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001043 $(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 +08001044 $(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 +08001045 cat $(kernel_signature) >> $(boot_signature) $(newline) \
1046 $(call assert-max-image-size,$(boot_signature),16 << 10) $(newline) \
1047 truncate -s $$(( 16 << 10 )) $(boot_signature) $(newline) \
1048 cat "$(boot_signature)" >> $(1))
Yifan Hongebe65f82020-10-15 14:48:07 -07001049 $(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 -07001050 $(AVBTOOL) add_hash_footer \
1051 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001052 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) \
Steve Muckle04b6f052020-08-09 14:36:56 -07001053 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1054 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1055endef
1056
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001057$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001058 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001059 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -04001060
Bob Badour70c07dd2022-02-12 15:39:22 -08001061$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1062$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES) $(INTERNAL_GKI_CERTIFICATE_DEPS),$(PRODUCT_OUT)/:/)
1063
1064UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1065
David Zeuthen0eb10972016-09-28 17:55:27 -04001066.PHONY: bootimage-nodeps
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001067bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001068 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001069 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001070
Anton Hansson8dab0a62019-03-28 15:45:40 +00001071else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -07001072
Steve Muckle04b6f052020-08-09 14:36:56 -07001073# $1: boot image target
1074define build_boot_supports_boot_signer
1075 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
1076 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -07001077 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001078endef
1079
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001080$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -07001081 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001082 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -07001083
Bob Badour70c07dd2022-02-12 15:39:22 -08001084$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1085$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1086
1087UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1088
Geremy Condra740b6632014-07-08 20:07:41 -07001089.PHONY: bootimage-nodeps
1090bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
1091 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001092 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -07001093
Anton Hansson8dab0a62019-03-28 15:45:40 +00001094else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -08001095
Steve Muckle04b6f052020-08-09 14:36:56 -07001096# $1: boot image target
1097define build_boot_supports_vboot
1098 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
1099 $(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 -07001100 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001101endef
1102
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001103$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001104 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001105 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -08001106
Bob Badour70c07dd2022-02-12 15:39:22 -08001107$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1108$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1109
1110UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1111
David Riley17be3d32015-03-03 08:54:11 -08001112.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001113bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001114 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001115 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -08001116
1117else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001118
Steve Muckle04b6f052020-08-09 14:36:56 -07001119# $1: boot image target
1120define build_boot_novboot
1121 $(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 -07001122 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001123endef
1124
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001125$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001126 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001127 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -07001128
Bob Badour70c07dd2022-02-12 15:39:22 -08001129$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1130$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1131
1132UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
1133
Ying Wangad7fd292013-08-08 16:34:29 -07001134.PHONY: bootimage-nodeps
1135bootimage-nodeps: $(MKBOOTIMG)
1136 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001137 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -07001138
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001139endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -07001140endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001141
Tao Baob1a2e352018-08-14 16:17:12 -07001142else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001143ifdef BOARD_PREBUILT_BOOTIMAGE
Yifan Hong0674a6e2020-10-22 14:37:01 -07001144INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +09001145INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001146
1147ifeq ($(BOARD_AVB_ENABLE),true)
1148$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
1149 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1150 $(AVBTOOL) add_hash_footer \
1151 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001152 $(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001153 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1154 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08001155
1156$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
1157$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_BOOTIMAGE),$(PRODUCT_OUT)/:/)
1158
1159UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001160else
1161$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
1162 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1163endif # BOARD_AVB_ENABLE
1164
Tao Baob1a2e352018-08-14 16:17:12 -07001165else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -07001166INSTALLED_BOOTIMAGE_TARGET :=
1167endif # BOARD_PREBUILT_BOOTIMAGE
1168endif # TARGET_NO_KERNEL
Yifan Hong0674a6e2020-10-22 14:37:01 -07001169endif # my_installed_prebuilt_gki_apex not defined
1170
1171my_apex_extracted_boot_image :=
1172my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001173
1174# -----------------------------------------------------------------
Devin Moore380d9e42021-11-04 19:01:19 +00001175# init boot image
1176ifeq ($(BUILDING_INIT_BOOT_IMAGE),true)
1177
1178INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1179$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_RAMDISK_TARGET)
1180
1181ifdef BOARD_KERNEL_PAGESIZE
1182 INTERNAL_INIT_BOOT_IMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1183endif
1184
1185ifeq ($(BOARD_AVB_ENABLE),true)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08001186$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
Devin Moore380d9e42021-11-04 19:01:19 +00001187 $(call pretty,"Target init_boot image: $@")
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001188 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output "$@"
Devin Moore380d9e42021-11-04 19:01:19 +00001189 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
1190 $(AVBTOOL) add_hash_footer \
1191 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001192 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001193 --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1194 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08001195
1196$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1197$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_GENERIC_RAMDISK_BOOT_SIGNATURE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001198else
1199$(INSTALLED_INIT_BOOT_IMAGE_TARGET):
1200 $(call pretty,"Target init_boot image: $@")
1201 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output $@
1202 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
Bob Badour70c07dd2022-02-12 15:39:22 -08001203
1204$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001205endif
1206
Bob Badour70c07dd2022-02-12 15:39:22 -08001207UNMOUNTED_NOTICE_DEPS += $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
1208
Devin Moore380d9e42021-11-04 19:01:19 +00001209else # BUILDING_INIT_BOOT_IMAGE is not true
1210
1211ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
1212INTERNAL_PREBUILT_INIT_BOOT_IMAGE := $(BOARD_PREBUILT_INIT_BOOT_IMAGE)
1213INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1214
1215ifeq ($(BOARD_AVB_ENABLE),true)
1216$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
1217 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
1218 $(AVBTOOL) add_hash_footer \
1219 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001220 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001221 --partition_name boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1222 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08001223
1224$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1225$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_PREBUILT_INIT_BOOT_IMAGE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001226else
1227$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE)
1228 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
Bob Badour70c07dd2022-02-12 15:39:22 -08001229
1230$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001231endif # BOARD_AVB_ENABLE
1232
Bob Badour70c07dd2022-02-12 15:39:22 -08001233UNMOUNTED_NOTICE_DEPS += $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
1234
Devin Moore380d9e42021-11-04 19:01:19 +00001235else # BOARD_PREBUILT_INIT_BOOT_IMAGE not defined
1236INSTALLED_INIT_BOOT_IMAGE_TARGET :=
1237endif # BOARD_PREBUILT_INIT_BOOT_IMAGE
1238
1239endif # BUILDING_INIT_BOOT_IMAGE is not true
Ramji Jiyani10655232022-01-20 06:43:09 +00001240
1241# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001242# vendor boot image
1243ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1244
1245ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
1246 $(error vboot 1.0 does not support vendor_boot partition)
1247endif
1248
1249INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
1250 $(ALL_GENERATED_SOURCES) \
1251 $(ALL_DEFAULT_INSTALLED_MODULES))
1252
Petri Gynther6a6d6212021-03-06 00:45:53 -08001253INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001254
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001255# Exclude recovery files in the default vendor ramdisk if including a standalone
1256# recovery ramdisk in vendor_boot.
Yifan Hong881df392020-10-09 14:29:39 -07001257ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001258ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
Yifan Hong881df392020-10-09 14:29:39 -07001259$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1260$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1261endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001262endif
Yifan Hong881df392020-10-09 14:29:39 -07001263
J. Avila3f6560e2020-05-11 20:20:03 +00001264$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001265 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001266
Petri Gynther828828b2021-03-04 11:04:03 -08001267INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1268$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08001269 @echo "Target vendor ramdisk: $@"
Petri Gynther828828b2021-03-04 11:04:03 -08001270 $(copy-file-to-target)
Petri Gynther828828b2021-03-04 11:04:03 -08001271
Bob Badour70c07dd2022-02-12 15:39:22 -08001272$(call declare-1p-container,$(INSTALLED_VENDOR_RAMDISK_TARGET),)
1273$(call declare-container-license-deps,$(INSTALLED_VENDOR_RAMDISK_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
1274
1275VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_RAMDISK_TARGET)
1276
Petri Gynther6ff52012020-11-20 11:59:41 -08001277INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1278INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1279$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1280$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1281$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001282 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001283 mkdir -p $(dir $@)
1284 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001285 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1286 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001287
Bob Badour70c07dd2022-02-12 15:39:22 -08001288$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_RAMDISK)))
1289
Steve Mucklee1b10862019-07-10 10:49:37 -07001290ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1291 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1292endif
1293ifdef BOARD_KERNEL_BASE
1294 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1295endif
1296ifdef BOARD_KERNEL_PAGESIZE
1297 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1298endif
1299ifdef INTERNAL_KERNEL_CMDLINE
1300 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1301endif
1302
Devin Moore50509012021-01-13 10:45:04 -08001303ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001304 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1305 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001306 rm -f $@
1307 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1308 printf "%s\n" $(param) >> $@;)
1309 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1310endif
1311
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001312# $(1): Build target name
1313# $(2): Staging dir to be compressed
1314# $(3): Build dependencies
1315define build-vendor-ramdisk-fragment-target
1316$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1317 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1318endef
1319
1320# $(1): Ramdisk name
1321define build-vendor-ramdisk-fragment
1322$(strip \
1323 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1324 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1325 $(build_target) \
1326)
1327endef
1328
1329# $(1): Ramdisk name
1330# $(2): Prebuilt file path
1331define build-prebuilt-vendor-ramdisk-fragment
1332$(strip \
1333 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1334 $(eval $(call copy-one-file,$(2),$(build_target))) \
1335 $(build_target) \
1336)
1337endef
1338
1339INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1340INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1341
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001342$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001343 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1344 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1345 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1346 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001347 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001348 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1349 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1350)
1351
Steve Mucklee1b10862019-07-10 10:49:37 -07001352INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1353$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001354$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001355ifeq ($(BOARD_AVB_ENABLE),true)
1356$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1357 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001358 $(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 -07001359 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1360 $(AVBTOOL) add_hash_footer \
1361 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001362 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Steve Mucklee1b10862019-07-10 10:49:37 -07001363 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1364 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1365else
1366$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1367 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001368 $(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 -07001369 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1370endif
Bob Badour70c07dd2022-02-12 15:39:22 -08001371
1372$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
1373$(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)/:/)
1374VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001375endif # BUILDING_VENDOR_BOOT_IMAGE
1376
1377# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001378# NOTICE files
1379#
Steve Blockd14d3b42012-03-01 11:34:41 +00001380# We are required to publish the licenses for all code under BSD, GPL and
1381# Apache licenses (and possibly other more exotic ones as well). We err on the
1382# side of caution, so the licenses for other third-party code are included here
1383# too.
1384#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001385# This needs to be before the systemimage rules, because it adds to
1386# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1387# go into the systemimage.
1388
Steve Block495e5852012-02-29 19:18:08 +00001389.PHONY: notice_files
1390
Bob Badour70c07dd2022-02-12 15:39:22 -08001391# Convert license metadata into xml notice file.
1392# $(1) - Output target notice filename
1393# $(2) - Product name
1394# $(3) - File title
1395# $(4) - License metadata file roots
1396# $(5) - Prefixes to strip
1397#
1398define xml-notice-rule
1399$(1): PRIVATE_PRODUCT := $(2)
1400$(1): PRIVATE_MESSAGE := $(3)
1401$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
1402 $(XMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
1403
1404notice_files: $(1)
1405endef
1406
1407# Convert license metadata into text notice file.
1408# $(1) - Output target notice filename
1409# $(2) - Product name
1410# $(3) - File title
1411# $(4) - License metadata file roots
1412# $(5) - Prefixes to strip
1413#
1414define text-notice-rule
1415$(1): PRIVATE_PRODUCT := $(2)
1416$(1): PRIVATE_MESSAGE := $(3)
1417$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
1418 $(TEXTNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
1419
1420notice_files: $(1)
1421endef
1422
1423# Conversion license metadata into html notice file.
1424# $(1) - Output target notice filename
1425# $(2) - Product name
1426# $(3) - File title
1427# $(4) - License metadata file roots
1428# $(5) - Prefixes to strip
1429#
1430define html-notice-rule
1431$(1): PRIVATE_PRODUCT := $(2)
1432$(1): PRIVATE_MESSAGE := $(3)
1433$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
1434 $(HTMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
1435
1436notice_files: $(1)
1437endef
1438
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001439# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -07001440# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
1441# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
1442# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
1443# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001444# $(2) - Plain text output file
1445# $(3) - HTML/XML output file
1446# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -07001447# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -08001448# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001449# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -08001450# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -08001451#
1452# The algorithm here is that we go collect a hash for each of the notice
1453# files and write the names of the files that match that hash. Then
1454# to generate the real files, we go print out all of the files and their
1455# hashes.
1456#
1457# These rules are fairly complex, so they depend on this makefile so if
1458# it changes, they'll run again.
1459#
1460# TODO: We could clean this up so that we just record the locations of the
1461# original notice files instead of making rules to copy them somwehere.
1462# Then we could traverse that without quite as much bash drama.
1463define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -07001464$(2): PRIVATE_MESSAGE := $(4)
1465$(2): PRIVATE_DIR := $(5)
1466$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
1467$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -08001468 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -07001469 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
1470 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +00001471 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001472 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001473 $(if $(filter $(1),xml_system),-i system --xml-output, \
1474 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001475 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001476 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
1477 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -07001478 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001479notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001480endef
1481
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001482# Notice file logic isn't relevant for TARGET_BUILD_APPS
1483ifndef TARGET_BUILD_APPS
1484
The Android Open Source Project88b60792009-03-03 19:28:42 -08001485# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1486# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1487# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001488target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001489kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1490winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001491
Bob Badour4b25c902020-01-28 13:23:39 -08001492# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1493# reasons--not to be flashed onto any device. Targets under these directories
1494# need no associated notice file on the device UI.
1495exclude_target_dirs := apex
1496
Steven Morelandae69e572017-12-15 14:49:55 -08001497# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001498ifneq ($(PRODUCT_NOTICE_SPLIT),true)
Bob Badour70c07dd2022-02-12 15:39:22 -08001499#target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001500target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1501installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Bob Badour879cfa82021-04-15 10:41:38 -07001502
1503$(call declare-0p-target,$(target_notice_file_html_gz))
1504$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001505else
Bob Badour70c07dd2022-02-12 15:39:22 -08001506# target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001507target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001508installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1509
1510target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001511target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1512installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001513
1514target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
Dario Freniadc972d2018-07-09 18:38:38 +01001515target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1516installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001517
Justin Yun6151e3f2019-06-25 15:58:13 +09001518target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
Justin Yun6151e3f2019-06-25 15:58:13 +09001519target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1520installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001521
Chris Gross15d96552019-07-16 14:38:43 -07001522target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
Chris Gross15d96552019-07-16 14:38:43 -07001523target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1524installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1525
Yifan Hong3d3f0302020-05-11 18:35:11 -07001526target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
Yifan Hong3d3f0302020-05-11 18:35:11 -07001527target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1528installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1529
Yifan Hongc83f9e92020-07-15 16:57:47 -07001530target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
Yifan Hongc83f9e92020-07-15 16:57:47 -07001531target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1532installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1533
Ramji Jiyani13a41372022-01-27 07:05:08 +00001534target_system_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.txt
Ramji Jiyani13a41372022-01-27 07:05:08 +00001535target_system_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.xml.gz
1536installed_system_dlkm_notice_xml_gz := $(TARGET_OUT_SYSTEM_DLKM)/etc/NOTICE.xml.gz
1537
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001538# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1539# being built. A notice xml file must depend on all modules that could potentially
1540# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001541license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001542# Only files copied to a system image need system image notices.
1543license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001544# Phonys/fakes don't have notice files (though their deps might)
1545license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001546# testcases are not relevant to the system image.
1547license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001548# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001549license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001550# system_other is relevant to system partition.
1551license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001552license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1553license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001554license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001555license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001556license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001557license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001558license_modules_odm_dlkm := $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001559license_modules_agg := $(license_modules_system) \
1560 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001561 $(license_modules_product) \
1562 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001563 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001564 $(license_modules_vendor_dlkm) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001565 $(license_modules_odm_dlkm) \
1566 $(license_modules_system_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001567# targets used for debug symbols only and do not get copied to the device
1568license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1569
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001570license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001571license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1572
1573# Identify the other targets we expect to have notices for:
1574# targets copied to the device but are not readable by the UI (e.g. must boot
1575# into a different partition to read or don't have an associated /etc
1576# directory) must have their notices built somewhere readable.
1577license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1578license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1579license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1580license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1581license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1582license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001583license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001584license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1585license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1586license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1587license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1588license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1589license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1590
1591# after removing targets in system images, targets reported in system images, and
1592# targets used for debug symbols that do not need notices, nothing must remain.
1593license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1594$(call maybe-print-list-and-error, $(license_modules_rest), \
1595 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001596
Chris Grossaad39b32019-06-13 09:43:26 -07001597# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1598# update its notice file, so include those notices in the system partition instead
1599ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001600license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001601system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1602system_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 -07001603else
Bob Badour4b25c902020-01-28 13:23:39 -08001604license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001605system_xml_directories := xml_system
1606system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001607endif
1608
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001609endif # PRODUCT_NOTICE_SPLIT
1610
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001611ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001612
Ying Wang62c81f82013-08-22 20:02:03 -07001613endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001614
1615# The kernel isn't really a module, so to get its module file in there, we
1616# make the target NOTICE files depend on this particular file too, which will
1617# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001618$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001619
Bob Badour70c07dd2022-02-12 15:39:22 -08001620# No matter where it gets copied from, a copied linux kernel is licensed under "GPL 2.0 only"
1621$(eval $(call declare-copy-files-license-metadata,,:kernel,SPDX-license-identifier-GPL-2.0-only,notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,))
1622
Dan Willemsen288bedf2019-05-28 15:36:47 -07001623$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001624
Doug Zongker8678df42009-06-15 14:30:14 -07001625
The Android Open Source Project88b60792009-03-03 19:28:42 -08001626# #################################################################
1627# Targets for user images
1628# #################################################################
1629
Ying Wang933abf12010-06-16 14:31:34 -07001630INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001631ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001632INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1633else
1634ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001635INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1636else
1637ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001638INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1639endif
1640endif
1641endif
1642
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001643# These options tell the recovery updater/installer how to mount the partitions writebale.
1644# <fstype>=<fstype_opts>[|<fstype_opts>]...
1645# fstype_opts := <opt>[,<opt>]...
1646# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001647# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1648DEFAULT_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 -07001649
Ying Wang542903a2010-11-17 15:40:38 -08001650ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1651 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1652endif
Gao Xiang961041a2020-06-17 13:59:16 +08001653ifneq (true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED))
1654 INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG := -s
1655endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001656ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1657 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1658endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001659ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1660 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1661endif
Tao Baodba635a2019-06-24 10:39:54 -07001662
1663INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001664 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001665 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001666 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001667
Bob Badour2f66fd12022-03-09 17:30:24 -08001668$(call declare-1p-target,$(MKE2FS_CONF),system/extras)
1669
Tao Baodba635a2019-06-24 10:39:54 -07001670ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1671INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001672endif
1673
Yifan Hongcfb917a2020-05-07 14:58:20 -07001674ifneq ($(filter \
1675 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1676 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1677 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1678 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1679 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1680 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001681 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001682 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001683 ,erofs),)
David Anderson94ad5bb2022-03-04 10:57:58 -08001684INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
Kelvin Zhang37d49292021-12-01 14:21:24 -08001685BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
Gao Xiang961041a2020-06-17 13:59:16 +08001686endif
1687
1688ifneq ($(filter \
1689 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1690 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1691 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1692 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1693 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1694 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1695 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001696 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001697 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001698INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1699endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001700
Anton Hansson8dab0a62019-03-28 15:45:40 +00001701ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001702INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001703ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001704INTERNAL_USERIMAGES_DEPS += $(FEC)
1705endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001706endif
1707
Tao Baodba635a2019-06-24 10:39:54 -07001708ifeq ($(BOARD_AVB_ENABLE),true)
1709INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1710endif
1711
1712# Get a colon-separated list of search paths.
1713INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1714
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001715# Collects file_contexts files from modules to be installed
1716$(call merge-fc-files, \
1717 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1718 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1719
Alex Klyubin092c9022017-03-13 13:28:34 -07001720SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001721
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001722INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1723
Yifan Hongc5c01242018-11-09 10:27:23 -08001724ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001725
Anton Hansson8dab0a62019-03-28 15:45:40 +00001726ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001727 $(error vboot 1.0 doesn't support logical partition)
1728endif
1729
Yifan Hongc5c01242018-11-09 10:27:23 -08001730endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001731
David Anderson707e6f52021-09-21 22:24:43 -07001732# $(1) the partition name (eg system)
1733# $(2) the image prop file
1734define add-common-flags-to-image-props
1735$(eval _var := $(call to-upper,$(1)))
1736$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
1737$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
1738endef
1739
1740# $(1) the partition name (eg system)
1741# $(2) the image prop file
1742define add-common-ro-flags-to-image-props
1743$(eval _var := $(call to-upper,$(1)))
David Anderson64b351b2021-10-13 00:20:43 -07001744$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
1745$(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 -07001746$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
1747$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
1748$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
1749$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
1750$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
1751$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
1752$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
1753$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
1754$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
1755$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
1756$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
1757$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
1758$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
1759$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
1760$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
1761$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
David Anderson5f4aa6c2021-09-23 17:03:14 -07001762$(if $(or $(_size), $(_reserved), $(_headroom)),,
1763 $(hide) echo "$(1)_disable_sparse=true" >> $(2))
David Anderson707e6f52021-09-21 22:24:43 -07001764$(call add-common-flags-to-image-props,$(1),$(2))
David Anderson9e95a022021-08-31 21:32:45 -07001765endef
1766
Ying Wangbd93d422011-10-28 17:02:30 -07001767# $(1): the path of the output dictionary file
Ramji Jiyani13a41372022-01-27 07:05:08 +00001768# $(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 -07001769# $(3): additional "key=value" pairs to append to the dictionary file.
1770define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001771$(if $(filter $(2),system),\
Bowgo Tsai867ab662019-01-29 13:30:18 +08001772 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001773 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001774 $(call add-common-ro-flags-to-image-props,system,$(1))
Chris Gross203191b2020-05-30 02:39:12 +00001775)
1776$(if $(filter $(2),system_other),\
1777 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
David Anderson9e95a022021-08-31 21:32:45 -07001778 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
1779 $(hide) echo "system_other_disable_sparse=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001780)
Yifan Hong760d3c02018-05-30 11:16:46 -07001781$(if $(filter $(2),userdata),\
1782 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1783 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001784 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1785 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kim55c16dd2020-10-12 19:50:05 -07001786 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001787 $(call add-common-flags-to-image-props,userdata,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001788)
Yifan Hong760d3c02018-05-30 11:16:46 -07001789$(if $(filter $(2),cache),\
1790 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1791 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001792 $(call add-common-flags-to-image-props,cache,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001793)
1794$(if $(filter $(2),vendor),\
David Anderson707e6f52021-09-21 22:24:43 -07001795 $(call add-common-ro-flags-to-image-props,vendor,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001796)
1797$(if $(filter $(2),product),\
David Anderson707e6f52021-09-21 22:24:43 -07001798 $(call add-common-ro-flags-to-image-props,product,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001799)
Justin Yun6151e3f2019-06-25 15:58:13 +09001800$(if $(filter $(2),system_ext),\
David Anderson707e6f52021-09-21 22:24:43 -07001801 $(call add-common-ro-flags-to-image-props,system_ext,$(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001802)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001803$(if $(filter $(2),odm),\
David Anderson707e6f52021-09-21 22:24:43 -07001804 $(call add-common-ro-flags-to-image-props,odm,$(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001805)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001806$(if $(filter $(2),vendor_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001807 $(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001808)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001809$(if $(filter $(2),odm_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001810 $(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001811)
Ramji Jiyani13a41372022-01-27 07:05:08 +00001812$(if $(filter $(2),system_dlkm),\
1813 $(call add-common-ro-flags-to-image-props,system_dlkm,$(1))
1814)
Yifan Hong760d3c02018-05-30 11:16:46 -07001815$(if $(filter $(2),oem),\
1816 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1817 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1818 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1819 $(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 -07001820 $(call add-common-flags-to-image-props,oem,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001821)
Tao Bao3602eca2018-07-10 10:53:55 -07001822$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001823
Tao Bao3602eca2018-07-10 10:53:55 -07001824$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001825$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Gao Xiang961041a2020-06-17 13:59:16 +08001826$(if $(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG),$(hide) echo "erofs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001827$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001828$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
David Anderson40a821f2021-09-22 18:02:01 -07001829$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
David Anderson64b351b2021-10-13 00:20:43 -07001830$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
1831$(if $(BOARD_EROFS_SHARE_DUP_BLOCKS),$(hide) echo "erofs_share_dup_blocks=$(BOARD_EROFS_SHARE_DUP_BLOCKS)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001832$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1833$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1834$(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 +00001835$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1836$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1837$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1838$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1839$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001840$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001841$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1842$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1843$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001844$(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 -07001845$(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 -07001846$(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 +00001847$(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 +00001848$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1849$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1850$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1851$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1852$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001853$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001854$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1855$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1856$(if $(BOARD_AVB_ENABLE),\
1857 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1858 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1859 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1860 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001861$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1862$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1863$(if $(BOARD_AVB_ENABLE),\
1864 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1865 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001866 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001867$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1868$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1869$(if $(BOARD_AVB_ENABLE),\
1870 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1871 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1872 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1873 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001874$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1875$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1876$(if $(BOARD_AVB_ENABLE),\
1877 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1878 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1879 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1880 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001881$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001882$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001883 $(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 +01001884$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001885 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1886 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1887 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1888 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001889$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1890$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1891$(if $(BOARD_AVB_ENABLE),\
1892 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1893 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1894 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1895 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001896$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1897$(if $(BOARD_AVB_ENABLE),\
1898 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1899$(if $(BOARD_AVB_ENABLE),\
1900 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1901 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1902 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1903 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001904$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1905$(if $(BOARD_AVB_ENABLE),\
1906 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1907$(if $(BOARD_AVB_ENABLE),\
1908 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1909 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1910 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1911 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001912$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1913$(if $(BOARD_AVB_ENABLE),\
1914 $(hide) echo "avb_system_dlkm_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1915$(if $(BOARD_AVB_ENABLE),\
1916 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
1917 $(hide) echo "avb_system_dlkm_key_path=$(BOARD_AVB_SYSTEM_DLKM_KEY_PATH)" >> $(1)
1918 $(hide) echo "avb_system_dlkm_algorithm=$(BOARD_AVB_SYSTEM_DLKM_ALGORITHM)" >> $(1)
1919 $(hide) echo "avb_system_dlkm_rollback_index_location=$(BOARD_SYSTEM_SYSTEM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001920$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1921 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001922$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001923 $(hide) echo "system_root_image=true" >> $(1))
1924$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001925$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1926 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001927$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1928endef
1929
1930# $(1): the path of the output dictionary file
1931# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001932PROP_DICTIONARY_IMAGES := oem
1933ifdef BUILDING_CACHE_IMAGE
1934 PROP_DICTIONARY_IMAGES += cache
1935endif
1936ifdef BUILDING_SYSTEM_IMAGE
1937 PROP_DICTIONARY_IMAGES += system
1938endif
Chris Gross203191b2020-05-30 02:39:12 +00001939ifdef BUILDING_SYSTEM_OTHER_IMAGE
1940 PROP_DICTIONARY_IMAGES += system_other
1941endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001942ifdef BUILDING_USERDATA_IMAGE
1943 PROP_DICTIONARY_IMAGES += userdata
1944endif
1945ifdef BUILDING_VENDOR_IMAGE
1946 PROP_DICTIONARY_IMAGES += vendor
1947endif
1948ifdef BUILDING_PRODUCT_IMAGE
1949 PROP_DICTIONARY_IMAGES += product
1950endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001951ifdef BUILDING_SYSTEM_EXT_IMAGE
1952 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001953endif
1954ifdef BUILDING_ODM_IMAGE
1955 PROP_DICTIONARY_IMAGES += odm
1956endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001957ifdef BUILDING_VENDOR_DLKM_IMAGE
1958 PROP_DICTIONARY_IMAGES += vendor_dlkm
1959endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001960ifdef BUILDING_ODM_DLKM_IMAGE
1961 PROP_DICTIONARY_IMAGES += odm_dlkm
1962endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00001963ifdef BUILDING_SYSTEM_DLKM_IMAGE
1964 PROP_DICTIONARY_IMAGES += system_dlkm
1965endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001966define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001967 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001968endef
1969
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001970# $(1): the path of the input dictionary file, where each line has the format key=value
1971# $(2): the key to look up
1972define read-image-prop-dictionary
1973$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1974endef
1975
The Android Open Source Project88b60792009-03-03 19:28:42 -08001976# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001977# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001978
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001979# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001980ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001981
Ying Wang37526142015-03-10 12:02:57 -07001982INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1983 $(ALL_DEFAULT_INSTALLED_MODULES))
1984
Tao Bao10fc9492018-08-14 12:17:48 -07001985INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1986INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1987
Bob Badour70c07dd2022-02-12 15:39:22 -08001988$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RECOVERY)))
1989
Colin Cross359f4212020-12-02 15:14:04 -08001990ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1991INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1992endif
1993
Tao Bao10fc9492018-08-14 12:17:48 -07001994# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1995# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1996# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1997# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08001998$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07001999
2000$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002001$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07002002 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002003 mkdir -p $(dir $@)
2004 rm -f $@
2005 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
2006 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07002007
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002008recovery_sepolicy := \
2009 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07002010 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002011 $(TARGET_RECOVERY_ROOT_OUT)/plat_service_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002012 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002013 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002014 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_service_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002015 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
2016 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002017 $(TARGET_RECOVERY_ROOT_OUT)/vendor_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002018 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08002019 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002020 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
2021 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002022 $(TARGET_RECOVERY_ROOT_OUT)/product_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002023 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08002024
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002025# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
2026# SELinux files
2027IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
2028
Steve Muckle04b6f052020-08-09 14:36:56 -07002029# if building multiple boot images from multiple kernels, use the first kernel listed
2030# for the recovery image
2031recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002032recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07002033recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08002034
Anton Hansson45a40da2019-01-18 14:06:34 +00002035# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
2036# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
2037# which get remapped to a bucket.
2038recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07002039ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
2040recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00002041# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07002042# ------160------240------320----------480------------640------
2043# mdpi hdpi xhdpi xxhdpi xxxhdpi
2044recovery_density := $(strip \
2045 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
2046 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
2047 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
2048 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07002049endif
2050
2051ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
2052recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
2053else
Doug Zongker25d55f82014-04-04 13:51:15 -07002054recovery_resources_common := $(recovery_resources_common)-xhdpi
2055endif
2056
Tao Baoe1e829e2018-08-29 20:36:00 -07002057# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
2058# Note that the font selected here can be overridden for a particular device by putting a font.png
2059# in its private recovery resources.
2060ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07002061recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08002062else
Dan Willemsen97672232020-05-27 00:09:16 -07002063recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08002064endif
2065
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002066
2067# We will only generate the recovery background text images if the variable
2068# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
2069# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
2070# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
2071# BoardConfig in order to use this feature.
2072ifeq ($(recovery_density),xxxhdpi)
2073TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
2074else ifeq ($(recovery_density),xxhdpi)
2075TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
2076endif
2077
2078ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
2079# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
2080ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
2081 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
2082else
2083 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
2084endif
2085
2086
Dan Willemsen97672232020-05-27 00:09:16 -07002087RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002088RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
2089RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
2090RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
2091RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
2092
xunchangcc57d312018-12-07 12:12:17 -08002093RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
2094RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
2095RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
2096RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
2097RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
2098
2099generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002100 $(RECOVERY_INSTALLING_TEXT_FILE) \
2101 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
2102 $(RECOVERY_ERASING_TEXT_FILE) \
2103 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08002104 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
2105 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
2106 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
2107 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
2108 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
2109 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002110
Dan Willemsen97672232020-05-27 00:09:16 -07002111resource_dir := bootable/recovery/tools/recovery_l10n/res/
2112resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002113image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08002114zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002115$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07002116$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002117$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
2118$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08002119$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002120$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08002121$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002122 recovery_installing \
2123 recovery_installing_security \
2124 recovery_erasing \
2125 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08002126 recovery_no_command
2127$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002128 recovery_cancel_wipe_data \
2129 recovery_factory_data_reset \
2130 recovery_try_again \
2131 recovery_wipe_data_menu_header \
2132 recovery_wipe_data_confirmation
2133$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07002134$(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 -08002135 # Prepares the font directory.
2136 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
2137 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08002138 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002139 @rm -rf $(dir $@)
2140 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08002141 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08002142 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08002143 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002144 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
2145 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
2146 --text_name $(text_name) \
2147 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2148 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002149 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002150 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002151else
2152RECOVERY_INSTALLING_TEXT_FILE :=
2153RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2154RECOVERY_ERASING_TEXT_FILE :=
2155RECOVERY_ERROR_TEXT_FILE :=
2156RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002157RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2158RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2159RECOVERY_TRY_AGAIN_TEXT_FILE :=
2160RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2161RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002162endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2163
Ying Wang9a175682015-08-06 11:47:47 -07002164ifndef TARGET_PRIVATE_RES_DIRS
2165TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2166endif
Doug Zongker4647f122009-07-02 09:00:54 -07002167recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002168 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002169recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002170
2171
Andrew Boiefa61ff02012-09-28 09:33:45 -07002172ifdef TARGET_RECOVERY_FSTAB
2173recovery_fstab := $(TARGET_RECOVERY_FSTAB)
Cole Faust64c2ddb2022-01-07 12:44:31 -08002174else ifdef TARGET_RECOVERY_FSTAB_GENRULE
2175# Specifies a soong genrule module that generates an fstab.
2176recovery_fstab := $(call intermediates-dir-for,ETC,$(TARGET_RECOVERY_FSTAB_GENRULE))/$(TARGET_RECOVERY_FSTAB_GENRULE)
Andrew Boiefa61ff02012-09-28 09:33:45 -07002177else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002178recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002179endif
Tao Baoc3c17532016-06-10 10:11:54 -07002180ifdef TARGET_RECOVERY_WIPE
2181recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002182else
Tao Baoc3c17532016-06-10 10:11:54 -07002183recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002184endif
Tao Bao8beab692015-07-22 12:33:18 -07002185
Tao Bao6d5d6232018-03-09 17:04:42 -08002186# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002187# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002188# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2189# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002190#
2191# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002192# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002193# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002194# b) We build a single image that contains boot and recovery both - no recovery image to install
2195# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07002196# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08002197# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002198# d) We include the recovery DTBO image within recovery - not needing the resource file as we
2199# do bsdiff because boot and recovery will contain different number of entries
2200# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002201# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
2202# do bsdiff because boot and recovery will contain different number of entries
2203# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yifan Hongef7a9712020-10-20 13:17:42 -07002204# f) We build a single image that contains vendor_boot and recovery both - no recovery image to
2205# install
2206# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002207
Tom Cherry2929cad2018-09-20 11:04:37 -07002208ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002209 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
2210 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002211# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002212RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2213ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002214else
Tao Bao8beab692015-07-22 12:33:18 -07002215RECOVERY_RESOURCE_ZIP :=
2216endif
Doug Zongker4647f122009-07-02 09:00:54 -07002217
Tao Bao139c7272018-07-31 13:26:54 -07002218INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2219
2220$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002221 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2222 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2223 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2224 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2225 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2226 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2227 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2228 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2229
2230# Parses the given list of build variables and writes their values as build properties if defined.
2231# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2232# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2233# $(1): Map from the build variable names to property names
2234# $(2): Output file
2235define append-recovery-ui-properties
2236echo "#" >> $(2)
2237echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2238echo "#" >> $(2)
2239$(foreach prop,$(1), \
2240 $(eval _varname := $(call word-colon,1,$(prop))) \
2241 $(eval _propname := $(call word-colon,2,$(prop))) \
2242 $(eval _value := $($(_varname))) \
2243 $(if $(_value), \
2244 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2245endef
2246
2247$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002248 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002249 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2250 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2251 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002252 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002253 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002254 $(hide) mkdir -p $(dir $@)
2255 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002256 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002257 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002258 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002259 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002260 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002261 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2262
Yifan Hong33fd5d42020-09-24 18:18:26 -07002263# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2264# On device with dedicated recovery partition, the file should come from the boot
2265# ramdisk.
2266ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2267INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2268$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2269 $(copy-file-to-target)
2270endif
2271
Yifan Hongc56931c2020-10-28 16:35:19 -07002272INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002273
Yifan Hong78860162020-10-28 14:15:21 -07002274ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002275INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002276# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002277ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002278ifdef INTERNAL_KERNEL_CMDLINE
2279 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002280endif # INTERNAL_KERNEL_CMDLINE != ""
2281endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002282ifdef BOARD_KERNEL_BASE
2283 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2284endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002285ifdef BOARD_KERNEL_PAGESIZE
2286 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2287endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002288ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002289ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2290 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2291else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002292 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2293endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002294endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002295ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2296 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2297endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002298ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2299 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2300endif
Yifan Hong3941a872020-10-28 16:33:06 -07002301endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002302ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2303 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2304endif
Doug Zongker4647f122009-07-02 09:00:54 -07002305
Yifan Hong881df392020-10-09 14:29:39 -07002306$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002307 $(INTERNAL_ROOT_FILES) \
2308 $(INSTALLED_RAMDISK_TARGET) \
2309 $(INTERNAL_RECOVERYIMAGE_FILES) \
2310 $(recovery_sepolicy) \
2311 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2312 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002313 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002314 $(recovery_resource_deps) \
2315 $(recovery_fstab)
2316 # Making recovery image
2317 mkdir -p $(TARGET_RECOVERY_OUT)
2318 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2319 # Copying baseline ramdisk...
2320 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2321 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2322 # Modifying ramdisk contents...
2323 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2324 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
2325 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2326 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2327 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2328 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2329 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2330 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2331 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2332 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2333 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2334 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2335 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2336 $(foreach item,$(recovery_fstab), \
2337 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2338 $(if $(strip $(recovery_wipe)), \
2339 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2340 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2341 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002342 $(hide) touch $@
2343
2344$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002345 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002346
Ying Wang747b9f12015-01-30 14:05:22 -08002347# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002348# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002349define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002350 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002351 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002352 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002353 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002354 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002355 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002356 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002357 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002358 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002359 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2360 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002361 )\
2362 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002363 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2364 $(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 +08002365 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002366 $(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 -07002367 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002368 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2369 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002370 $(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),\
2371 $(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 -08002372endef
2373
Dan Willemsend120ac62020-06-12 02:39:34 +00002374recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002375ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00002376 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002377endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002378ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002379 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002380endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002381ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002382 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002383endif
Tao Baof4866c72018-08-22 14:35:09 -07002384ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002385 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2386 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2387 else
2388 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2389 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002390endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002391ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002392 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002393endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002394ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002395 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002396endif
Tao Baof4866c72018-08-22 14:35:09 -07002397
Dan Willemsend120ac62020-06-12 02:39:34 +00002398ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002399$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002400$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002401 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002402 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Bob Badour70c07dd2022-02-12 15:39:22 -08002403
2404$(call declare-1p-container,$(INSTALLED_BOOTIMAGE_TARGET),)
2405$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2406
2407UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Tao Baof4866c72018-08-22 14:35:09 -07002408endif # BOARD_USES_RECOVERY_AS_BOOT
2409
Dan Willemsend120ac62020-06-12 02:39:34 +00002410$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002411 $(call build-recoveryimage-target, $@, \
2412 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002413
Tao Bao4594d0e2015-12-22 09:47:46 -08002414ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002415$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002416 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002417 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2418 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002419endif
Doug Zongker56588872012-08-20 15:38:58 -07002420
Bob Badour70c07dd2022-02-12 15:39:22 -08002421
2422$(call declare-1p-container,$(INSTALLED_RECOVERYIMAGE_TARGET),)
2423$(call declare-container-license-deps,$(INSTALLED_RECOVERYIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2424
2425UNMOUNTED_NOTICE_DEPS += $(INSTALLED_RECOVERYIMAGE_TARGET)
2426
Ying Wang747b9f12015-01-30 14:05:22 -08002427.PHONY: recoveryimage-nodeps
2428recoveryimage-nodeps:
2429 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002430 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2431 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002432
Chris Grossa784ef12019-04-22 11:09:57 -07002433else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002434RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002435endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002436
2437.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002438recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002439
Jiyong Park03eb0612017-10-04 21:22:41 +09002440ifneq ($(BOARD_NAND_PAGE_SIZE),)
2441$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002442endif
2443
Jiyong Park03eb0612017-10-04 21:22:41 +09002444ifneq ($(BOARD_NAND_SPARE_SIZE),)
2445$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002446endif
2447
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002448
Doug Zongker4647f122009-07-02 09:00:54 -07002449# -----------------------------------------------------------------
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002450# Build debug ramdisk and debug boot image.
2451ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
2452
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002453INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2454 $(ALL_GENERATED_SOURCES) \
2455 $(ALL_DEFAULT_INSTALLED_MODULES))
2456
2457# Directories to be picked into the debug ramdisk.
2458# As these directories are all merged into one single cpio archive, the order
2459# matters. If there are multiple files with the same pathname, then the last one
2460# wins.
2461#
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002462# ramdisk-debug.img will merge the content from either ramdisk.img or
2463# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
2464# is set or not.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002465ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002466 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT)
2467 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002468else # BOARD_USES_RECOVERY_AS_BOOT == true
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002469 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT)
2470 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002471endif # BOARD_USES_RECOVERY_AS_BOOT != true
2472
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002473INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT)
2474INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES)
2475
2476# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
2477INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2478INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2479$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2480$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS)
2481$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2482 @echo "Installed file list: $@"
2483 $(hide) rm -f $@
2484 $(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT)
2485 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
2486 $(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2487 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2488
Bob Badour70c07dd2022-02-12 15:39:22 -08002489$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_DEBUG_RAMDISK)))
2490
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002491ifdef BUILDING_DEBUG_BOOT_IMAGE
2492
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002493# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002494# the debug ramdisk, which is the original ramdisk plus additional
2495# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2496# When /force_debuggable is present, /init will load userdebug sepolicy
2497# and property files to allow adb root, if the device is unlocked.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002498INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
Bowgo Tsai0013f552019-03-20 17:59:52 +08002499
Bowgo Tsai610286a2021-04-23 11:31:32 +08002500$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002501$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2502 @echo "Target debug ramdisk: $@"
2503 $(hide) rm -f $@
2504 $(hide) mkdir -p $(dir $@)
2505 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002506
Bob Badour70c07dd2022-02-12 15:39:22 -08002507$(call declare-1p-container,$(INSTALLED_DEBUG_RAMDISK_TARGET),)
2508$(call declare-container-license-deps,$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2509
2510UNMOUNTED_NOTICE_DEPS += $(INSTALLED_DEBUG_RAMDISK_TARGET)
2511
Bowgo Tsai0013f552019-03-20 17:59:52 +08002512.PHONY: ramdisk_debug-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002513ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002514 @echo "make $@: ignoring dependencies"
2515 $(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET)
2516 $(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS)
2517 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002518
2519# -----------------------------------------------------------------
2520# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2521#
2522# Note: it's intentional to skip signing for boot-debug.img, because it
2523# can only be used if the device is unlocked with verification error.
Steve Muckleb3dda772020-03-11 16:03:07 -07002524ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002525 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002526 $(PRODUCT_OUT)/$(k).img)
2527else
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002528 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
Steve Muckleb3dda772020-03-11 16:03:07 -07002529endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002530
2531# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002532$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002533ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002534 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 +08002535else
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002536 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 +08002537endif
2538
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002539# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2540# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2541# Using a test key to sign boot-debug.img to continue booting with the mismatched
2542# public key, if the device is unlocked.
2543ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002544$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002545endif
2546
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002547BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2548INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2549# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002550# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002551define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002552$(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 +08002553$(AVBTOOL) add_hash_footer \
2554 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002555 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),$(2)))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002556 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2557 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002558$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002559endef
2560
Steve Muckleb3dda772020-03-11 16:03:07 -07002561# $(1): output file
2562define build-debug-bootimage-target
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002563 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002564 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002565 $(BOARD_MKBOOTIMG_ARGS) --output $1
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002566 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
Steve Muckleb3dda772020-03-11 16:03:07 -07002567endef
2568
Bowgo Tsai0013f552019-03-20 17:59:52 +08002569# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002570$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002571 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002572 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002573
Bob Badour70c07dd2022-02-12 15:39:22 -08002574$(call declare-1p-container,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),)
2575$(call declare-container-license-deps,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(INSTALLED_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2576
2577UNMOUNTED_NOTICE_DEPS += $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
2578
Bowgo Tsai0013f552019-03-20 17:59:52 +08002579.PHONY: bootimage_debug-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002580bootimage_debug-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002581 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002582 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002583
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002584endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002585
Bowgo Tsai6a683672020-02-14 19:00:15 +08002586# -----------------------------------------------------------------
2587# vendor debug ramdisk
2588# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002589ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2590
Bowgo Tsai610286a2021-04-23 11:31:32 +08002591INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2592 $(ALL_GENERATED_SOURCES) \
2593 $(ALL_DEFAULT_INSTALLED_MODULES))
2594
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002595# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk.
2596INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT)
2597INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002598
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002599# Exclude recovery files in the default vendor ramdisk if including a standalone
2600# recovery ramdisk in vendor_boot.
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002601ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002602 ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2603 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT)
2604 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
2605 endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true
2606endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002607
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002608INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT)
2609INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
2610
2611# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created.
2612INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2613INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2614$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2615$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS)
2616$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2617 @echo "Installed file list: $@"
2618 $(hide) rm -f $@
2619 $(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2620 $(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2621 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2622
Bob Badour70c07dd2022-02-12 15:39:22 -08002623$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)))
2624
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002625INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
2626
Bowgo Tsai610286a2021-04-23 11:31:32 +08002627$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002628$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2629 $(hide) rm -f $@
2630 $(hide) mkdir -p $(dir $@)
2631 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002632
Petri Gyntherd7946d12021-03-10 12:38:15 -08002633INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2634$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002635 @echo "Target debug vendor ramdisk: $@"
Petri Gyntherd7946d12021-03-10 12:38:15 -08002636 $(copy-file-to-target)
Petri Gyntherd7946d12021-03-10 12:38:15 -08002637
Bob Badour70c07dd2022-02-12 15:39:22 -08002638$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),)
2639$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2640
2641VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2642
Bowgo Tsai6a683672020-02-14 19:00:15 +08002643# -----------------------------------------------------------------
2644# vendor_boot-debug.img.
2645INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2646
2647# The util to sign vendor_boot-debug.img with a test key.
2648BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2649INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2650# $(1): the vendor bootimage to sign
2651define test-key-sign-vendor-bootimage
2652$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2653$(AVBTOOL) add_hash_footer \
2654 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002655 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsai6a683672020-02-14 19:00:15 +08002656 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2657 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2658$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2659endef
2660
2661ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2662$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2663endif
2664
2665# 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 +08002666$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002667$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002668 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002669 $(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 +08002670 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2671 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2672
Bob Badour70c07dd2022-02-12 15:39:22 -08002673$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),)
2674$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2675
2676VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
2677
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002678endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai6a683672020-02-14 19:00:15 +08002679
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002680# Appends a few test harness specific properties into the adb_debug.prop.
2681ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2682ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2683
2684INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES)))
2685INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2686$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET)
2687 $(hide) rm -f $@
2688 $(hide) mkdir -p $(dir $@)
2689ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET
2690 $(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@
2691endif
2692 $(hide) echo "" >> $@
2693 $(hide) echo "#" >> $@
2694 $(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@
2695 $(hide) echo "#" >> $@
2696 $(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \
2697 echo "$(line)" >> $@;)
2698
Bob Badour2f66fd12022-03-09 17:30:24 -08002699$(call declare-1p-target,$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET))
2700
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002701INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
2702 $(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \
2703 $(ALL_GENERATED_SOURCES) \
2704 $(ALL_DEFAULT_INSTALLED_MODULES))
2705
2706# The order is important here. The test harness ramdisk staging directory has to
2707# come last so that it can override the adb_debug.prop in the debug ramdisk
2708# staging directory.
2709INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2710INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
2711
2712ifdef BUILDING_DEBUG_BOOT_IMAGE
2713
Bowgo Tsai0013f552019-03-20 17:59:52 +08002714# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002715# The test harness ramdisk, which is based off debug_ramdisk, plus a
2716# few additional test-harness-specific properties in adb_debug.prop.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002717INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002718
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002719$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS)
2720$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2721 @echo "Target test harness ramdisk: $@"
2722 $(hide) rm -f $@
2723 $(hide) mkdir -p $(dir $@)
2724 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002725
Bob Badour70c07dd2022-02-12 15:39:22 -08002726$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),)
2727$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS),$(PRODUCT_OUT)/:/)
2728
2729UNMOUNTED_NOTICE_DEPS += $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2730
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002731.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002732ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002733 @echo "make $@: ignoring dependencies"
2734 $(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2735 $(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS)
2736 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002737
2738# -----------------------------------------------------------------
2739# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2740#
2741# Note: it's intentional to skip signing for boot-test-harness.img, because it
2742# can only be used if the device is unlocked with verification error.
Steve Muckle4866bd62020-04-02 11:31:08 -07002743ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2744 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2745 $(PRODUCT_OUT)/$(k).img)
2746else
2747 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2748endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002749
2750# 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 +08002751$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002752INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2753
2754# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2755# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2756# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2757# public key, if the device is unlocked.
2758ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2759$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2760endif
2761
Steve Muckle4866bd62020-04-02 11:31:08 -07002762# $(1): output file
2763define build-boot-test-harness-target
2764 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002765 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002766 $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002767 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002768endef
2769
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002770# 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 +08002771$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002772 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002773 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002774
Bob Badour70c07dd2022-02-12 15:39:22 -08002775$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),)
2776$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2777
2778UNMOUNTED_NOTICE_DEPS += $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
2779
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002780.PHONY: bootimage_test_harness-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002781bootimage_test_harness-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002782 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002783 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002784
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002785endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002786
Bowgo Tsai87f60012021-07-29 23:35:33 +08002787# -----------------------------------------------------------------
2788# vendor test harness ramdisk, which is a vendor ramdisk combined with
2789# a test harness ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002790ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai87f60012021-07-29 23:35:33 +08002791
2792INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
2793
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002794# The order is important here. The test harness ramdisk staging directory has to
2795# come last so that it can override the adb_debug.prop in the debug ramdisk
2796# staging directory.
2797INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2798INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002799
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002800$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002801$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002802 $(hide) rm -f $@
2803 $(hide) mkdir -p $(dir $@)
2804 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai87f60012021-07-29 23:35:33 +08002805
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002806INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
2807$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2808 @echo "Target test harness vendor ramdisk: $@"
2809 $(copy-file-to-target)
2810
Bob Badour70c07dd2022-02-12 15:39:22 -08002811$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),)
2812$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2813
2814VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2815
Bowgo Tsai87f60012021-07-29 23:35:33 +08002816# -----------------------------------------------------------------
2817# vendor_boot-test-harness.img.
2818INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
2819
2820ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2821$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2822endif
2823
2824# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
2825$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
2826$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2827$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
2828 $(call pretty,"Target vendor_boot test harness image: $@")
2829 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
2830 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2831 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2832
Bob Badour70c07dd2022-02-12 15:39:22 -08002833$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),)
2834$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2835
2836VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
2837
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002838endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2839
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002840endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2841
Bowgo Tsai87f60012021-07-29 23:35:33 +08002842
Colin Crossbd382142020-08-26 15:08:57 -07002843# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2844# $1: from location (e.g $(TARGET_OUT)/vendor)
2845# $2: destination location (e.g. /vendor)
2846# $3: partition image name (e.g. vendor.img)
2847define create-partition-compat-symlink
2848$(eval \
2849$1:
2850 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2851 mkdir -p $(dir $1)
2852 if [ -d $1 ] && [ ! -h $1 ]; then \
2853 echo 'Non-symlink $1 detected!' 1>&2; \
2854 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2855 exit 1; \
2856 fi
2857 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002858$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002859)
2860$1
2861endef
2862
2863
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002864# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002865# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002866
Inseob Kim135c1f12022-01-06 17:22:07 +09002867# FSVerity metadata generation
2868# Generate fsverity metadata files (.fsv_meta) and build manifest
2869# (system/etc/security/fsverity/BuildManifest.apk) BEFORE filtering systemimage files below
2870ifeq ($(PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA),true)
2871
2872# Generate fsv_meta
2873fsverity-metadata-targets := $(sort $(filter \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08002874 $(TARGET_OUT)/framework/% \
Inseob Kim135c1f12022-01-06 17:22:07 +09002875 $(TARGET_OUT)/etc/boot-image.prof \
2876 $(TARGET_OUT)/etc/dirty-image-objects \
Nicolas Geoffray13f28212022-03-18 17:28:14 +00002877 $(TARGET_OUT)/etc/preloaded-classes \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08002878 $(TARGET_OUT)/etc/classpaths/%.pb, \
Inseob Kim135c1f12022-01-06 17:22:07 +09002879 $(ALL_GENERATED_SOURCES) $(ALL_DEFAULT_INSTALLED_MODULES)))
2880
2881define fsverity-generate-metadata
2882$(1).fsv_meta: PRIVATE_SRC := $(1)
2883$(1).fsv_meta: PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2884$(1).fsv_meta: $(HOST_OUT_EXECUTABLES)/fsverity_metadata_generator $(HOST_OUT_EXECUTABLES)/fsverity $(1)
2885 $$< --fsverity-path $$(PRIVATE_FSVERITY) --signature none \
2886 --hash-alg sha256 --output $$@ $$(PRIVATE_SRC)
2887endef
2888
2889$(foreach f,$(fsverity-metadata-targets),$(eval $(call fsverity-generate-metadata,$(f))))
2890ALL_DEFAULT_INSTALLED_MODULES += $(addsuffix .fsv_meta,$(fsverity-metadata-targets))
2891
2892# Generate BuildManifest.apk
2893FSVERITY_APK_KEY_PATH := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
2894FSVERITY_APK_OUT := $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk
2895FSVERITY_APK_MANIFEST_PATH := system/security/fsverity/AndroidManifest.xml
2896$(FSVERITY_APK_OUT): PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2897$(FSVERITY_APK_OUT): PRIVATE_AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002898$(FSVERITY_APK_OUT): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
Colin Cross658172d2022-01-27 12:45:13 -08002899$(FSVERITY_APK_OUT): PRIVATE_VERSION_CODE := $(PLATFORM_SDK_VERSION)
2900$(FSVERITY_APK_OUT): PRIVATE_VERSION_NAME := $(APPS_DEFAULT_VERSION_NAME)
Inseob Kim135c1f12022-01-06 17:22:07 +09002901$(FSVERITY_APK_OUT): PRIVATE_APKSIGNER := $(HOST_OUT_EXECUTABLES)/apksigner
2902$(FSVERITY_APK_OUT): PRIVATE_MANIFEST := $(FSVERITY_APK_MANIFEST_PATH)
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002903$(FSVERITY_APK_OUT): PRIVATE_FRAMEWORK_RES := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
Inseob Kim135c1f12022-01-06 17:22:07 +09002904$(FSVERITY_APK_OUT): PRIVATE_KEY := $(FSVERITY_APK_KEY_PATH)
2905$(FSVERITY_APK_OUT): PRIVATE_INPUTS := $(fsverity-metadata-targets)
2906$(FSVERITY_APK_OUT): $(HOST_OUT_EXECUTABLES)/fsverity_manifest_generator \
2907 $(HOST_OUT_EXECUTABLES)/fsverity $(HOST_OUT_EXECUTABLES)/aapt2 \
2908 $(HOST_OUT_EXECUTABLES)/apksigner $(FSVERITY_APK_MANIFEST_PATH) \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08002909 $(FSVERITY_APK_KEY_PATH).x509.pem $(FSVERITY_APK_KEY_PATH).pk8 \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002910 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08002911 $(fsverity-metadata-targets)
Inseob Kim135c1f12022-01-06 17:22:07 +09002912 $< --fsverity-path $(PRIVATE_FSVERITY) --aapt2-path $(PRIVATE_AAPT2) \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002913 --min-sdk-version $(PRIVATE_MIN_SDK_VERSION) \
Colin Cross658172d2022-01-27 12:45:13 -08002914 --version-code $(PRIVATE_VERSION_CODE) \
2915 --version-name $(PRIVATE_VERSION_NAME) \
Inseob Kim135c1f12022-01-06 17:22:07 +09002916 --apksigner-path $(PRIVATE_APKSIGNER) --apk-key-path $(PRIVATE_KEY) \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002917 --apk-manifest-path $(PRIVATE_MANIFEST) --framework-res $(PRIVATE_FRAMEWORK_RES) \
2918 --output $@ \
Inseob Kim135c1f12022-01-06 17:22:07 +09002919 --base-dir $(PRODUCT_OUT) $(PRIVATE_INPUTS)
2920
2921ALL_DEFAULT_INSTALLED_MODULES += $(FSVERITY_APK_OUT)
2922
2923endif # PRODUCT_SYSTEM_FSVERITY_GENERATE_METADATA
2924
Dan Willemsen37a19862018-10-31 16:31:46 -07002925INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002926 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002927 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002928
Colin Crossbd382142020-08-26 15:08:57 -07002929# Create symlink /system/vendor to /vendor if necessary.
2930ifdef BOARD_USES_VENDORIMAGE
2931 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2932endif
2933
2934# Create symlink /system/product to /product if necessary.
2935ifdef BOARD_USES_PRODUCTIMAGE
2936 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2937endif
2938
2939# Create symlink /system/system_ext to /system_ext if necessary.
2940ifdef BOARD_USES_SYSTEM_EXTIMAGE
2941 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2942endif
2943
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00002944# -----------------------------------------------------------------
2945# system_dlkm partition image
2946
2947# Create symlinks for system_dlkm on devices with a system_dlkm partition:
2948# /system/lib/modules -> /system_dlkm/lib/modules
2949#
2950# On devices with a system_dlkm partition,
2951# - /system/lib/modules is a symlink to a directory that stores system DLKMs.
2952# - The system_dlkm partition is mounted at /system_dlkm at runtime.
Ramji Jiyani13a41372022-01-27 07:05:08 +00002953ifdef BOARD_USES_SYSTEM_DLKMIMAGE
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00002954 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/lib/modules,/system_dlkm/lib/modules,system_dlkm.img)
2955endif
2956
Ying Wang82cceba2012-08-13 15:03:00 -07002957FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002958
2959# ASAN libraries in the system image - add dependency.
2960ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002961ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002962 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2963 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2964 endif
2965endif
2966
Tom Cherryd14b8952018-08-09 14:26:00 -07002967FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002968
Ying Wange5e8c5f2011-09-09 16:35:53 -07002969# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002970ifdef BUILDING_SYSTEM_IMAGE
2971
Kiyoung Kim36481e02020-11-16 10:50:05 +09002972# Install system linker configuration
2973# Collect all available stub libraries installed in system and install with predefined linker configuration
2974SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
Colin Crossd4a054f2022-03-15 15:07:07 -07002975SYSTEM_LINKER_CONFIG_SOURCE := $(call intermediates-dir-for,ETC,system_linker_config)/system_linker_config
2976$(SYSTEM_LINKER_CONFIG): PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE := $(SYSTEM_LINKER_CONFIG_SOURCE)
2977$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE) | conv_linker_config
2978 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE) \
Kiyoung Kim36481e02020-11-16 10:50:05 +09002979 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
2980
Bob Badour2f66fd12022-03-09 17:30:24 -08002981$(call declare-1p-target,$(SYSTEM_LINKER_CONFIG),)
Colin Crossd4a054f2022-03-15 15:07:07 -07002982$(call declare-license-deps,$(SYSTEM_LINKER_CONFIG),$(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE))
Bob Badour2f66fd12022-03-09 17:30:24 -08002983
Kiyoung Kim36481e02020-11-16 10:50:05 +09002984FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
2985
Ying Wange5e8c5f2011-09-09 16:35:53 -07002986# installed file list
2987# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2988# We put installed-files.txt ahead of image itself in the dependency graph
2989# so that we can get the size stat even if the build fails due to too large
2990# system image.
2991INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002992INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2993$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002994$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002995 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002996 mkdir -p $(dir $@)
2997 rm -f $@
2998 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
2999 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07003000
Bob Badour70c07dd2022-02-12 15:39:22 -08003001$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE)))
3002
Ying Wange5e8c5f2011-09-09 16:35:53 -07003003.PHONY: installed-file-list
3004installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08003005
Dan Willemsen616e7fd2021-09-16 14:50:08 -07003006ifeq ($(HOST_OS),linux)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07003007$(call dist-for-goals, sdk sdk_addon, $(INSTALLED_FILES_FILE))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07003008endif
Ying Wange5e8c5f2011-09-09 16:35:53 -07003009
3010systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003011 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003012BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
3013
The Android Open Source Project88b60792009-03-03 19:28:42 -08003014# $(1): output file
3015define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07003016 @echo "Target system fs image: $(1)"
3017 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003018 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07003019 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003020 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003021 $(BUILD_IMAGE) \
3022 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
3023 || ( mkdir -p $${DIST_DIR}; \
3024 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
3025 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08003026endef
3027
Dan Willemsen6b72c732019-06-12 21:33:38 +00003028ifeq ($(BOARD_AVB_ENABLE),true)
3029$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
3030endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07003031$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003032 $(call build-systemimage-target,$@)
3033
Bob Badour879cfa82021-04-15 10:41:38 -07003034$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
Bob Badour70c07dd2022-02-12 15:39:22 -08003035$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:/)
Bob Badour879cfa82021-04-15 10:41:38 -07003036
Tao Baoe9d61b02018-08-20 21:09:07 -07003037INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07003038SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003039
Tao Baoe9d61b02018-08-20 21:09:07 -07003040# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
3041# compatibility, in case device-specific Makefiles still refer to the old name.
3042INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
3043
Doug Zongker73ef8252009-07-23 15:12:53 -07003044# The system partition needs room for the recovery image as well. We
3045# now store the recovery image as a binary patch using the boot image
3046# as the source (since they are very similar). Generate the patch so
3047# we can see how big it's going to be, and include that in the system
3048# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07003049ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07003050ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07003051ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08003052ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08003053diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
3054else
3055diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
3056endif
Doug Zongker73ef8252009-07-23 15:12:53 -07003057intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
3058RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08003059$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
3060$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00003061 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07003062 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003063 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07003064 @echo "Construct recovery from boot"
3065 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07003066 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07003067else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
3068RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07003069endif # BOARD_USES_FULL_RECOVERY_IMAGE
3070endif # INSTALLED_RECOVERYIMAGE_TARGET
3071endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07003072
Yifan Hong9a3cad92020-04-27 19:06:59 -07003073$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003074 @echo "Install system fs image: $@"
3075 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003076 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003077
Bob Badour879cfa82021-04-15 10:41:38 -07003078$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
3079$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
3080
Tao Baoe9d61b02018-08-20 21:09:07 -07003081systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003082
Bob Badour70c07dd2022-02-12 15:39:22 -08003083SYSTEM_NOTICE_DEPS += $(INSTALLED_SYSTEMIMAGE_TARGET)
Bob Badour879cfa82021-04-15 10:41:38 -07003084
The Android Open Source Project88b60792009-03-03 19:28:42 -08003085.PHONY: systemimage-nodeps snod
3086systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07003087 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003088 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07003089 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00003090 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08003091ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00003092 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08003093endif
3094
Dan Willemsen67495202019-01-16 12:42:05 -08003095endif # BUILDING_SYSTEM_IMAGE
3096
Anton Hansson30e061b2018-11-12 13:36:46 +00003097.PHONY: sync syncsys
3098sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07003099
Ying Wang3a61eeb2016-03-11 10:32:01 -08003100# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07003101# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07003102.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07003103platform:
3104 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07003105
3106.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07003107platform-java:
3108 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07003109
Ying Wang3a61eeb2016-03-11 10:32:01 -08003110# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003111# data partition image
3112INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003113 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003114
Dan Willemsen67495202019-01-16 12:42:05 -08003115ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07003116userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003117 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07003118BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
3119
Ying Wangbd93d422011-10-28 17:02:30 -07003120define build-userdataimage-target
3121 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
3122 @mkdir -p $(TARGET_OUT_DATA)
3123 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003124 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003125 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003126 $(BUILD_IMAGE) \
3127 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
3128 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
3129 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07003130endef
3131
Joe Onorato64d85d02009-04-09 19:31:12 -07003132# We just build this directly to the install location.
3133INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003134INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
3135 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003136 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003137$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003138 $(build-userdataimage-target)
3139
Bob Badour70c07dd2022-02-12 15:39:22 -08003140$(call declare-1p-container,$(INSTALLED_USERDATAIMAGE_TARGET),)
3141$(call declare-container-license-deps,$(INSTALLED_USERDATAIMAGE_TARGET),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS),$(PRODUCT_OUT)/:/)
3142
3143UNMOUNTED_NOTICE_DEPS += $(INSTALLED_USERDATAIMAGE_TARGET)
3144
The Android Open Source Project88b60792009-03-03 19:28:42 -08003145.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07003146userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003147 $(build-userdataimage-target)
3148
Dan Willemsen67495202019-01-16 12:42:05 -08003149endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07003150
Andreas Gampe039b5c72017-03-24 16:06:31 -07003151# ASAN libraries in the system image - build rule.
3152ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
3153 $(TARGET_OUT_SHARED_LIBRARIES) \
3154 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
3155 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
3156 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07003157# Extra options: Enforce the system user for the files to avoid having to change ownership.
3158ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07003159# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
3160# enough space.
3161$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07003162 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 -07003163
The Android Open Source Project88b60792009-03-03 19:28:42 -08003164# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04003165# partition table image
3166ifdef BOARD_BPT_INPUT_FILES
3167
3168BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003169BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04003170
3171INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
3172 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003173 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04003174 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
3175
3176ifdef BOARD_BPT_DISK_SIZE
3177INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
3178endif
3179
3180define build-bptimage-target
3181 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
3182 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
3183endef
3184
3185INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003186$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
3187 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
3188
David Zeuthen25328622016-04-08 15:08:03 -04003189$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
3190 $(build-bptimage-target)
3191
Bob Badour70c07dd2022-02-12 15:39:22 -08003192$(call declare-1p-container,$(INSTALLED_BPTIMAGE_TARGET),)
3193$(call declare-container-license-deps,$(INSTALLED_BPTIMAGE_TARGET),$(BOARD_BPT_INPUT_FILES),$(PRODUCT_OUT)/:/)
3194
3195UNMOUNTED_NOTICE_DEPS += $(INSTALLED_BPTIMAGE_TARGET)
3196
David Zeuthen25328622016-04-08 15:08:03 -04003197.PHONY: bptimage-nodeps
3198bptimage-nodeps:
3199 $(build-bptimage-target)
3200
3201endif # BOARD_BPT_INPUT_FILES
3202
3203# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07003204# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003205ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003206INTERNAL_CACHEIMAGE_FILES := \
3207 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
3208
3209cacheimage_intermediates := \
3210 $(call intermediates-dir-for,PACKAGING,cache)
3211BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
3212
3213define build-cacheimage-target
3214 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
3215 @mkdir -p $(TARGET_OUT_CACHE)
3216 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003217 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003218 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003219 $(BUILD_IMAGE) \
3220 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
3221 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
3222 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07003223endef
3224
3225# We just build this directly to the install location.
3226INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003227$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07003228 $(build-cacheimage-target)
3229
Bob Badour70c07dd2022-02-12 15:39:22 -08003230$(call declare-1p-container,$(INSTALLED_CACHEIMAGE_TARGET),)
3231$(call declare-container-license-deps,$(INSTALLED_CACHEIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES),$(PRODUCT_OUT)/:/)
3232
3233UNMOUNTED_NOTICE_DEPS += $(INSTALLED_CACHEIMAGE_TARGET)
3234
Ying Wang9f8e8db2011-11-04 11:37:01 -07003235.PHONY: cacheimage-nodeps
3236cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3237 $(build-cacheimage-target)
3238
Dan Willemsen67495202019-01-16 12:42:05 -08003239else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07003240# we need to ignore the broken cache link when doing the rsync
3241IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08003242endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003243
David Zeuthen0eb10972016-09-28 17:55:27 -04003244# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07003245# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003246ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003247ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07003248# Marker file to identify that odex files are installed
3249INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
3250ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
3251$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
3252 $(hide) touch $@
Bob Badour2f66fd12022-03-09 17:30:24 -08003253
3254$(call declare-0p-target,$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER))
Alex Light4e358ab2016-06-16 14:47:10 -07003255endif
3256
Alex Light4e358ab2016-06-16 14:47:10 -07003257INTERNAL_SYSTEMOTHERIMAGE_FILES := \
3258 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003259 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07003260
Colin Cross6db5b0e2018-11-16 21:26:33 -08003261# system_other dex files are installed as a side-effect of installing system image files
3262INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
3263
Alex Light4e358ab2016-06-16 14:47:10 -07003264INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07003265INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
3266$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003267$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07003268 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003269 mkdir -p $(dir $@)
3270 rm -f $@
3271 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
3272 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07003273
Bob Badour70c07dd2022-02-12 15:39:22 -08003274$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEMOTHER)))
3275
Bowgo Tsai867ab662019-01-29 13:30:18 +08003276# Determines partition size for system_other.img.
3277ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
3278ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
3279INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
3280endif
3281endif
3282
3283ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
3284INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
3285endif
3286
Alex Light4e358ab2016-06-16 14:47:10 -07003287systemotherimage_intermediates := \
3288 $(call intermediates-dir-for,PACKAGING,system_other)
3289BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
3290
3291# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
3292define build-systemotherimage-target
3293 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
3294 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
3295 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003296 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003297 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003298 $(BUILD_IMAGE) \
3299 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
3300 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
3301 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07003302endef
3303
3304# We just build this directly to the install location.
3305INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003306ifneq (true,$(SANITIZE_LITE))
3307# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07003308$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
3309 $(build-systemotherimage-target)
Bob Badour70c07dd2022-02-12 15:39:22 -08003310
3311$(call declare-1p-container,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),)
3312$(call declare-container-license-deps,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES),$(PRODUCT_OUT)/:/)
3313
3314UNMOUNTED_NOTICE_DEPS += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003315endif
Alex Light4e358ab2016-06-16 14:47:10 -07003316
3317.PHONY: systemotherimage-nodeps
3318systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3319 $(build-systemotherimage-target)
3320
Dan Willemsen67495202019-01-16 12:42:05 -08003321endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003322
3323
3324# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07003325# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003326ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07003327INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07003328 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003329 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07003330
Ying Wang8da19e32015-09-15 14:22:12 -07003331
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003332# Create symlink /vendor/odm to /odm if necessary.
3333ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003334 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003335endif
3336
Yifan Honge51dff22020-06-23 17:26:57 -07003337# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
3338# /vendor/lib/modules -> /vendor_dlkm/lib/modules
3339#
3340# On devices with a vendor_dlkm partition,
3341# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
3342# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
3343# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3344# are hidden.
3345# On devices without a vendor_dlkm partition,
3346# - /vendor/lib/modules stores vendor DLKMs directly.
3347# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
3348# See system/core/rootdir/Android.mk for a list of created symlinks.
3349# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
3350# are not guaranteed to exist on all devices.
3351ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003352 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 -07003353endif
3354
Colin Crossbd382142020-08-26 15:08:57 -07003355INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
3356INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3357$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
3358$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3359 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003360 mkdir -p $(dir $@)
3361 rm -f $@
3362 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
3363 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07003364
Bob Badour70c07dd2022-02-12 15:39:22 -08003365$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR)))
3366
Ying Wanga0febe52013-03-20 11:02:05 -07003367vendorimage_intermediates := \
3368 $(call intermediates-dir-for,PACKAGING,vendor)
3369BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003370define build-vendorimage-target
3371 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3372 @mkdir -p $(TARGET_OUT_VENDOR)
3373 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003374 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003375 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003376 $(BUILD_IMAGE) \
3377 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3378 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003379 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003380endef
3381
3382# We just build this directly to the install location.
3383INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003384$(INSTALLED_VENDORIMAGE_TARGET): \
3385 $(INTERNAL_USERIMAGES_DEPS) \
3386 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003387 $(INSTALLED_FILES_FILE_VENDOR) \
3388 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003389 $(build-vendorimage-target)
3390
Bob Badour70c07dd2022-02-12 15:39:22 -08003391VENDOR_NOTICE_DEPS += $(INSTALLED_VENDORIMAGE_TARGET)
3392
3393$(call declare-1p-container,$(INSTALLED_VENDORIMAGE_TARGET),vendor)
3394$(call declare-container-license-deps,$(INSTALLED_VENDORIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(RECOVERY_FROM_BOOT_PATH),$(PRODUCT_OUT)/:/)
3395
Steven Morelanda2e734d2017-03-07 12:10:09 -08003396.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003397vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003398 $(build-vendorimage-target)
3399
Colin Cross91a52272017-06-20 16:57:52 -07003400sync: $(INTERNAL_VENDORIMAGE_FILES)
3401
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003402else ifdef BOARD_PREBUILT_VENDORIMAGE
3403INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3404$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
3405endif
Ying Wanga0febe52013-03-20 11:02:05 -07003406
Ying Wang9f8e8db2011-11-04 11:37:01 -07003407# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003408# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003409ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003410INTERNAL_PRODUCTIMAGE_FILES := \
3411 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003412 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003413
3414INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003415INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3416$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003417$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003418 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003419 mkdir -p $(dir $@)
3420 rm -f $@
3421 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3422 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003423
Bob Badour70c07dd2022-02-12 15:39:22 -08003424$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_PRODUCT)))
3425
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003426productimage_intermediates := \
3427 $(call intermediates-dir-for,PACKAGING,product)
3428BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3429define build-productimage-target
3430 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3431 @mkdir -p $(TARGET_OUT_PRODUCT)
3432 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003433 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003434 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003435 $(BUILD_IMAGE) \
3436 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3437 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3438 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003439endef
3440
3441# We just build this directly to the install location.
3442INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003443$(INSTALLED_PRODUCTIMAGE_TARGET): \
3444 $(INTERNAL_USERIMAGES_DEPS) \
3445 $(INTERNAL_PRODUCTIMAGE_FILES) \
3446 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003447 $(build-productimage-target)
3448
Bob Badour70c07dd2022-02-12 15:39:22 -08003449PRODUCT_NOTICE_DEPS += $(INSTALLED_PRODUCTIMAGE_TARGET)
3450
3451$(call declare-1p-container,$(INSTALLED_PRODUCTIMAGE_TARGET),)
3452$(call declare-container-license-deps,$(INSTALLED_PRODUCTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT),$(PRODUCT_OUT)/:/)
3453
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003454.PHONY: productimage-nodeps pnod
3455productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3456 $(build-productimage-target)
3457
3458sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3459
3460else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3461INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3462$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3463endif
3464
3465# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003466# system_ext partition image
3467ifdef BUILDING_SYSTEM_EXT_IMAGE
3468INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3469 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003470 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003471
Justin Yun6151e3f2019-06-25 15:58:13 +09003472INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3473INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3474$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3475$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003476 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003477 mkdir -p $(dir $@)
3478 rm -f $@
3479 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3480 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003481
Bob Badour70c07dd2022-02-12 15:39:22 -08003482$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_EXT)))
3483
Justin Yun6151e3f2019-06-25 15:58:13 +09003484system_extimage_intermediates := \
3485 $(call intermediates-dir-for,PACKAGING,system_ext)
3486BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3487define build-system_extimage-target
3488 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3489 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3490 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3491 $(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 -07003492 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003493 $(BUILD_IMAGE) \
3494 $(TARGET_OUT_SYSTEM_EXT) \
3495 $(system_extimage_intermediates)/system_ext_image_info.txt \
3496 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3497 $(TARGET_OUT)
3498 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003499endef
3500
3501# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003502INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003503$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3504 $(INTERNAL_USERIMAGES_DEPS) \
3505 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3506 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003507 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003508
Bob Badour70c07dd2022-02-12 15:39:22 -08003509SYSTEM_EXT_NOTICE_DEPS += $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
3510
3511$(call declare-1p-container,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),)
3512$(call declare-container-license-deps,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_EXT),$(PRODUCT_OUT)/:/)
3513
Justin Yun6151e3f2019-06-25 15:58:13 +09003514.PHONY: systemextimage-nodeps senod
3515systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3516 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003517
Justin Yun6151e3f2019-06-25 15:58:13 +09003518sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003519
Justin Yun6151e3f2019-06-25 15:58:13 +09003520else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3521INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3522$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003523endif
3524
3525# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003526# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003527ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003528INTERNAL_ODMIMAGE_FILES := \
3529 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003530 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003531
Colin Crossbd382142020-08-26 15:08:57 -07003532# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3533# /odm/lib/modules -> /odm_dlkm/lib/modules
3534#
3535# On devices with a odm_dlkm partition,
3536# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3537# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3538# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3539# are hidden.
3540# On devices without a odm_dlkm partition,
3541# - /odm/lib/modules stores odm DLKMs directly.
3542# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3543# See system/core/rootdir/Android.mk for a list of created symlinks.
3544# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3545# are not guaranteed to exist on all devices.
3546ifdef BOARD_USES_ODM_DLKMIMAGE
3547 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3548endif
3549
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003550INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3551INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3552$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003553$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003554 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003555 mkdir -p $(dir $@)
3556 rm -f $@
3557 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3558 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003559
Bob Badour70c07dd2022-02-12 15:39:22 -08003560$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM)))
3561
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003562odmimage_intermediates := \
3563 $(call intermediates-dir-for,PACKAGING,odm)
3564BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3565define build-odmimage-target
3566 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3567 @mkdir -p $(TARGET_OUT_ODM)
3568 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003569 $(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
3570 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003571 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003572 $(BUILD_IMAGE) \
3573 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3574 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3575 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003576endef
3577
3578# We just build this directly to the install location.
3579INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003580$(INSTALLED_ODMIMAGE_TARGET): \
3581 $(INTERNAL_USERIMAGES_DEPS) \
3582 $(INTERNAL_ODMIMAGE_FILES) \
3583 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003584 $(build-odmimage-target)
3585
Bob Badour70c07dd2022-02-12 15:39:22 -08003586ODM_NOTICE_DEPS += $(INSTALLED_ODMIMAGE_TARGET)
3587
3588$(call declare-1p-container,$(INSTALLED_ODMIMAGE_TARGET),)
3589$(call declare-container-license-deps,$(INSTALLED_ODMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM),$(PRODUCT_OUT)/:/)
3590
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003591.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003592odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003593 $(build-odmimage-target)
3594
3595sync: $(INTERNAL_ODMIMAGE_FILES)
3596
3597else ifdef BOARD_PREBUILT_ODMIMAGE
3598INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3599$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3600endif
3601
3602# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003603# vendor_dlkm partition image
3604ifdef BUILDING_VENDOR_DLKM_IMAGE
3605INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3606 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003607 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003608
3609INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3610INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3611$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3612$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3613 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003614 mkdir -p $(dir $@)
3615 rm -f $@
3616 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3617 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003618
Bob Badour70c07dd2022-02-12 15:39:22 -08003619$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DLKM)))
3620
Yifan Hongcfb917a2020-05-07 14:58:20 -07003621vendor_dlkmimage_intermediates := \
3622 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3623BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3624define build-vendor_dlkmimage-target
3625 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3626 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3627 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003628 $(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
3629 vendor_dlkm, skip_fsck=true)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003630 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3631 $(BUILD_IMAGE) \
3632 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3633 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3634 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3635endef
3636
3637# We just build this directly to the install location.
3638INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3639$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3640 $(INTERNAL_USERIMAGES_DEPS) \
3641 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3642 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3643 $(build-vendor_dlkmimage-target)
3644
Bob Badour70c07dd2022-02-12 15:39:22 -08003645VENDOR_DLKM_NOTICE_DEPS += $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
3646
3647$(call declare-1p-container,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),)
3648$(call declare-container-license-deps,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR_DLKM),$(PRODUCT_OUT)/:/)
3649
Yifan Hongcfb917a2020-05-07 14:58:20 -07003650.PHONY: vendor_dlkmimage-nodeps vdnod
3651vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3652 $(build-vendor_dlkmimage-target)
3653
3654sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3655
3656else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3657INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3658$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3659endif
3660
3661# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003662# odm_dlkm partition image
3663ifdef BUILDING_ODM_DLKM_IMAGE
3664INTERNAL_ODM_DLKMIMAGE_FILES := \
3665 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003666 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003667
3668INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3669INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3670$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3671$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3672 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003673 mkdir -p $(dir $@)
3674 rm -f $@
3675 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3676 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003677
Bob Badour70c07dd2022-02-12 15:39:22 -08003678$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM_DLKM)))
3679
Yifan Hongf496f1b2020-07-15 16:52:59 -07003680odm_dlkmimage_intermediates := \
3681 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3682BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3683define build-odm_dlkmimage-target
3684 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3685 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3686 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003687 $(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
3688 odm_dlkm, skip_fsck=true)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003689 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3690 $(BUILD_IMAGE) \
3691 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3692 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3693 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3694endef
3695
3696# We just build this directly to the install location.
3697INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3698$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3699 $(INTERNAL_USERIMAGES_DEPS) \
3700 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3701 $(INSTALLED_FILES_FILE_ODM_DLKM)
3702 $(build-odm_dlkmimage-target)
3703
Bob Badour70c07dd2022-02-12 15:39:22 -08003704ODM_DLKM_NOTICE_DEPS += $(INSTALLED_ODM_DLKMIMAGE_TARGET)
3705
3706$(call declare-1p-container,$(INSTALLED_ODM_DLKMIMAGE_TARGET),)
3707$(call declare-container-license-deps,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM_DLKM),$(PRODUCT_OUT)/:/)
3708
Yifan Hongf496f1b2020-07-15 16:52:59 -07003709.PHONY: odm_dlkmimage-nodeps odnod
3710odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3711 $(build-odm_dlkmimage-target)
3712
3713sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3714
3715else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3716INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3717$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3718endif
3719
Ramji Jiyani13a41372022-01-27 07:05:08 +00003720# -----------------------------------------------------------------
3721# system_dlkm partition image
3722
3723ifdef BUILDING_SYSTEM_DLKM_IMAGE
3724
3725INTERNAL_SYSTEM_DLKMIMAGE_FILES := \
3726 $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,\
3727 $(ALL_DEFAULT_INSTALLED_MODULES))
3728
3729INSTALLED_FILES_FILE_SYSTEM_DLKM := $(PRODUCT_OUT)/installed-files-system_dlkm.txt
3730INSTALLED_FILES_JSON_SYSTEM_DLKM := $(INSTALLED_FILES_FILE_SYSTEM_DLKM:.txt=.json)
3731$(INSTALLED_FILES_FILE_SYSTEM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_DLKM)
3732$(INSTALLED_FILES_FILE_SYSTEM_DLKM): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3733 @echo Installed file list: $@
3734 mkdir -p $(dir $@)
3735 if [ -d "$(BOARD_SYSTEM_DLKM_SRC)" ]; then rsync -rupE $(BOARD_SYSTEM_DLKM_SRC)/ $(TARGET_OUT_SYSTEM_DLKM); fi
3736 rm -f $@
3737 $(FILESLIST) $(TARGET_OUT_SYSTEM_DLKM) > $(@:.txt=.json)
3738 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3739
Bob Badour70c07dd2022-02-12 15:39:22 -08003740$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_DLKM)))
3741
Ramji Jiyani13a41372022-01-27 07:05:08 +00003742system_dlkmimage_intermediates := \
3743 $(call intermediates-dir-for,PACKAGING,system_dlkm)
3744BUILT_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3745define build-system_dlkmimage-target
3746 $(call pretty,"Target system_dlkm fs image: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)")
3747 @mkdir -p $(TARGET_OUT_SYSTEM_DLKM)
3748 @mkdir -p $(system_dlkmimage_intermediates) && rm -rf $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt
3749 $(call generate-image-prop-dictionary, $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt, \
3750 system_dlkm, skip_fsck=true)
3751 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3752 $(BUILD_IMAGE) \
3753 $(TARGET_OUT_SYSTEM_DLKM) $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt \
3754 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3755 $(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
3756endef
3757
3758# We just build this directly to the install location.
3759INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
3760$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): \
3761 $(INTERNAL_USERIMAGES_DEPS) \
3762 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
3763 $(INSTALLED_FILES_FILE_SYSTEM_DLKM)
3764 $(build-system_dlkmimage-target)
3765
3766.PHONY: system_dlkmimage-nodeps sdnod
3767system_dlkmimage-nodeps sdnod: | $(INTERNAL_USERIMAGES_DEPS)
3768 $(build-system_dlkmimage-target)
3769
3770sync: $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
3771
3772else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
3773INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3774$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_DLKMIMAGE),$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)))
3775endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07003776
3777# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003778# dtbo image
3779ifdef BOARD_PREBUILT_DTBOIMAGE
3780INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3781
3782ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003783$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003784 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3785 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003786 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003787 $(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003788 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3789 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08003790
3791$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_TARGET),)
3792$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_TARGET),$(BOARD_PREBUILT_DTBOIMAGE),$(PRODUCT_OUT)/:/)
3793
3794UNMOUNTED_NOTICE_DEPS += $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003795else
3796$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3797 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3798endif
3799
Tao Bao0da43472018-08-22 22:53:41 -07003800endif # BOARD_PREBUILT_DTBOIMAGE
3801
Andrew Scull9b103e42020-11-29 14:04:28 +00003802# -----------------------------------------------------------------
3803# Protected VM firmware image
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003804ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00003805INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00003806INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
Pierre-Clément Tosi3bda0d62021-09-21 13:49:35 +02003807INTERNAL_PREBUILT_PVMFWIMAGE := packages/modules/Virtualization/pvmfw/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00003808INTERNAL_PVMFW_EMBEDDED_AVBKEY := external/avb/test/data/testkey_rsa4096_pub.bin
Andrew Scull9b103e42020-11-29 14:04:28 +00003809
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003810ifdef BOARD_PREBUILT_PVMFWIMAGE
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003811PREBUILT_PVMFWIMAGE_TARGET := $(BOARD_PREBUILT_PVMFWIMAGE)
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01003812else
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003813PREBUILT_PVMFWIMAGE_TARGET := $(INTERNAL_PREBUILT_PVMFWIMAGE)
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003814endif
Andrew Scull9b103e42020-11-29 14:04:28 +00003815
3816ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003817$(INSTALLED_PVMFWIMAGE_TARGET): $(PREBUILT_PVMFWIMAGE_TARGET) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH)
3818 cp $< $@
Andrew Scull9b103e42020-11-29 14:04:28 +00003819 $(AVBTOOL) add_hash_footer \
3820 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003821 $(call get-partition-size-argument,$(BOARD_PVMFWIMAGE_PARTITION_SIZE)) \
Andrew Scull9b103e42020-11-29 14:04:28 +00003822 --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \
3823 $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)
Bob Badour70c07dd2022-02-12 15:39:22 -08003824
3825$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
3826$(call declare-container-license-deps,$(INSTALLED_PVMFWIMAGE_TARGET),$(PREBUILT_PVMFWIMAGE_TARGET),$(PRODUCT_OUT)/:/)
3827
3828UNMOUNTED_NOTICE_DEPS += $(INSTALLED_PVMFWIMAGE_TARGET)
Andrew Scull9b103e42020-11-29 14:04:28 +00003829else
Pierre-Clément Tosi37aa7e42022-02-01 13:01:28 +01003830$(eval $(call copy-one-file,$(PREBUILT_PVMFWIMAGE_TARGET),$(INSTALLED_PVMFWIMAGE_TARGET)))
Andrew Scull9b103e42020-11-29 14:04:28 +00003831endif
3832
Andrew Scullbbc930b2022-02-17 22:34:27 +00003833$(INSTALLED_PVMFWIMAGE_TARGET): $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)
3834
3835$(eval $(call copy-one-file,$(INTERNAL_PVMFW_EMBEDDED_AVBKEY),$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)))
3836
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003837endif # BOARD_USES_PVMFWIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00003838
Tao Bao0da43472018-08-22 22:53:41 -07003839# Returns a list of image targets corresponding to the given list of partitions. For example, it
3840# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3841# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003842# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003843define images-for-partitions
Bowgo Tsai4f62aa02022-01-04 14:21:39 +08003844$(strip $(foreach item,$(1),\
3845 $(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
3846 $(if $(filter $(item),init_boot),$(INSTALLED_INIT_BOOT_IMAGE_TARGET),\
Ramji Jiyani13a41372022-01-27 07:05:08 +00003847 $(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))))
Tao Bao0da43472018-08-22 22:53:41 -07003848endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003849
3850# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003851# custom images
3852INSTALLED_CUSTOMIMAGES_TARGET :=
3853
3854ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3855INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3856
3857# Sign custom image.
3858# $(1): the prebuilt custom image.
3859# $(2): the mount point of the prebuilt custom image.
3860# $(3): the signed custom image target.
3861define sign_custom_image
3862$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3863 @echo Target custom image: $(3)
3864 mkdir -p $(dir $(3))
3865 cp $(1) $(3)
3866ifeq ($(BOARD_AVB_ENABLE),true)
3867 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3868 $(AVBTOOL) add_hashtree_footer \
3869 --image $(3) \
3870 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3871 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003872 $(call get-partition-size-argument,$(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE)) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003873 --partition_name $(2) \
3874 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3875 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3876endif
3877INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3878endef
3879
3880$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3881 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3882 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3883endif
3884
3885# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003886# vbmeta image
3887ifeq ($(BOARD_AVB_ENABLE),true)
3888
3889BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003890AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003891
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003892ifdef BOARD_AVB_KEY_PATH
3893$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3894else
3895# If key path isn't specified, use the 4096-bit test key.
3896BOARD_AVB_ALGORITHM := SHA256_RSA4096
3897BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3898endif
3899
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003900# AVB signing for system_other.img.
3901ifdef BUILDING_SYSTEM_OTHER_IMAGE
3902ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3903$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3904else
3905# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3906BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3907BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3908endif
3909
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003910$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3911 @echo Extracting system_other avb key: $@
3912 @rm -f $@
3913 @mkdir -p $(dir $@)
3914 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003915
Bob Badour70c07dd2022-02-12 15:39:22 -08003916$(eval $(call declare-0p-target,$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET),))
3917
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003918ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3919BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3920endif
3921
3922BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3923endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3924
Tao Bao744c4c72018-08-20 21:09:07 -07003925INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003926 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003927 $(BOARD_AVB_VBMETA_VENDOR)
3928
3929# Not allowing the same partition to appear in multiple groups.
3930ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003931 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003932endif
3933
cfig1aeef722019-09-20 22:45:06 +08003934# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3935# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3936# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003937ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003938ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3939$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003940 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003941 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3942endif
3943endif
3944
Bowgo Tsai9b548012019-05-14 16:57:03 +08003945# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003946
3947BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003948 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003949 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003950 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3951
3952BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003953 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003954 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003955 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3956
Justin Yun6151e3f2019-06-25 15:58:13 +09003957BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003958 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003959 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003960 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003961
Bowgo Tsai9b548012019-05-14 16:57:03 +08003962BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsai8c7f8202022-02-22 14:47:45 +08003963 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003964
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08003965BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
3966 --prop com.android.build.init_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3967 --prop com.android.build.init_boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3968
Tao Bao19b02fe2019-10-09 00:04:28 -07003969BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3970 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3971
3972BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3973 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3974
Bowgo Tsai9b548012019-05-14 16:57:03 +08003975BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003976 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003977 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003978
3979BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003980 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003981 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003982
Yifan Hongcfb917a2020-05-07 14:58:20 -07003983BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3984 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3985 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3986
Yifan Hongf496f1b2020-07-15 16:52:59 -07003987BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3988 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3989 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3990
Ramji Jiyani13a41372022-01-27 07:05:08 +00003991BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3992 --prop com.android.build.system_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3993 --prop com.android.build.system_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3994
Tao Bao19b02fe2019-10-09 00:04:28 -07003995BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3996 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3997
Andrew Scull9b103e42020-11-29 14:04:28 +00003998BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3999 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4000
Bowgo Tsai9b548012019-05-14 16:57:03 +08004001# The following vendor- and odm-specific images needs explicit SPL set per board.
Devin Moore380d9e42021-11-04 19:01:19 +00004002# TODO(b/210875415) Is this security_patch property used? Should it be removed from
4003# boot.img when there is no platform ramdisk included in it?
Bowgo Tsai8c7f8202022-02-22 14:47:45 +08004004ifdef BOOT_OS_VERSION
4005BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4006 --prop com.android.build.boot.os_version:$(BOOT_OS_VERSION)
4007else
4008BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4009 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
4010endif
4011
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004012ifdef BOOT_SECURITY_PATCH
4013BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4014 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004015endif
4016
4017ifdef INIT_BOOT_SECURITY_PATCH
4018BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4019 --prop com.android.build.init_boot.security_patch:$(INIT_BOOT_SECURITY_PATCH)
4020else ifdef BOOT_SECURITY_PATCH
Devin Moore380d9e42021-11-04 19:01:19 +00004021BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4022 --prop com.android.build.init_boot.security_patch:$(BOOT_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004023endif
4024
4025ifdef VENDOR_SECURITY_PATCH
4026BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4027 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
4028endif
4029
4030ifdef ODM_SECURITY_PATCH
4031BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4032 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
4033endif
4034
Yifan Hongcfb917a2020-05-07 14:58:20 -07004035ifdef VENDOR_DLKM_SECURITY_PATCH
4036BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4037 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
4038endif
4039
Yifan Hongf496f1b2020-07-15 16:52:59 -07004040ifdef ODM_DLKM_SECURITY_PATCH
4041BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4042 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
4043endif
4044
Ramji Jiyani13a41372022-01-27 07:05:08 +00004045ifdef SYSTEM_DLKM_SECURITY_PATCH
4046BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4047 --prop com.android.build.system_dlkm.security_patch:$(SYSTEM_DLKM_SECURITY_PATCH)
4048endif
4049
Andrew Scull9b103e42020-11-29 14:04:28 +00004050ifdef PVMFW_SECURITY_PATCH
4051BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4052 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
4053endif
4054
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004055BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Devin Moore380d9e42021-11-04 19:01:19 +00004056INIT_BOOT_FOOTER_ARGS := BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07004057VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004058DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00004059PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004060SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
4061VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05004062RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004063PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09004064SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004065ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07004066VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07004067ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Ramji Jiyani13a41372022-01-27 07:05:08 +00004068SYSTEM_DLKM_FOOTER_ARGS := BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004069
Tao Bao0da43472018-08-22 22:53:41 -07004070# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004071# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07004072define _check-and-set-avb-chain-args
4073$(eval part := $(1))
4074$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004075
4076$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
4077$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
4078$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
4079$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4080$(if $($(_key_path)),,$(error $(_key_path) is not defined))
4081$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
4082$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
4083$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4084
4085# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
4086$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
4087$(eval $(_signing_args) := \
4088 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
4089
cfig1aeef722019-09-20 22:45:06 +08004090# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
4091# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07004092$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08004093 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4094 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004095
Tao Bao744c4c72018-08-20 21:09:07 -07004096# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07004097# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07004098$(if $(filter $(part),$(part:vbmeta_%=%)),\
4099 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
4100 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004101endef
4102
Tao Bao0da43472018-08-22 22:53:41 -07004103# Checks and sets the required build variables for an AVB partition. The partition will be
4104# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07004105# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
4106# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004107# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
4108# but vbmeta would capture the image descriptor of only the first boot
4109# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07004110# $(1): Partition name, e.g. boot or system.
4111define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07004112$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07004113$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07004114 $(if $(_in_chained_vbmeta),\
4115 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07004116 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07004117 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004118 $(if $(filter boot,$(1)),\
4119 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4120 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
4121 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4122 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07004123endef
4124
Hongguang Chenf23364d2020-04-27 18:36:36 -07004125# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
4126# $(1): the custom partition to enable AVB chain.
4127define check-and-set-custom-avb-chain-args
4128$(eval part := $(1))
4129$(eval PART=$(call to-upper,$(part)))
4130$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4131$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4132
4133INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4134 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
4135endef
4136
Tao Baob1a2e352018-08-14 16:17:12 -07004137ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004138$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07004139endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004140
Devin Moore380d9e42021-11-04 19:01:19 +00004141ifdef INSTALLED_INIT_BOOT_IMAGE_TARGET
4142$(eval $(call check-and-set-avb-args,init_boot))
4143endif
4144
Steve Mucklee1b10862019-07-10 10:49:37 -07004145ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4146$(eval $(call check-and-set-avb-args,vendor_boot))
4147endif
4148
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004149ifdef INSTALLED_SYSTEMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004150$(eval $(call check-and-set-avb-args,system))
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004151endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004152
4153ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004154$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004155endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004156
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004157ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004158$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004159endif
4160
Justin Yun6151e3f2019-06-25 15:58:13 +09004161ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4162$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07004163endif
4164
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004165ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004166$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004167endif
4168
Yifan Hongcfb917a2020-05-07 14:58:20 -07004169ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
4170$(eval $(call check-and-set-avb-args,vendor_dlkm))
4171endif
4172
Yifan Hongf496f1b2020-07-15 16:52:59 -07004173ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
4174$(eval $(call check-and-set-avb-args,odm_dlkm))
4175endif
4176
Ramji Jiyani13a41372022-01-27 07:05:08 +00004177ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
4178$(eval $(call check-and-set-avb-args,system_dlkm))
4179endif
4180
Yueyao Zhu211c9012017-04-27 00:34:50 -07004181ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004182$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004183endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07004184
Andrew Scull9b103e42020-11-29 14:04:28 +00004185ifdef INSTALLED_PVMFWIMAGE_TARGET
4186$(eval $(call check-and-set-avb-args,pvmfw))
4187endif
4188
David Zeuthen8fecb282017-12-01 16:24:01 -05004189ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004190$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05004191endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08004192
David Anderson7709ab22018-10-15 14:41:34 -07004193# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
4194ifdef BOARD_AVB_VBMETA_SYSTEM
4195$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07004196endif
4197
4198ifdef BOARD_AVB_VBMETA_VENDOR
4199$(eval $(call check-and-set-avb-args,vbmeta_vendor))
4200endif
4201
Hongguang Chenf23364d2020-04-27 18:36:36 -07004202ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4203$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4204 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
4205endif
4206
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004207# Add kernel cmdline descriptor for kernel to mount system.img as root with
4208# dm-verity. This works when system.img is either chained or not-chained:
4209# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
4210# cmdline descriptor to system.img
4211# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
4212# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08004213ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07004214ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004215BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08004216endif
David Anderson8916a2a2018-09-18 15:46:59 -07004217endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08004218
Tao Bao0da43472018-08-22 22:53:41 -07004219BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07004220BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07004221BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
4222
4223ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07004224# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07004225BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07004226endif
Tao Bao0da43472018-08-22 22:53:41 -07004227
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004228ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004229BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004230endif
4231
David Anderson7709ab22018-10-15 14:41:34 -07004232ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
4233BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
4234 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07004235endif
4236
4237ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
4238BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
4239 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07004240endif
4241
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004242# $(1): the directory to extract public keys to
4243define extract-avb-chain-public-keys
4244 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
4245 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
4246 --output $(1)/boot.avbpubkey)
Devin Moore380d9e42021-11-04 19:01:19 +00004247 $(if $(BOARD_AVB_INIT_BOOT_KEY_PATH),\
4248 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_INIT_BOOT_KEY_PATH) \
4249 --output $(1)/init_boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07004250 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
4251 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
4252 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004253 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
4254 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
4255 --output $(1)/system.avbpubkey)
4256 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
4257 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
4258 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004259 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
4260 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
4261 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09004262 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
4263 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
4264 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004265 $(if $(BOARD_AVB_ODM_KEY_PATH),\
4266 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
4267 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004268 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
4269 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
4270 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004271 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
4272 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
4273 --output $(1)/odm_dlkm.avbpubkey)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004274 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
4275 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH) \
4276 --output $(1)/system_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004277 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
4278 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
4279 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00004280 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
4281 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
4282 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05004283 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
4284 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
4285 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07004286 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
4287 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4288 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07004289 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
4290 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4291 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07004292 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
4293 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4294 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
4295 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004296endef
4297
Tao Bao744c4c72018-08-20 21:09:07 -07004298# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
4299# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07004300# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09004301# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
4302# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07004303# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004304# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07004305# $(2): Output filename.
4306define build-chained-vbmeta-image
4307 $(call pretty,"Target chained vbmeta image: $@")
4308 $(hide) $(AVBTOOL) make_vbmeta_image \
4309 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
4310 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
4311 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
4312 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
4313 --output $@
4314endef
4315
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004316ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07004317ifdef BOARD_AVB_VBMETA_SYSTEM
4318INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
4319$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004320 $(AVBTOOL) \
4321 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
4322 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07004323 $(call build-chained-vbmeta-image,vbmeta_system)
Bob Badour70c07dd2022-02-12 15:39:22 -08004324
4325$(call declare-1p-container,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET),)
4326
4327SYSTEM_NOTICE_DEPS += $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004328endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004329endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07004330
4331ifdef BOARD_AVB_VBMETA_VENDOR
4332INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
4333$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004334 $(AVBTOOL) \
4335 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
4336 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07004337 $(call build-chained-vbmeta-image,vbmeta_vendor)
Bob Badour70c07dd2022-02-12 15:39:22 -08004338
4339$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
4340
4341UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004342endif
4343
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004344define build-vbmetaimage-target
4345 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004346 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
4347 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004348 $(hide) $(AVBTOOL) make_vbmeta_image \
4349 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07004350 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004351 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
4352 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004353 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004354endef
4355
Paul Trautrim4e143232019-08-13 16:30:57 +09004356ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004357INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07004358$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4359 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
4360
David Zeuthen8fecb282017-12-01 16:24:01 -05004361$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004362 $(AVBTOOL) \
4363 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00004364 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004365 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004366 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4367 $(INSTALLED_VENDORIMAGE_TARGET) \
4368 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004369 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004370 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004371 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004372 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004373 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004374 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004375 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004376 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004377 $(INSTALLED_RECOVERYIMAGE_TARGET) \
4378 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
4379 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
4380 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4381 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4382 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004383 $(build-vbmetaimage-target)
4384
Bob Badour70c07dd2022-02-12 15:39:22 -08004385$(call declare-1p-container,$(INSTALLED_VBMETAIMAGE_TARGET),)
4386
4387UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETAIMAGE_TARGET)
4388
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004389.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08004390vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4391 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004392vbmetaimage-nodeps:
4393 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09004394endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004395
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004396endif # BOARD_AVB_ENABLE
4397
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004398# List of files from all images
4399INTERNAL_ALLIMAGES_FILES := \
4400 $(FULL_SYSTEMIMAGE_DEPS) \
4401 $(INTERNAL_RAMDISK_FILES) \
4402 $(INTERNAL_USERDATAIMAGE_FILES) \
4403 $(INTERNAL_VENDORIMAGE_FILES) \
4404 $(INTERNAL_PRODUCTIMAGE_FILES) \
4405 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4406 $(INTERNAL_ODMIMAGE_FILES) \
4407 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4408 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004409 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004410
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004411# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004412# Check VINTF of build
4413
Ramji Jiyani13a41372022-01-27 07:05:08 +00004414# Note: vendor_dlkm, odm_dlkm, and system_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004415ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07004416
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004417intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
4418check_vintf_all_deps :=
4419
Yifan Hongaf9b0702020-01-21 12:46:57 -08004420# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
4421# because they are only used for prebuilt images.
4422check_vintf_common_srcs_patterns := \
4423 $(TARGET_OUT)/etc/vintf/% \
4424 $(TARGET_OUT_VENDOR)/etc/vintf/% \
4425 $(TARGET_OUT_ODM)/etc/vintf/% \
4426 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
4427 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
4428
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004429check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08004430check_vintf_common_srcs_patterns :=
4431
4432check_vintf_has_system :=
4433check_vintf_has_vendor :=
4434
Yifan Hong28ffd732020-03-13 13:11:10 -07004435ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
4436$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
4437endif
4438ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
4439$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
4440endif
4441
Yifan Hong605ea042020-01-14 21:36:00 +00004442# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08004443check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
4444ifneq ($(check_vintf_system_deps),)
4445check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00004446
Yifan Hongfd150d32021-03-09 12:19:11 -08004447check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00004448check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004449$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00004450 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
4451check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00004452
Yifan Hongfd150d32021-03-09 12:19:11 -08004453vintffm_log := $(intermediates)/vintffm.log
Yifan Hong7a157b02020-10-20 17:08:11 +00004454check_vintf_all_deps += $(vintffm_log)
4455$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
4456 @( $< --check --dirmap /system:$(TARGET_OUT) \
4457 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
4458
Yifan Hongaf9b0702020-01-21 12:46:57 -08004459endif # check_vintf_system_deps
4460check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004461
4462# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004463check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
4464ifneq ($(check_vintf_vendor_deps),)
4465check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08004466check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00004467check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07004468# Check vendor SKU=(empty) case when:
4469# - DEVICE_MANIFEST_FILE is not empty; OR
4470# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004471$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004472 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4473 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004474 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004475$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07004476 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4477 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4478 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4479 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00004480check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08004481endif # check_vintf_vendor_deps
4482check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004483
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004484# -- Kernel version and configurations.
4485ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
4486
Yifan Hong605ea042020-01-14 21:36:00 +00004487BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
4488BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
4489
4490my_board_extracted_kernel :=
4491
4492# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
4493# from INSTALLED_KERNEL_TARGET.
4494ifdef BOARD_KERNEL_CONFIG_FILE
4495ifdef BOARD_KERNEL_VERSION
4496$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
4497 cp $< $@
4498$(BUILT_KERNEL_VERSION_FILE):
4499 echo $(BOARD_KERNEL_VERSION) > $@
4500
4501my_board_extracted_kernel := true
4502endif # BOARD_KERNEL_VERSION
4503endif # BOARD_KERNEL_CONFIG_FILE
4504
4505ifneq ($(my_board_extracted_kernel),true)
Yifan Hong605ea042020-01-14 21:36:00 +00004506# Tools for decompression that is not in PATH.
4507# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
4508# Algorithms that are in the script but not in this list will be found in PATH.
4509my_decompress_tools := \
4510 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
4511
Yifan Hongb1627772021-07-14 15:01:50 -07004512endif # my_board_extracted_kernel
4513
4514ifneq ($(my_board_extracted_kernel),true)
4515ifdef INSTALLED_KERNEL_TARGET
Yifan Hong605ea042020-01-14 21:36:00 +00004516$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4517$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4518$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07004519$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
4520 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00004521 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08004522 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00004523
Yifan Hongb1627772021-07-14 15:01:50 -07004524my_board_extracted_kernel := true
Yifan Hong605ea042020-01-14 21:36:00 +00004525endif # INSTALLED_KERNEL_TARGET
Yifan Hongb1627772021-07-14 15:01:50 -07004526endif # my_board_extracted_kernel
4527
4528ifneq ($(my_board_extracted_kernel),true)
4529ifdef INSTALLED_BOOTIMAGE_TARGET
4530$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4531$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4532$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
4533$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
4534$(BUILT_KERNEL_CONFIGS_FILE): \
4535 $(HOST_OUT_EXECUTABLES)/unpack_bootimg \
4536 $(EXTRACT_KERNEL) \
4537 $(INSTALLED_BOOTIMAGE_TARGET)
4538 $(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
4539 $(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
4540 --output-configs $@ \
4541 --output-release $(BUILT_KERNEL_VERSION_FILE)
4542
4543my_board_extracted_kernel := true
4544endif # INSTALLED_BOOTIMAGE_TARGET
4545endif # my_board_extracted_kernel
4546
4547ifneq ($(my_board_extracted_kernel),true)
4548$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
4549 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
4550 cannot be built into OTA update package. You can fix this by: \
4551 (1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
4552 so that kernel information will be extracted from the built kernel; or \
4553 (2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
4554 (3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
4555 BOARD_KERNEL_VERSION manually; or \
4556 (4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
4557# Clear their values to indicate that these two files does not exist.
4558BUILT_KERNEL_CONFIGS_FILE :=
4559BUILT_KERNEL_VERSION_FILE :=
4560endif
4561
4562my_decompress_tools :=
4563my_board_extracted_kernel :=
Yifan Hong605ea042020-01-14 21:36:00 +00004564
Yifan Hongc0f904e2021-03-17 11:25:31 -07004565endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4566
4567# -- Check VINTF compatibility of build.
4568# Skip partial builds; only check full builds. Only check if:
4569# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
4570# - system / vendor VINTF metadata exists
4571# - Building product / system_ext / odm images if board has product / system_ext / odm images
4572ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4573ifeq ($(check_vintf_has_system),true)
4574ifeq ($(check_vintf_has_vendor),true)
4575ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
4576ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
4577ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
4578
4579check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
4580check_vintf_all_deps += $(check_vintf_compatible_log)
4581
4582check_vintf_compatible_args :=
4583check_vintf_compatible_deps := $(check_vintf_common_srcs)
4584
4585ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004586ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004587check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004588check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004589endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004590endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4591
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004592check_vintf_compatible_args += \
4593 --dirmap /system:$(TARGET_OUT) \
4594 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4595 --dirmap /odm:$(TARGET_OUT_ODM) \
4596 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4597 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
4598
4599ifdef PRODUCT_SHIPPING_API_LEVEL
4600check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4601endif # PRODUCT_SHIPPING_API_LEVEL
4602
4603$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4604$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004605# Check ODM SKU=(empty) case when:
4606# - ODM_MANIFEST_FILES is not empty; OR
4607# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004608$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004609 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
4610 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004611 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07004612# Check vendor SKU=(empty) case when:
4613# - DEVICE_MANIFEST_FILE is not empty; OR
4614# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004615$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004616 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4617 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004618 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004619$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08004620 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
4621 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004622 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
4623 @echo -n -e 'Args: \n ' >> $@
4624 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07004625 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4626 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004627 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004628 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
4629 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4630 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004631
4632check_vintf_compatible_log :=
4633check_vintf_compatible_args :=
4634check_vintf_compatible_deps :=
4635
4636endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4637endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4638endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004639endif # check_vintf_has_vendor
4640endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004641endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4642
4643# Add all logs of VINTF checks to dist builds
4644droid_targets: $(check_vintf_all_deps)
4645$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4646
4647# Helper alias to check all VINTF of current build.
4648.PHONY: check-vintf-all
4649check-vintf-all: $(check_vintf_all_deps)
4650 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4651
Yifan Hongaf9b0702020-01-21 12:46:57 -08004652check_vintf_has_vendor :=
4653check_vintf_has_system :=
4654check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004655check_vintf_all_deps :=
4656intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004657endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004658
4659# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004660# Check image sizes <= size of super partition
4661
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004662ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004663
4664ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004665
Tianjie16bcac12021-05-13 15:44:43 -07004666PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
4667
4668# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
4669ifdef BUILDING_SYSTEM_OTHER_IMAGE
4670PARTITIONS_AND_OTHER_IN_SUPER += system_other
4671endif # BUILDING_SYSTEM_OTHER_IMAGE
4672
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004673# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004674# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004675define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004676 mkdir -p $(dir $(1))
4677 rm -f $(1)
4678 $(call dump-super-image-info, $(1))
Tianjie16bcac12021-05-13 15:44:43 -07004679 $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004680 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004681 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004682endef
4683
Yifan Hongd11953c2021-03-11 14:47:48 -08004684check_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 -07004685droid_targets: $(check_all_partition_sizes_log)
4686$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004687
Yifan Hong30910932019-10-25 20:36:55 -07004688$(check_all_partition_sizes_log): \
4689 $(CHECK_PARTITION_SIZES) \
Tianjie16bcac12021-05-13 15:44:43 -07004690 $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
Yifan Hong30910932019-10-25 20:36:55 -07004691 $(call check-all-partition-sizes-target, \
4692 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4693 $@)
4694
4695.PHONY: check-all-partition-sizes
4696check-all-partition-sizes: $(check_all_partition_sizes_log)
4697
4698.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004699check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004700 $(call check-all-partition-sizes-target, \
4701 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004702
Yifan Hong2dae5722018-07-31 12:47:27 -07004703endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004704
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004705endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004706
4707# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004708# bring in the installer image generation defines if necessary
4709ifeq ($(TARGET_USE_DISKINSTALLER),true)
4710include bootable/diskinstaller/config.mk
4711endif
4712
4713# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004714# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004715
Ying Wangbd2d0242015-09-22 11:17:52 -07004716ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004717 build_ota_package := false
4718 build_otatools_package := false
4719else
Tao Bao9be20c72019-04-08 21:11:59 -07004720 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004721 build_ota_package := true
4722 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4723 build_ota_package := false
4724 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004725 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004726 build_ota_package := false
4727 endif
4728 ifeq ($(TARGET_PRODUCT),sdk)
4729 build_ota_package := false
4730 endif
Yifan Hongf32f65c2021-07-14 14:19:12 -07004731 # A target without a kernel may be one of the following:
Yifan Hong8c1e5262021-07-19 16:35:05 +00004732 # - A generic target. In this case, the OTA package usually isn't built.
4733 # PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
4734 # generation.
4735 # - A real device target, with TARGET_NO_KERNEL set to true and
4736 # BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
4737 # an OTA package.
Tao Bao9be20c72019-04-08 21:11:59 -07004738 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4739 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4740 build_ota_package := false
4741 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004742 ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4743 ifeq ($(TARGET_NO_KERNEL),true)
4744 build_ota_package := false
4745 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004746 endif # INSTALLED_BOOTIMAGE_TARGET == ""
Yifan Hongbf777872021-07-19 16:28:49 +00004747 ifeq ($(recovery_fstab),)
4748 build_ota_package := false
4749 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004750 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004751
Tao Bao9be20c72019-04-08 21:11:59 -07004752 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004753 build_otatools_package := true
4754 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4755 build_otatools_package := false
4756 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004757endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004758
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004759ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004760
4761INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004762 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004763 add_img_to_target_files \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004764 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004765 append2simg \
4766 avbtool \
4767 blk_alloc_to_base_fs \
4768 boot_signer \
4769 brillo_update_payload \
4770 brotli \
4771 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004772 build_image \
4773 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004774 build_verity_metadata \
4775 build_verity_tree \
4776 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004777 check_ota_package_signature \
4778 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004779 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004780 checkvintf \
4781 delta_generator \
4782 e2fsck \
4783 e2fsdroid \
4784 fc_sort \
4785 fec \
Woody Line4164192022-03-21 18:29:41 +08004786 fsck.erofs \
Jaegeuk Kim01da65f2021-06-08 18:24:46 -07004787 fsck.f2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07004788 fs_config \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08004789 generate_gki_certificate \
Tao Bao96daeeb2019-05-01 21:17:13 -07004790 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08004791 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07004792 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004793 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004794 imgdiff \
4795 libconscrypt_openjdk_jni \
4796 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004797 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07004798 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07004799 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07004800 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07004801 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004802 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004803 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004804 mkbootfs \
4805 mkbootimg \
4806 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004807 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08004808 mkfs.erofs \
Tao Bao96daeeb2019-05-01 21:17:13 -07004809 mkf2fsuserimg.sh \
4810 mksquashfs \
4811 mksquashfsimage.sh \
4812 mkuserimg_mke2fs \
Kelvin Zhang83eb9f72022-03-15 11:12:50 -07004813 ota_extractor \
Tao Bao8821d642019-08-05 12:05:45 -07004814 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08004815 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08004816 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07004817 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004818 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004819 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004820 sign_apex \
4821 sign_target_files_apks \
Jooyung Han8caba5e2021-10-27 03:58:09 +09004822 sign_virt_apex \
Tao Bao96daeeb2019-05-01 21:17:13 -07004823 signapk \
4824 simg2img \
4825 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07004826 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07004827 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08004828 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07004829 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07004830 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004831 verity_signer \
4832 verity_verifier \
4833 zipalign \
Kelvin Zhangb673bbf2021-08-20 10:09:20 -07004834 zucchini \
Tao Bao5e04c382017-02-22 16:38:19 -08004835
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004836# Additional tools to unpack and repack the apex file.
4837INTERNAL_OTATOOLS_MODULES += \
4838 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00004839 apex_compression_tool \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004840 deapexer \
4841 debugfs_static \
4842 merge_zips \
4843 resize2fs \
4844 soong_zip \
4845
Anton Hansson8dab0a62019-03-28 15:45:40 +00004846ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004847INTERNAL_OTATOOLS_MODULES += \
4848 futility \
4849 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004850endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004851
Tao Bao96daeeb2019-05-01 21:17:13 -07004852INTERNAL_OTATOOLS_FILES := \
4853 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004854
Ying Wang06898662010-06-17 17:52:18 -07004855.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07004856otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07004857
Tao Bao96daeeb2019-05-01 21:17:13 -07004858# For each module, recursively resolve its host shared library dependencies. Then we have a full
4859# list of modules whose installed files need to be packed.
4860INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
4861 $(sort $(INTERNAL_OTATOOLS_MODULES) \
4862 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004863
Tao Bao96daeeb2019-05-01 21:17:13 -07004864INTERNAL_OTATOOLS_PACKAGE_FILES := \
4865 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
4866
4867INTERNAL_OTATOOLS_PACKAGE_FILES += \
4868 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
4869 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07004870
4871ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07004872INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07004873 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004874 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004875endif
4876ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004877INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004878 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4879 -name "atx_metadata.bin"))
4880endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004881ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004882INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004883 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004884endif
4885
Tao Bao96daeeb2019-05-01 21:17:13 -07004886INTERNAL_OTATOOLS_RELEASETOOLS := \
4887 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4888 \( -type f -o -type l \) -print))
4889
4890BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4891$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4892$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4893$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4894$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004895$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004896 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004897 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4898 mkdir -p $(dir $@)
4899 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4900 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004901 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004902 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004903
4904.PHONY: otatools-package
4905otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4906
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004907endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004908
The Android Open Source Project88b60792009-03-03 19:28:42 -08004909# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004910# misc_info.txt
4911
4912INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4913
4914ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4915# default to common dir for device vendor
4916tool_extensions := $(TARGET_DEVICE_DIR)/../common
4917else
4918tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4919endif
4920.KATI_READONLY := tool_extensions
4921
Steve Muckle903a1ca2020-05-07 17:32:10 -07004922# $1: boot image file name
4923define misc_boot_size
4924$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4925endef
4926
Daniel Normane1e48082019-06-27 13:55:23 -07004927$(INSTALLED_MISC_INFO_TARGET):
4928 rm -f $@
4929 $(call pretty,"Target misc_info.txt: $@")
4930 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4931 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4932ifdef BOARD_FLASH_BLOCK_SIZE
4933 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4934endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004935ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4936 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4937 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004938endif
4939ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4940 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004941else
4942 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004943endif
Devin Moore380d9e42021-11-04 19:01:19 +00004944ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
4945 $(hide) echo "init_boot=true" >> $@
4946 $(hide) echo "init_boot_size=$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)" >> $@
4947endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004948ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4949 echo "lz4_ramdisks=true" >> $@
4950endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004951ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4952 echo "vendor_boot=true" >> $@
4953 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4954endif
Daniel Normane1e48082019-06-27 13:55:23 -07004955ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4956 $(hide) echo "no_recovery=true" >> $@
4957endif
4958ifdef BOARD_INCLUDE_RECOVERY_DTBO
4959 $(hide) echo "include_recovery_dtbo=true" >> $@
4960endif
4961ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4962 $(hide) echo "include_recovery_acpio=true" >> $@
4963endif
4964ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4965 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4966endif
4967ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4968 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4969 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4970else
4971 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4972endif
4973 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4974 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
Jacky Liubeb0b692021-12-29 16:29:05 +08004975ifdef PRODUCT_EXTRA_OTA_KEYS
4976 $(hide) echo "extra_ota_keys=$(PRODUCT_EXTRA_OTA_KEYS)" >> $@
4977endif
Daniel Normane1e48082019-06-27 13:55:23 -07004978ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4979 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4980endif
4981 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004982 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004983 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Devin Moore380d9e42021-11-04 19:01:19 +00004984 $(hide) echo 'mkbootimg_init_args=$(BOARD_MKBOOTIMG_INIT_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08004985ifdef BOARD_GKI_SIGNING_KEY_PATH
4986 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
4987 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08004988 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
4989endif
Daniel Normane1e48082019-06-27 13:55:23 -07004990 $(hide) echo "multistage_support=1" >> $@
4991 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4992ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4993 $(hide) echo "build_generic_ota_package=true" >> $@
4994endif
4995ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4996 # OTA scripts are only interested in fingerprint related properties
4997 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4998endif
4999ifneq (,$(filter address, $(SANITIZE_TARGET)))
5000 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
5001 $(hide) echo "userdata_img_with_data=true" >> $@
5002endif
5003ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
5004 $(hide) echo "full_recovery_image=true" >> $@
5005endif
Bill Peckhame868aec2019-09-17 17:06:47 -07005006ifdef BOARD_USES_VENDORIMAGE
5007 $(hide) echo "board_uses_vendorimage=true" >> $@
5008endif
Daniel Normane1e48082019-06-27 13:55:23 -07005009ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08005010ifeq ($(BUILDING_VBMETA_IMAGE),true)
5011 $(hide) echo "avb_building_vbmeta_image=true" >> $@
5012endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005013 $(hide) echo "avb_enable=true" >> $@
5014 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
5015 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
5016 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
5017 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5018ifdef BOARD_AVB_BOOT_KEY_PATH
5019 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
5020 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
5021 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5022endif # BOARD_AVB_BOOT_KEY_PATH
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08005023 $(hide) echo "avb_init_boot_add_hash_footer_args=$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5024ifdef BOARD_AVB_INIT_BOOT_KEY_PATH
5025 $(hide) echo "avb_init_boot_key_path=$(BOARD_AVB_INIT_BOOT_KEY_PATH)" >> $@
5026 $(hide) echo "avb_init_boot_algorithm=$(BOARD_AVB_INIT_BOOT_ALGORITHM)" >> $@
5027 $(hide) echo "avb_init_boot_rollback_index_location=$(BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5028endif # BOARD_AVB_INIT_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07005029 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5030ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
5031 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
5032 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
5033 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5034endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07005035 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
5036ifdef BOARD_AVB_RECOVERY_KEY_PATH
5037 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
5038 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
5039 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
5040endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07005041ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
5042 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
5043 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5044 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
5045 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
5046 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
5047 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
5048 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
5049 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
5050endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07005051ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
5052 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
5053 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
5054 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
5055 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
5056 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
5057endif # BOARD_AVB_VBMETA_SYSTEM
5058ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
5059 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
5060 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
5061 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
5062 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
5063 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
5064endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
5065endif # BOARD_AVB_ENABLE
5066ifdef BOARD_BPT_INPUT_FILES
5067 $(hide) echo "board_bpt_enable=true" >> $@
5068 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
5069 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
5070endif
5071ifdef BOARD_BPT_DISK_SIZE
5072 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
5073endif
5074 $(call generate-userimage-prop-dictionary, $@)
5075ifeq ($(AB_OTA_UPDATER),true)
5076 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
5077 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
5078 $(hide) echo "ab_update=true" >> $@
5079endif
Yifan Hong65afc072020-04-17 10:08:10 -07005080ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
5081 $(hide) echo "allow_non_ab=true" >> $@
5082endif
Daniel Normane1e48082019-06-27 13:55:23 -07005083ifdef BOARD_PREBUILT_DTBOIMAGE
5084 $(hide) echo "has_dtbo=true" >> $@
5085ifeq ($(BOARD_AVB_ENABLE),true)
5086 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
5087 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
5088ifdef BOARD_AVB_DTBO_KEY_PATH
5089 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
5090 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
5091 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
5092endif # BOARD_AVB_DTBO_KEY_PATH
5093endif # BOARD_AVB_ENABLE
5094endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005095ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005096 $(hide) echo "has_pvmfw=true" >> $@
5097ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi592a3ca2021-10-04 11:34:11 +02005098 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@
Andrew Scull9b103e42020-11-29 14:04:28 +00005099 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
5100ifdef BOARD_AVB_PVMFW_KEY_PATH
5101 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
5102 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
5103 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
5104endif # BOARD_AVB_PVMFW_KEY_PATH
5105endif # BOARD_AVB_ENABLE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005106endif # BOARD_USES_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005107 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07005108 @# VINTF checks
5109ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
5110 $(hide) echo "vintf_enforce=true" >> $@
5111endif
5112ifdef ODM_MANIFEST_SKUS
5113 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
5114endif
Yifan Hong28ffd732020-03-13 13:11:10 -07005115ifdef ODM_MANIFEST_FILES
5116 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
5117endif
5118ifdef DEVICE_MANIFEST_SKUS
5119 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
5120endif
5121ifdef DEVICE_MANIFEST_FILE
5122 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
5123endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005124ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
5125 $(hide) echo "bootloader_in_update_package=true" >> $@
5126endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07005127ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
5128 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
5129endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05005130ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5131 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
5132endif
Jose Galmes9c8f6eb2021-07-21 09:34:08 -07005133ifeq ($(BUILDING_WITH_VSDK),true)
5134 $(hide) echo "building_with_vsdk=true" >> $@
5135endif
5136ifeq ($(TARGET_FLATTEN_APEX),false)
5137 $(hide) echo "target_flatten_apex=false" >> $@
5138endif
Daniel Normane1e48082019-06-27 13:55:23 -07005139
Bob Badour70c07dd2022-02-12 15:39:22 -08005140$(call declare-0p-target,$(INSTALLED_MISC_INFO_TARGET))
5141
Daniel Normane1e48082019-06-27 13:55:23 -07005142.PHONY: misc_info
5143misc_info: $(INSTALLED_MISC_INFO_TARGET)
5144
Bill Peckham315b98a2021-06-15 19:35:06 -07005145droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
Daniel Normane1e48082019-06-27 13:55:23 -07005146
5147# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005148# A zip of the directories that map to the target filesystem.
5149# This zip can be used to create an OTA package or filesystem image
5150# as a post-build step.
5151#
5152name := $(TARGET_PRODUCT)
5153ifeq ($(TARGET_BUILD_TYPE),debug)
5154 name := $(name)_debug
5155endif
5156name := $(name)-target_files-$(FILE_NAME_TAG)
5157
5158intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
5159BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
5160$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
5161$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005162 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005163
5164# $(1): Directory to copy
5165# $(2): Location to copy it to
5166# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
5167define package_files-copy-root
5168 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
5169 mkdir -p $(2) && \
5170 $(ACP) -rd $(strip $(1))/* $(2); \
5171 fi
5172endef
5173
Tao Baoa04fca32015-11-30 12:22:24 -08005174built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07005175
5176# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08005177ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07005178built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07005179 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07005180endif
5181
The Android Open Source Project88b60792009-03-03 19:28:42 -08005182$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
5183
Dan Willemsen653bea92017-03-21 15:47:37 -07005184tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07005185$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07005186
Kelvin Zhang6877e812022-01-06 11:12:04 -08005187updaer_dep :=
Sen Jiang4438fd92016-03-07 16:51:01 -08005188ifeq ($(AB_OTA_UPDATER),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005189updater_dep += system/update_engine/update_engine.conf
5190updater_dep += external/zucchini/version_info.h
5191updater_dep += $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so
Yifan Hong65afc072020-04-17 10:08:10 -07005192endif
5193
5194# Build OTA tools if non-A/B is allowed
5195ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005196updater_dep += $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07005197endif
Yifan Hong65afc072020-04-17 10:08:10 -07005198
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09005199$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07005200
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005201# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07005202# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005203ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5204$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07005205else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
5206$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005207else
5208$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
5209endif
5210
Dan Willemsen653bea92017-03-21 15:47:37 -07005211ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07005212 ifdef OSRELEASED_DIRECTORY
5213 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
5214 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
5215 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
5216 endif
Tao Baoa835f382019-07-18 15:55:30 -07005217
5218 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
5219 # additionally include radio or bootloader partitions).
5220 ifeq ($(AB_OTA_PARTITIONS),)
5221 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
5222 endif
5223endif
5224
5225ifneq ($(AB_OTA_PARTITIONS),)
5226 ifneq ($(AB_OTA_UPDATER),true)
5227 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
5228 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07005229endif
5230
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005231# Run fs_config while creating the target files package
5232# $1: root directory
5233# $2: add prefix
5234define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08005235(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 -08005236endef
5237
Yifan Hong60bfcc42019-11-01 11:39:45 -07005238define filter-out-missing-vendor
5239$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
5240endef
Petri Gynther09865a42021-03-10 18:23:39 -08005241define filter-out-missing-vendor_dlkm
5242$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
5243endef
5244define filter-out-missing-odm
5245$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
5246endef
5247define filter-out-missing-odm_dlkm
5248$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
5249endef
Ramji Jiyani13a41372022-01-27 07:05:08 +00005250define filter-out-missing-system_dlkm
5251$(if $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(1),$(filter-out system_dlkm,$(1)))
5252endef
5253# Filter out vendor,vendor_dlkm,odm,odm_dlkm,system_dlkm from the list for AOSP targets.
Petri Gynther09865a42021-03-10 18:23:39 -08005254# $(1): list
5255define filter-out-missing-partitions
5256$(call filter-out-missing-vendor,\
5257 $(call filter-out-missing-vendor_dlkm,\
5258 $(call filter-out-missing-odm,\
Ramji Jiyani13a41372022-01-27 07:05:08 +00005259 $(call filter-out-missing-odm_dlkm,\
5260 $(call filter-out-missing-system_dlkm,$(1))))))
Petri Gynther09865a42021-03-10 18:23:39 -08005261endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07005262
5263# Information related to dynamic partitions and virtual A/B. This information
5264# is needed for building the super image (see dump-super-image-info) and
5265# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08005266# $(1): file
5267define dump-dynamic-partitions-info
5268 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
5269 echo "use_dynamic_partitions=true" >> $(1))
5270 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
5271 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08005272 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
5273 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
5274 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00005275 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
5276 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08005277 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
5278 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005279 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
5280 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5281 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
5282 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5283 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
5284 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005285 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005286 $(if $(BOARD_SUPER_PARTITION_GROUPS),
5287 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
5288 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
5289 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
5290 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005291 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 -07005292 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
5293 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07005294 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
5295 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005296 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
5297 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005298 $(if $(BOARD_SUPER_PARTITION_SIZE), \
5299 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
5300 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
5301 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
5302 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
5303 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
5304 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
5305 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005306 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
5307 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05005308 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
5309 echo "virtual_ab_compression=true" >> $(1))
Kelvin Zhangfa91e982022-02-09 11:19:16 -08005310# This value controls the compression algorithm used for VABC
5311# valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
5312# e.g. "none", "gz", "brotli"
5313 $(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD), \
5314 echo "virtual_ab_compression_method=$(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005315 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
5316 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005317endef
5318
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005319# By conditionally including the dependency of the target files package on the
5320# full system image deps, we speed up builds that do not build the system
5321# image.
5322ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005323 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005324else
5325 # releasetools may need the system build.prop even when building a
5326 # system-image-less product.
5327 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BUILD_PROP_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005328endif
5329
5330ifdef BUILDING_USERDATA_IMAGE
5331 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
5332endif
5333
5334ifdef BUILDING_SYSTEM_OTHER_IMAGE
5335 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
5336endif
5337
5338ifdef BUILDING_VENDOR_BOOT_IMAGE
5339 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005340 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Devin Moore55af5062021-06-09 10:44:44 -07005341 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Colin Crosse6431202021-02-24 11:44:55 -08005342 # The vendor ramdisk may be built from the recovery ramdisk.
5343 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
5344 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
5345 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07005346endif
5347
5348ifdef BUILDING_RECOVERY_IMAGE
5349 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08005350 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07005351 # commands in build-recoveryimage-target, which would touch the files under
5352 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
5353 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5354 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5355 else
5356 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
5357 endif
5358 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
5359endif
5360
5361# Conditionally depend on the image files if the image is being built so the
5362# target-files.zip rule doesn't wait on the image creation rule, or the image
5363# if it is coming from a prebuilt.
5364
5365ifdef BUILDING_VENDOR_IMAGE
5366 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
5367else ifdef BOARD_PREBUILT_VENDORIMAGE
5368 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
5369endif
5370
5371ifdef BUILDING_PRODUCT_IMAGE
5372 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
5373else ifdef BOARD_PREBUILT_PRODUCTIMAGE
5374 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
5375endif
5376
5377ifdef BUILDING_SYSTEM_EXT_IMAGE
5378 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
5379else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
5380 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
5381endif
5382
Devin Moore380d9e42021-11-04 19:01:19 +00005383ifneq (,$(BUILDING_BOOT_IMAGE)$(BUILDING_INIT_BOOT_IMAGE))
Colin Cross43f2eb22020-08-26 18:41:29 -07005384 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Devin Moore380d9e42021-11-04 19:01:19 +00005385endif # BUILDING_BOOT_IMAGE != "" || BUILDING_INIT_BOOT_IMAGE != ""
5386
Yifan Hong49968aa2020-11-09 11:52:52 -08005387ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07005388 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5389endif
5390
5391ifdef BUILDING_ODM_IMAGE
5392 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
5393else ifdef BOARD_PREBUILT_ODMIMAGE
5394 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
5395endif
5396
5397ifdef BUILDING_VENDOR_DLKM_IMAGE
5398 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005399else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005400 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
5401endif
5402
5403ifdef BUILDING_ODM_DLKM_IMAGE
5404 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005405else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005406 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005407endif
5408
Ramji Jiyani13a41372022-01-27 07:05:08 +00005409ifdef BUILDING_SYSTEM_DLKM_IMAGE
5410 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
5411else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5412 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
5413endif
5414
Isaac Chen9e09d472019-07-05 17:30:41 +08005415ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07005416 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
5417 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08005418endif
5419
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005420ifdef BOARD_PREBUILT_BOOTLOADER
5421$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005422droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005423endif
5424
The Android Open Source Project88b60792009-03-03 19:28:42 -08005425# Depending on the various images guarantees that the underlying
5426# directories are up-to-date.
5427$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005428 $(INSTALLED_RADIOIMAGE_TARGET) \
5429 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005430 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005431 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00005432 $(INSTALLED_PVMFWIMAGE_TARGET) \
Andrew Scullbbc930b2022-02-17 22:34:27 +00005433 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07005434 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005435 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
5436 $(INSTALLED_KERNEL_TARGET) \
Enrico Granatab582e0f2020-10-14 15:17:20 -06005437 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005438 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005439 $(INSTALLED_2NDBOOTLOADER_TARGET) \
5440 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08005441 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005442 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005443 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5444 $(PRODUCT_VENDOR_BASE_FS_PATH) \
5445 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09005446 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005447 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07005448 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07005449 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00005450 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00005451 $(LPMAKE) \
5452 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07005453 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005454 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005455 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005456 $(SOONG_ZIP) \
5457 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07005458 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07005459 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005460 $(BUILT_KERNEL_CONFIGS_FILE) \
5461 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005462 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005463 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005464 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005465 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07005466ifneq (,$(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 -08005467 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005468 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005469# Exclude recovery files in the default vendor ramdisk if including a standalone
5470# recovery ramdisk in vendor_boot.
5471ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005472 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005473 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005474endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005475ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005476ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07005477 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07005478else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07005479 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
5480endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005481endif
Yifan Hong78860162020-10-28 14:15:21 -07005482ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005483ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005484 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005485endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005486ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08005487ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07005488 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08005489else
Steve Mucklee1b10862019-07-10 10:49:37 -07005490 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005491endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005492endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005493ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07005494 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005495endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005496ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005497 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005498endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005499ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07005500ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07005501 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07005502endif # INTERNAL_KERNEL_CMDLINE != ""
5503endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07005504ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005505 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005506endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005507ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005508 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005509endif
Yifan Hong3941a872020-10-28 16:33:06 -07005510endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005511endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08005512 @# Components of the boot image
5513 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07005514 $(hide) mkdir -p $(zip_root)/ROOT
5515 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005516 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08005517 @# If we are using recovery as boot, this is already done when processing recovery.
5518ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07005519ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005520 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005521 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07005522endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005523ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005524 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08005525endif
Yifan Hong46aff092020-10-28 13:50:47 -07005526ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07005527 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07005528else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07005529 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08005530ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005531 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005532endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005533ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005534 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005535endif
Doug Zongker38a649f2009-06-17 09:07:09 -07005536ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005537 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005538endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005539ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005540 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005541endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005542endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07005543endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07005544 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
5545 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07005546 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07005547ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5548 mkdir -p $(zip_root)/VENDOR_BOOT
5549 $(call package_files-copy-root, \
5550 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
5551ifdef INSTALLED_DTBIMAGE_TARGET
5552 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
5553endif
Devin Moore50509012021-01-13 10:45:04 -08005554ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
5555 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
5556endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005557ifdef BOARD_KERNEL_BASE
5558 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
5559endif
5560ifdef BOARD_KERNEL_PAGESIZE
5561 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
5562endif
5563 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005564ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
5565 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
5566 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005567 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
5568 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
5569 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
5570 $(if $(prebuilt_ramdisk), \
5571 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
5572 $(call package_files-copy-root, \
5573 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
5574 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
5575 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005576endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07005577endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08005578ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005579 @# Contents of the system image
5580 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005581 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005582else ifdef INSTALLED_BUILD_PROP_TARGET
5583 @# Copy the system build.prop even if not building a system image
5584 @# because add_img_to_target_files may need it to build other partition
5585 @# images.
5586 $(hide) mkdir -p "$(zip_root)/SYSTEM"
5587 $(hide) cp "$(INSTALLED_BUILD_PROP_TARGET)" "$(patsubst $(TARGET_OUT)/%,$(zip_root)/SYSTEM/%,$(INSTALLED_BUILD_PROP_TARGET))"
Dan Willemsen67495202019-01-16 12:42:05 -08005588endif
5589ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005590 @# Contents of the data image
5591 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005592 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08005593endif
5594ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07005595 @# Contents of the vendor image
5596 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005597 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07005598endif
Dan Willemsen67495202019-01-16 12:42:05 -08005599ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005600 @# Contents of the product image
5601 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005602 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005603endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005604ifdef BUILDING_SYSTEM_EXT_IMAGE
5605 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01005606 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09005607 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01005608endif
Dan Willemsen67495202019-01-16 12:42:05 -08005609ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005610 @# Contents of the odm image
5611 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005612 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005613endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005614ifdef BUILDING_VENDOR_DLKM_IMAGE
5615 @# Contents of the vendor_dlkm image
5616 $(hide) $(call package_files-copy-root, \
5617 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
5618endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005619ifdef BUILDING_ODM_DLKM_IMAGE
5620 @# Contents of the odm_dlkm image
5621 $(hide) $(call package_files-copy-root, \
5622 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
5623endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005624ifdef BUILDING_SYSTEM_DLKM_IMAGE
5625 @# Contents of the system_dlkm image
5626 $(hide) $(call package_files-copy-root, \
5627 $(TARGET_OUT_SYSTEM_DLKM),$(zip_root)/SYSTEM_DLKM)
5628endif
Dan Willemsen67495202019-01-16 12:42:05 -08005629ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07005630 @# Contents of the system_other image
5631 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005632 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07005633endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005634 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07005635 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07005636 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granatab582e0f2020-10-14 15:17:20 -06005637ifdef BUILDING_RAMDISK_IMAGE
5638ifeq (true,$(BOARD_IMG_USE_RAMDISK))
5639 @# Contents of the ramdisk image
5640 $(hide) mkdir -p $(zip_root)/IMAGES
5641 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
5642endif
5643endif
Yifan Hong65afc072020-04-17 10:08:10 -07005644ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08005645ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07005646 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07005647 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07005648endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08005649endif
Doug Zongker8678df42009-06-15 14:30:14 -07005650 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08005651 @# build them.
5652 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07005653 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005654 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005655ifneq ($(tool_extension),)
5656 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
5657endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07005658 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005659 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07005660 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00005661ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
5662 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5663 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005664endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005665ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
5666 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
5667 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005668endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005669ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
5670 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
5671 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005672endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005673ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
5674 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
5675 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01005676endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005677ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
5678 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
5679 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005680endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005681ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
5682 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
5683 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
5684endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005685ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
5686 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
5687 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
5688endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005689ifneq ($(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH),)
5690 $(hide) cp $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
5691 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH))
5692endif
Yifan Hong65afc072020-04-17 10:08:10 -07005693ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07005694ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07005695 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07005696 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07005697endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08005698endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005699ifeq ($(AB_OTA_UPDATER),true)
5700 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07005701 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Kelvin Zhangc06f0622021-11-30 12:38:39 -08005702 $(hide) cp $(TOPDIR)external/zucchini/version_info.h $(zip_root)/META/zucchini_config.txt
Kelvin Zhang6877e812022-01-06 11:12:04 -08005703 $(hide) cp $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so $(zip_root)/META/liblz4.so
Cole Faust90099992022-02-17 11:35:27 -08005704 $(hide) for part in $(sort $(AB_OTA_PARTITIONS)); do \
Alex Deymo8925d332015-10-01 17:38:09 -07005705 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
5706 done
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005707 $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
Sen Jiang8f22e2a2015-11-12 13:53:25 -08005708 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
5709 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005710ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07005711 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
5712 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
5713 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005714endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005715endif
Steve Fungdfbab492015-09-24 18:12:33 -07005716ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07005717 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07005718 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07005719endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07005720ifdef BOARD_PREBUILT_VENDORIMAGE
5721 $(hide) mkdir -p $(zip_root)/IMAGES
5722 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
5723endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005724ifdef BOARD_PREBUILT_PRODUCTIMAGE
5725 $(hide) mkdir -p $(zip_root)/IMAGES
5726 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
5727endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005728ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01005729 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09005730 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01005731endif
Devin Moore380d9e42021-11-04 19:01:19 +00005732ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
Devin Moorecda41f02022-01-05 00:08:39 +00005733 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5734 $(hide) cp $(INSTALLED_INIT_BOOT_IMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Devin Moore380d9e42021-11-04 19:01:19 +00005735endif
Ramji Jiyani034e7772022-01-24 04:00:29 +00005736
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005737ifndef BOARD_PREBUILT_BOOTIMAGE
Yi-Yo Chiang81939002022-01-08 23:46:40 +08005738ifneq (,$(strip $(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES))))
Yifan Hong49968aa2020-11-09 11:52:52 -08005739ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07005740 $(hide) mkdir -p $(zip_root)/IMAGES
5741 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08005742endif # INSTALLED_BOOTIMAGE_TARGET
5743endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005744else # BOARD_PREBUILT_BOOTIMAGE is defined
5745 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5746 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5747endif # BOARD_PREBUILT_BOOTIMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005748ifdef BOARD_PREBUILT_ODMIMAGE
5749 $(hide) mkdir -p $(zip_root)/IMAGES
5750 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
5751endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07005752ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07005753 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07005754 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5755endif
5756ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
5757 $(hide) mkdir -p $(zip_root)/IMAGES
5758 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07005759endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005760ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5761 $(hide) mkdir -p $(zip_root)/IMAGES
5762 $(hide) cp $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5763endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07005764ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07005765 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5766 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08005767endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01005768ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005769 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5770 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Andrew Scullbbc930b2022-02-17 22:34:27 +00005771 $(hide) cp $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) $(zip_root)/PREBUILT_IMAGES/
Pierre-Clément Tosid8248af2021-10-07 12:18:17 +02005772endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005773ifdef BOARD_PREBUILT_BOOTLOADER
5774 $(hide) mkdir -p $(zip_root)/IMAGES
5775 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
5776endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07005777ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
5778 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5779 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5780 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
5781endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07005782 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
5783 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
5784 @# INSTALLED_RADIOIMAGE_TARGET.
5785 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
5786 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005787 @# Run fs_config on all the system, vendor, boot ramdisk,
5788 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08005789ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005790 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08005791endif
5792ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005793 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
5794endif
Dan Willemsen67495202019-01-16 12:42:05 -08005795ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005796 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
5797endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005798ifdef BUILDING_SYSTEM_EXT_IMAGE
5799 $(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 +01005800endif
Dan Willemsen67495202019-01-16 12:42:05 -08005801ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005802 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
5803endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005804ifdef BUILDING_VENDOR_DLKM_IMAGE
5805 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
5806endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005807ifdef BUILDING_ODM_DLKM_IMAGE
5808 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
5809endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005810ifdef BUILDING_SYSTEM_DLKM_IMAGE
5811 $(hide) $(call fs_config,$(zip_root)/SYSTEM_DLKM,system_dlkm/) > $(zip_root)/META/system_dlkm_filesystem_config.txt
5812endif
Tom Cherryd14b8952018-08-09 14:26:00 -07005813 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005814 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005815ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07005816 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005817 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005818endif
Devin Moore380d9e42021-11-04 19:01:19 +00005819ifdef BUILDING_INIT_BOOT_IMAGE
5820 $(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK)
5821 $(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt
5822ifdef BOARD_KERNEL_PAGESIZE
5823 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize
5824endif # BOARD_KERNEL_PAGESIZE
5825endif # BUILDING_INIT_BOOT_IMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07005826ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5827 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
5828endif
Tom Cherry2929cad2018-09-20 11:04:37 -07005829ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
5830 @# 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 -08005831 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
5832endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005833ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5834 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
5835endif
Dan Willemsen67495202019-01-16 12:42:05 -08005836ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005837 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
5838endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07005839 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07005840ifdef BUILT_KERNEL_CONFIGS_FILE
5841 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
5842endif
5843ifdef BUILT_KERNEL_VERSION_FILE
5844 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
5845endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07005846 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
5847ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5848 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
5849endif
Tao Baocbd6d492019-10-07 22:46:02 -07005850 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
5851 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08005852ifeq ($(BUILD_QEMU_IMAGES),true)
5853 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
5854 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
5855endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08005856 @# Zip everything up, preserving symlinks and placing META/ files first to
5857 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005858 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07005859 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08005860 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07005861
Ying Wanga0febe52013-03-20 11:02:05 -07005862.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08005863target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
5864
Ying Wang4709d7c2014-04-14 17:25:43 -07005865$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07005866
Dan Albert4d323332016-10-14 13:23:06 -07005867# -----------------------------------------------------------------
5868# NDK Sysroot Package
5869NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07005870$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07005871 @echo Package NDK sysroot...
5872 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
5873
Dan Willemsen616e7fd2021-09-16 14:50:08 -07005874ifeq ($(HOST_OS),linux)
Dan Albert4d323332016-10-14 13:23:06 -07005875$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07005876endif
Dan Albert4d323332016-10-14 13:23:06 -07005877
Ying Wang09c4b682015-08-11 11:24:19 -07005878ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07005879# -----------------------------------------------------------------
5880# OTA update package
5881
Yifan Hong50e79542018-11-08 17:44:12 -08005882# $(1): output file
5883# $(2): additional args
5884define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07005885PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07005886 $(OTA_FROM_TARGET_FILES) \
5887 --verbose \
5888 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
5889 --path $(HOST_OUT) \
5890 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
5891 $(2) \
5892 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08005893endef
5894
Tianjie6bd3b1a2020-10-16 18:53:47 -07005895product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07005896ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005897 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07005898endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07005899name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07005900
5901INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08005902INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
5903
Doug Zongker8678df42009-06-15 14:30:14 -07005904$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08005905$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07005906$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07005907 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08005908 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07005909
5910.PHONY: otapackage
5911otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
5912
Tao Bao519d1822018-12-27 12:47:23 -08005913ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005914name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08005915
5916INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08005917$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07005918$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
5919 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07005920 $(OTA_FROM_TARGET_FILES) \
5921 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08005922 @echo "Package OTA (retrofit dynamic partitions): $@"
5923 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
5924
5925.PHONY: otardppackage
5926
5927otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
5928
Tao Bao519d1822018-12-27 12:47:23 -08005929endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08005930
Tianjie6bd3b1a2020-10-16 18:53:47 -07005931ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5932name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
5933
5934INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5935$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
5936$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
5937 @echo "Package partial OTA: $@"
5938 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
5939
5940.PHONY: partialotapackage
5941partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
5942
5943endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
5944
Ying Wang09c4b682015-08-11 11:24:19 -07005945endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07005946
Ying Wang09a00a62010-10-20 14:01:09 -07005947# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01005948# A zip of the appcompat directory containing logs
5949APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
5950# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005951ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07005952$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
5953 $(INTERNAL_RAMDISK_FILES) \
5954 $(INTERNAL_USERDATAIMAGE_FILES) \
5955 $(INTERNAL_VENDORIMAGE_FILES) \
5956 $(INTERNAL_PRODUCTIMAGE_FILES) \
5957 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01005958endif
5959$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
5960$(APPCOMPAT_ZIP): $(SOONG_ZIP)
5961 @echo "appcompat logs: $@"
5962 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5963 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
5964 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
5965 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
5966
Jeongik Cha2522c362021-04-27 23:52:15 +09005967# The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
5968ifeq ($(BUILD_OS),linux)
Jeongik Cha62519de2021-05-13 13:29:39 +09005969ifneq ($(DEX2OAT),)
Jeongik Cha2522c362021-04-27 23:52:15 +09005970dexpreopt_tools_deps := $(DEXPREOPT_GEN_DEPS) $(DEXPREOPT_GEN) $(AAPT2)
Eric Miao1d0fd2c2021-11-08 19:34:50 +00005971dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/dexdump
5972dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/oatdump
Jeongik Cha2522c362021-04-27 23:52:15 +09005973DEXPREOPT_TOOLS_ZIP := $(PRODUCT_OUT)/dexpreopt_tools.zip
5974$(DEXPREOPT_TOOLS_ZIP): $(dexpreopt_tools_deps)
5975$(DEXPREOPT_TOOLS_ZIP): PRIVATE_DEXPREOPT_TOOLS_DEPS := $(dexpreopt_tools_deps)
5976$(DEXPREOPT_TOOLS_ZIP): $(SOONG_ZIP)
5977 $(hide) mkdir -p $(dir $@)
5978 $(hide) $(SOONG_ZIP) -d -o $@ -j $(addprefix -f ,$(PRIVATE_DEXPREOPT_TOOLS_DEPS)) -f $$(realpath $(DEX2OAT))
Jeongik Cha62519de2021-05-13 13:29:39 +09005979endif # DEX2OAT is set
5980endif # BUILD_OS == linux
Jeongik Cha2522c362021-04-27 23:52:15 +09005981
Jeongik Chaa8056d62021-04-07 23:57:16 +09005982DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
Jeongik Chab26bf582021-06-08 11:31:31 +09005983
5984$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
5985 $(INSTALLED_VENDORIMAGE_TARGET) \
5986 $(INSTALLED_ODMIMAGE_TARGET) \
5987 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5988
5989ifeq (,$(TARGET_BUILD_UNBUNDLED))
5990$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
5991 $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
5992
5993endif
Jeongik Chaa8056d62021-04-07 23:57:16 +09005994
5995$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
5996 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Chab26bf582021-06-08 11:31:31 +09005997
5998ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jeongik Cha35bf6b02021-04-23 19:09:04 +09005999ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006000 $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006001endif
6002ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006003 $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006004endif
Jeongik Chab26bf582021-06-08 11:31:31 +09006005endif #!TARGET_BUILD_UNBUNDLED
Jeongik Chaa8056d62021-04-07 23:57:16 +09006006 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
6007
Jeongik Chab26bf582021-06-08 11:31:31 +09006008.PHONY: dexpreopt_config_zip
6009dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
6010
Dario Frenid1011272018-07-23 20:20:15 +01006011# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006012# A zip of the symbols directory. Keep the full paths to make it
6013# more obvious where these files came from.
6014#
6015name := $(TARGET_PRODUCT)
6016ifeq ($(TARGET_BUILD_TYPE),debug)
6017 name := $(name)_debug
6018endif
6019name := $(name)-symbols-$(FILE_NAME_TAG)
6020
6021SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07006022# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006023ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006024$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07006025endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006026$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
6027$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006028 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006029 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6030 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09006031 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07006032 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07006033# -----------------------------------------------------------------
6034# A zip of the coverage directory.
6035#
Oliver Nguyene91ab232019-04-30 15:14:44 -07006036name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07006037ifeq ($(TARGET_BUILD_TYPE),debug)
6038name := $(name)_debug
6039endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07006040COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006041ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006042$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07006043endif
6044$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
6045$(COVERAGE_ZIP): $(SOONG_ZIP)
6046 @echo "Package coverage: $@"
6047 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6048 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
6049 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
6050 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006051
Bob Badourf2529722022-03-18 11:34:03 -07006052$(call declare-1p-container,$(COVERAGE_ZIP),)
6053$(call declare-container-license-deps,$(COVERAGE_ZIP),$(INTERNAL_ALLIMAGE_FILES),$(PRODUCT_OUT)/:/)
6054
6055SYSTEM_NOTICE_DEPS += $(COVERAGE_ZIP)
6056
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006057#------------------------------------------------------------------
6058# Export the LLVM profile data tool and dependencies for Clang coverage processing
6059#
6060ifeq (true,$(CLANG_COVERAGE))
6061 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006062 LLVM_COV := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006063 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006064 # Use llvm-profdata.zip for backwards compatibility with tradefed code.
6065 LLVM_COVERAGE_TOOLS_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006066
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006067 $(LLVM_COVERAGE_TOOLS_ZIP): $(SOONG_ZIP)
6068 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX) -f $(LLVM_COV)
6069
6070 $(call dist-for-goals,droidcore-unbundled apps_only,$(LLVM_COVERAGE_TOOLS_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006071endif
6072
The Android Open Source Project88b60792009-03-03 19:28:42 -08006073# -----------------------------------------------------------------
6074# A zip of the Android Apps. Not keeping full path so that we don't
6075# include product names when distributing
6076#
6077name := $(TARGET_PRODUCT)
6078ifeq ($(TARGET_BUILD_TYPE),debug)
6079 name := $(name)_debug
6080endif
6081name := $(name)-apps-$(FILE_NAME_TAG)
6082
6083APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07006084$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006085 @echo "Package apps: $@"
6086 $(hide) rm -rf $@
6087 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006088 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
6089 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00006090 echo "No apps to zip up. Generating empty apps archive." ; \
6091 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006092 else \
Anton Hansson6d814982018-11-26 18:12:05 +00006093 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006094 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07006095
Ying Wangbc415dd2012-08-15 12:22:44 -07006096ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07006097#------------------------------------------------------------------
6098# An archive of classes for use in generating code-coverage reports
6099# These are the uninstrumented versions of any classes that were
6100# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07006101# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006102
Colin Crossa6bc3a82017-09-27 14:28:41 -07006103JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Colin Cross330b1fe2021-04-06 18:04:06 -07006104$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
6105$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
6106$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
6107$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006108$(JACOCO_REPORT_CLASSES_ALL) :
6109 @echo "Collecting uninstrumented classes"
Colin Cross330b1fe2021-04-06 18:04:06 -07006110 mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
6111 $(SOONG_ZIP) -o $@ -L 0 \
6112 -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
6113 -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
6114 -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
6115 -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006116
Jiyong Park3c875602021-01-21 12:46:56 +09006117ifeq (,$(TARGET_BUILD_UNBUNDLED))
6118 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
6119endif
Ying Wangbc415dd2012-08-15 12:22:44 -07006120endif # EMMA_INSTRUMENT=true
6121
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006122
Ying Wangae9115a2013-08-22 20:52:47 -07006123#------------------------------------------------------------------
6124# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07006125#
Ying Wangc62c92c2013-08-28 18:38:25 -07006126PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07006127# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006128ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006129$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07006130endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006131$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
Colin Cross114e8df2019-09-05 17:19:35 -07006132$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07006133 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross330b1fe2021-04-06 18:04:06 -07006134 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR)
6135 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -P out/target/common/obj -D $(PRIVATE_PACKAGING_DIR)
Ying Wangae9115a2013-08-22 20:52:47 -07006136
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006137#------------------------------------------------------------------
6138# A zip of Proguard usage files.
6139#
6140PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
6141# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
6142ifeq (,$(TARGET_BUILD_UNBUNDLED))
6143$(PROGUARD_USAGE_ZIP): \
6144 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6145 $(INSTALLED_RAMDISK_TARGET) \
6146 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00006147 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006148 $(INSTALLED_USERDATAIMAGE_TARGET) \
6149 $(INSTALLED_VENDORIMAGE_TARGET) \
6150 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6151 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6152 $(INSTALLED_ODMIMAGE_TARGET) \
6153 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6154 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00006155 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006156 $(updater_dep)
6157endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006158$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
6159$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006160$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
6161 @echo "Packaging Proguard usage files."
Colin Cross330b1fe2021-04-06 18:04:06 -07006162 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6163 find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006164 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07006165
6166ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6167
6168# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
6169# $(1): output file
6170define dump-super-image-info
6171 $(call dump-dynamic-partitions-info,$(1))
6172 $(if $(filter true,$(AB_OTA_UPDATER)), \
6173 echo "ab_update=true" >> $(1))
6174endef
6175
6176endif # PRODUCT_USE_DYNAMIC_PARTITIONS
6177
The Android Open Source Project88b60792009-03-03 19:28:42 -08006178# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07006179# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08006180
6181ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6182
6183# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
6184ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6185
6186ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07006187
6188# For real devices and for dist builds, build super image from target files to an intermediate directory.
6189INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
6190$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
6191$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
6192 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08006193 PATH=$(dir $(LPMAKE)):$$PATH \
6194 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07006195
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006196# Skip packing it in dist package because it is in update package.
6197ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07006198$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006199endif
Yifan Hongacd862a2019-04-16 15:44:30 -07006200
6201.PHONY: superimage_dist
6202superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07006203
6204endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07006205endif # BOARD_SUPER_PARTITION_SIZE != ""
6206endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08006207
Yifan Hongacd862a2019-04-16 15:44:30 -07006208# -----------------------------------------------------------------
6209# super partition image for development
6210
6211ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6212ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6213ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
6214
6215# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
6216# $(1): built image path
6217# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
6218define build-superimage-target
6219 mkdir -p $(dir $(2))
6220 rm -rf $(2)
6221 $(call dump-super-image-info,$(2))
6222 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
6223 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09006224 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
6225 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07006226 mkdir -p $(dir $(1))
6227 PATH=$(dir $(LPMAKE)):$$PATH \
6228 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
6229endef
6230
6231INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
6232INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
6233 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
6234
changho.shina8f9f112019-10-15 13:26:19 +09006235ifdef BUILDING_SYSTEM_OTHER_IMAGE
6236ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
6237INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
6238endif
6239endif
6240
Yifan Hongacd862a2019-04-16 15:44:30 -07006241# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
6242# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
6243# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
6244# virtual devices.
6245ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
6246$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6247 $(call pretty,"Target super fs image for debug: $@")
6248 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08006249 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006250
Bill Peckham315b98a2021-06-15 19:35:06 -07006251droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
Yifan Hongacd862a2019-04-16 15:44:30 -07006252
6253# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
6254.PHONY: superimage
6255superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08006256
6257$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006258endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
6259
6260# Build $(PRODUCT_OUT)/super.img without dependencies.
6261.PHONY: superimage-nodeps supernod
6262superimage-nodeps supernod: intermediates :=
6263superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6264 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
6265 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
6266 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
6267
6268endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
6269endif # BOARD_SUPER_PARTITION_SIZE != ""
6270endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
6271
6272# -----------------------------------------------------------------
6273# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00006274ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006275
Yifan Hong8b79d162018-11-29 12:32:00 -08006276INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
6277$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
6278$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
6279 $(call pretty,"Target empty super fs image: $@")
6280 mkdir -p $(intermediates)
6281 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07006282 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08006283 PATH=$(dir $(LPMAKE)):$$PATH \
6284 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08006285
6286$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6287
Bob Badour70c07dd2022-02-12 15:39:22 -08006288$(call declare-0p-target,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6289
Yo Chiange86bab42021-03-25 10:12:28 +00006290endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006291
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006292
6293# -----------------------------------------------------------------
6294# The update package
6295
6296name := $(TARGET_PRODUCT)
6297ifeq ($(TARGET_BUILD_TYPE),debug)
6298 name := $(name)_debug
6299endif
6300name := $(name)-img-$(FILE_NAME_TAG)
6301
6302INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6303
Tao Bao57f8ed62019-08-14 23:08:18 -07006304$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
6305 $(call pretty,"Package: $@")
6306 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
6307 $(IMG_FROM_TARGET_FILES) \
6308 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
6309 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006310
6311.PHONY: updatepackage
6312updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07006313$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006314
6315
Yifan Hong2b891ac2018-11-29 12:06:31 -08006316# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006317# dalvik something
6318.PHONY: dalvikfiles
6319dalvikfiles: $(INTERNAL_DALVIK_MODULES)
6320
Bo Huf0d50bb2017-08-01 19:02:09 +00006321ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00006322MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08006323MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00006324SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08006325
6326ifdef INSTALLED_SYSTEMIMAGE_TARGET
6327INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08006328INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
6329$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
6330 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
6331 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08006332$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08006333 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
6334 @echo Create system-qemu.img now
6335 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08006336 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00006337
6338systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006339droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08006340endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006341ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00006342INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006343$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00006344 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006345 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00006346
6347vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006348droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
Bo Huf0d50bb2017-08-01 19:02:09 +00006349endif
bohu8fd437c2020-03-30 20:16:13 -07006350
6351ifdef INSTALLED_RAMDISK_TARGET
6352ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
6353ifdef INTERNAL_VENDOR_RAMDISK_TARGET
6354INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
6355$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
6356 @echo Create ramdisk-qemu.img
6357 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
6358
Bill Peckham315b98a2021-06-15 19:35:06 -07006359droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
bohu8fd437c2020-03-30 20:16:13 -07006360endif
6361endif
6362endif
6363
Anton Hansson32c76fe2018-12-13 14:34:18 +00006364ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006365INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006366$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006367 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006368 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006369
6370productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006371droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006372endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006373ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
6374INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
6375$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
6376 @echo Create system_ext-qemu.img
6377 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01006378
Justin Yun6151e3f2019-06-25 15:58:13 +09006379systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006380droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01006381endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006382ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006383INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
6384$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6385 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006386 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006387
6388odmimage: $(INSTALLED_QEMU_ODMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006389droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006390endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006391
Yifan Hongcfb917a2020-05-07 14:58:20 -07006392ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
6393INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
6394$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6395 @echo Create vendor_dlkm-qemu.img
6396 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
6397
6398vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006399droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07006400endif
6401
Yifan Hongf496f1b2020-07-15 16:52:59 -07006402ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
6403INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
6404$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6405 @echo Create odm_dlkm-qemu.img
6406 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
6407
6408odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006409droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07006410endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006411
Ramji Jiyani13a41372022-01-27 07:05:08 +00006412ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
6413INSTALLED_QEMU_SYSTEM_DLKMIMAGE := $(PRODUCT_OUT)/system_dlkm-qemu.img
6414$(INSTALLED_QEMU_SYSTEM_DLKMIMAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6415 @echo Create system_dlkm-qemu.img
6416 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET))
6417
6418system_dlkmimage: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6419droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6420endif
6421
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006422QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08006423$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
6424 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006425 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08006426 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
6427 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006428
6429systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
Bill Peckham315b98a2021-06-15 19:35:06 -07006430droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08006431
Bo Huf0d50bb2017-08-01 19:02:09 +00006432endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006433# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006434# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07006435ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006436INTERNAL_EMULATOR_PACKAGE_FILES += \
6437 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08006438 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006439 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07006440 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6441 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006442
6443name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
6444
6445INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6446
Ying Wang5d887702015-11-04 10:06:25 -08006447$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006448 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07006449 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006450
Ying Wang7d8c5352012-07-26 10:15:21 -07006451endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08006452
The Android Open Source Project88b60792009-03-03 19:28:42 -08006453
6454# -----------------------------------------------------------------
6455# The SDK
6456
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006457ifneq ($(filter sdk,$(MAKECMDGOALS)),)
6458
The Android Open Source Project88b60792009-03-03 19:28:42 -08006459# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07006460sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006461
6462# Build a name that looks like:
6463#
6464# linux-x86 --> android-sdk_12345_linux-x86
6465# darwin-x86 --> android-sdk_12345_mac-x86
6466# windows-x86 --> android-sdk_12345_windows
6467#
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006468ifneq ($(HOST_OS),linux)
6469 $(error Building the monolithic SDK is only supported on Linux)
6470endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006471sdk_name := android-sdk_$(FILE_NAME_TAG)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006472INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH)
Joe Onorato03fbe402009-04-13 08:31:16 -07006473sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006474
6475sdk_dep_file := $(sdk_dir)/sdk_deps.mk
6476
6477ATREE_FILES :=
6478-include $(sdk_dep_file)
6479
6480# if we don't have a real list, then use "everything"
6481ifeq ($(strip $(ATREE_FILES)),)
6482ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006483 $(ALL_DEFAULT_INSTALLED_MODULES) \
6484 $(INSTALLED_RAMDISK_TARGET) \
6485 $(ALL_DOCS) \
6486 $(ALL_SDK_FILES)
6487endif
6488
6489atree_dir := development/build
6490
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01006491
Dan Willemsen53c98f72021-10-16 16:49:06 -07006492sdk_atree_files := $(atree_dir)/sdk.exclude.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08006493
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02006494# development/build/sdk-android-<abi>.atree is used to differentiate
6495# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
6496# files like the kernel image. We use TARGET_CPU_ABI because we don't
6497# have a better way to distinguish between CPU models.
6498ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
6499 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
6500endif
6501
Anton Hansson8dab0a62019-03-28 15:45:40 +00006502ifneq ($(PRODUCT_SDK_ATREE_FILES),)
6503sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08006504else
6505sdk_atree_files += $(atree_dir)/sdk.atree
6506endif
6507
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07006508include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07006509
The Android Open Source Project88b60792009-03-03 19:28:42 -08006510deps := \
6511 $(target_notice_file_txt) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006512 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01006513 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07006514 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07006515 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01006516 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07006517 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00006518 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07006519 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07006520 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006521 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07006522 $(INSTALLED_USERDATAIMAGE_TARGET) \
6523 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006524 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07006525 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006526 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08006527 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006528 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07006529 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07006530 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006531
6532INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
6533$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
6534$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
6535$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
6536$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
6537
6538# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
6539#
6540#SDK_GNU_ERROR := true
6541
Ying Wang5d887702015-11-04 10:06:25 -08006542$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006543 @echo "Package SDK: $@"
6544 $(hide) rm -rf $(PRIVATE_DIR) $@
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07006545 $(hide) for f in $(strip $(target_gnu_MODULES)); do \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006546 if [ -f $$f ]; then \
6547 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
6548 including GNU target $$f >&2; \
6549 FAIL=$(SDK_GNU_ERROR); \
6550 fi; \
6551 done; \
6552 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07006553 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08006554 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00006555 ATREE_STRIP="$(HOST_STRIP) -x" \
6556 $(HOST_OUT_EXECUTABLES)/atree \
6557 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
6558 -m $(PRIVATE_DEP_FILE) \
6559 -I . \
6560 -I $(PRODUCT_OUT) \
6561 -I $(HOST_OUT) \
6562 -I $(TARGET_COMMON_OUT_ROOT) \
6563 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
6564 -v "OUT_DIR=$(OUT_DIR)" \
6565 -v "HOST_OUT=$(HOST_OUT)" \
6566 -v "TARGET_ARCH=$(TARGET_ARCH)" \
6567 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
6568 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
6569 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
6570 -o $(PRIVATE_DIR) && \
6571 cp -f $(target_notice_file_txt) \
6572 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
Anton Hansson6d814982018-11-26 18:12:05 +00006573 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
6574 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
6575 chmod -R ug+rwX $(PRIVATE_DIR) && \
6576 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006577 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
6578
Raphaelc4d47312011-02-15 16:09:36 -08006579MAIN_SDK_DIR := $(sdk_dir)
6580MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006581
6582endif # sdk in MAKECMDGOALS
Raphael3d224a02010-04-16 17:50:09 -07006583
The Android Open Source Project88b60792009-03-03 19:28:42 -08006584# -----------------------------------------------------------------
6585# Findbugs
6586INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
6587INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
6588$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
6589 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006590 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006591 > $@
6592$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
6593 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006594 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07006595 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08006596
6597# -----------------------------------------------------------------
6598# Findbugs
6599
6600# -----------------------------------------------------------------
6601# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07006602ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006603include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01006604-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07006605-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006606-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07006607# Also the project-specific tasks
6608-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
6609-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006610-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07006611# Also add test specifc tasks
6612include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07006613include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07006614endif
Raphaelc4d47312011-02-15 16:09:36 -08006615
Ying Wang67132ba2015-10-28 16:42:39 -07006616include $(BUILD_SYSTEM)/product-graph.mk
6617
Raphaelc4d47312011-02-15 16:09:36 -08006618# -----------------------------------------------------------------
6619# Create SDK repository packages. Must be done after tasks/* since
6620# we need the addon rules defined.
6621ifneq ($(sdk_repo_goal),)
6622include $(TOPDIR)development/build/tools/sdk_repo.mk
6623endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07006624
6625# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07006626# Soong generates the list of all shared libraries that are depended on by fuzz
6627# targets. It saves this list as a source:destination pair to
6628# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
6629# build of the unstripped shared library, and the destination is the
6630# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
6631# where fuzz target shared libraries are to be "reinstalled". The
6632# copy-many-files below generates the rules to copy the unstripped shared
6633# libraries to the device or host "reinstallation" directory. These rules are
6634# depended on by each module in soong_cc_prebuilt.mk, where the module will have
6635# a dependency on each shared library that it needs to be "reinstalled".
6636FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
6637
6638# -----------------------------------------------------------------
hamzeh5dfe7a22021-04-29 12:44:16 -07006639# The rule to build all fuzz targets for C++ and Rust, and package them.
Mitch Phillipsceefc442019-09-26 16:37:59 -07006640# Note: The packages are created in Soong, and in a perfect world,
6641# we'd be able to create the phony rule there. But, if we want to
6642# have dist goals for the fuzz target, we need to have the PHONY
6643# target defined in make. MakeVarsContext.DistForGoal doesn't take
6644# into account that a PHONY rule create by Soong won't be available
6645# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08006646# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07006647# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08006648.PHONY: haiku
6649haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
6650$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
hamzeh5dfe7a22021-04-29 12:44:16 -07006651
Muhammad Haseeb Ahmadcced1362022-01-13 03:17:39 +00006652.PHONY: haiku-java
6653haiku-java: $(SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_TARGETS)
6654$(call dist-for-goals,haiku-java,$(SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES))
6655
hamzeh5dfe7a22021-04-29 12:44:16 -07006656.PHONY: haiku-rust
6657haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
6658$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))
Bob Badour70c07dd2022-02-12 15:39:22 -08006659
6660
6661# -----------------------------------------------------------------
6662# OS Licensing
6663
6664include $(BUILD_SYSTEM)/os_licensing.mk
6665
6666# When appending new code to this file, please insert above OS Licensing