blob: 51541d811e67013139ce4219961985eb693ee0e6 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001# Put some miscellaneous rules here
2
Ying Wang3bbfddd2014-03-01 15:32:04 -08003# HACK: clear LOCAL_PATH from including last build target before calling
4# intermedites-dir-for
5LOCAL_PATH := $(BUILD_SYSTEM)
6
Bob Badourebdefc02022-02-12 15:39:22 -08007SYSTEM_NOTICE_DEPS :=
8VENDOR_NOTICE_DEPS :=
9UNMOUNTED_NOTICE_DEPS :=
Justin Yundd15ec12022-09-23 10:47:21 +090010UNMOUNTED_NOTICE_VENDOR_DEPS :=
Bob Badourebdefc02022-02-12 15:39:22 -080011ODM_NOTICE_DEPS :=
12OEM_NOTICE_DEPS :=
13PRODUCT_NOTICE_DEPS :=
14SYSTEM_EXT_NOTICE_DEPS :=
15VENDOR_DLKM_NOTICE_DEPS :=
16ODM_DLKM_NOTICE_DEPS :=
17SYSTEM_DLKM_NOTICE_DEPS :=
18
The Android Open Source Project88b60792009-03-03 19:28:42 -080019# -----------------------------------------------------------------
20# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -070021# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080022# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
23# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080024# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070025# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070026#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070027#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070028define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070029$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
30 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080031 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
32$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
33 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
34 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
35 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
36 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
37 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
38 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
39 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
40 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
41 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
42 use vintf_compatibility_matrix / vintf_fragments instead!)) \
43 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
44 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
45 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
46 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
47 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
48 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
49 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
50 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
51 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
52)
Ying Wang68864102011-09-29 13:23:25 -070053endef
Yo Chiang0b49c032020-03-17 17:49:49 +080054
Yo Chiang336883a2020-05-14 17:17:29 +080055# Phony target to check PRODUCT_COPY_FILES copy pairs don't contain ELF files
56.PHONY: check-elf-prebuilt-product-copy-files
57check-elf-prebuilt-product-copy-files:
58
Yo Chiang0b49c032020-03-17 17:49:49 +080059check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080060ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
61check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080062endif
63check_elf_prebuilt_product_copy_files_hint := \
64 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
65
Ying Wang619fccf2012-09-05 18:08:29 -070066# filter out the duplicate <source file>:<dest file> pairs.
67unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080068$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070069 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
70 $(eval unique_product_copy_files_pairs += $(cf))))
71unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080072product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070073$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070074 $(eval _src := $(call word-colon,1,$(cf))) \
75 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070076 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080077 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080078 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070079 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070080 $(if $(filter %.xml,$(_dest)),\
81 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010082 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
83 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070084 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
85 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080086 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
87 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
88 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
89 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070090 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080091
92# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070093pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
94$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
95$(pcf_ignored_file):
96 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080097
Bob Badour5acd4362022-04-12 18:31:35 -070098$(call declare-0p-target,$(pcf_ignored_file))
99
Bill Peckham315b98a2021-06-15 19:35:06 -0700100$(call dist-for-goals,droidcore-unbundled,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
Dan Willemsen7537fd02018-10-16 23:15:08 -0700101
102pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -0800103product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -0700104unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -0700105unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800106
107# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800108# Returns the max allowed size for an image suitable for hash verification
109# (e.g., boot.img, recovery.img, etc).
110# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
111# $(1): partition size to flash the image
112define get-hash-image-max-size
113$(if $(1), \
114 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
115 $(eval _hash_meta_size := 69632), \
116 $(eval _hash_meta_size := 0)) \
117 $(1)-$(_hash_meta_size))
118endef
119
120# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800121# Define rules to copy headers defined in copy_headers.mk
122# If more than one makefile declared a header, print a warning,
123# then copy the last one defined. This matches the previous make
124# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700125has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800126$(foreach dest,$(ALL_COPIED_HEADERS), \
127 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800128 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800129 $(if $(call streq,$(_src),$(_srcs)),, \
130 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800131 $(warning _ Using $(_src)) \
132 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
133 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
134 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
135 $(warning _ Ignoring $(src)) \
136 $(warning __ from $(firstword $(_makefiles))) \
137 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
138 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800139 $(eval $(call copy-one-header,$(_src),$(dest))))
140all_copied_headers: $(ALL_COPIED_HEADERS)
141
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700142ifdef has_dup_copy_headers
143 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700144 $(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 -0700145endif
146
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800147$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
148
Dan Willemsen6f60f022016-02-23 13:40:07 -0800149# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800150# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100151ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152gen := $(OUT_DOCS)/index.html
153ALL_DOCS += $(gen)
154$(gen): frameworks/base/docs/docs-redirect-index.html
155 @mkdir -p $(dir $@)
156 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700157endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800158
Dan Albert303e6032017-10-04 10:20:20 -0700159ndk_doxygen_out := $(OUT_NDK_DOCS)
160ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
161ndk_docs_src_dir := frameworks/native/docs
162ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
163ifneq ($(wildcard $(ndk_docs_src_dir)),)
164ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
165 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
166$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
167 @mkdir -p $(ndk_doxygen_out)
168 @echo "Generating NDK docs to $(ndk_doxygen_out)"
169 @( cat $(ndk_doxyfile); \
170 echo "INPUT=$(ndk_headers)"; \
171 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
172 ) | doxygen -
173
Bob Badour5acd4362022-04-12 18:31:35 -0700174$(call declare-1p-target,$(ndk_doxygen_out)/index.html,)
175
Dan Albert303e6032017-10-04 10:20:20 -0700176# Note: Not a part of the docs target because we don't have doxygen available.
177# You can run this target locally if you have doxygen installed.
178ndk-docs: $(ndk_doxygen_out)/index.html
179.PHONY: ndk-docs
180endif
181
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700182ifeq ($(HOST_OS),linux)
Colin Crossd60401a2019-04-18 14:46:48 -0700183$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700184endif
Dan Willemsenad6a1542018-12-14 01:04:19 -0800185
Andres Moralesb8876e12015-05-06 20:44:22 -0700186INSTALLED_RECOVERYIMAGE_TARGET :=
Yifan Hong881df392020-10-09 14:29:39 -0700187# Build recovery image if
188# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
189# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
190# with recovery resources.
191# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
192# but not the final recovery image.
Chris Grossa784ef12019-04-22 11:09:57 -0700193ifdef BUILDING_RECOVERY_IMAGE
194ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong881df392020-10-09 14:29:39 -0700195ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -0700196INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
197endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700198endif
Yifan Hong881df392020-10-09 14:29:39 -0700199endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700200
Jiyong Parke1346862020-05-18 14:31:30 +0900201include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100202
203# ----------------------------------------------------------------
204
205# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800206# sdk-build.prop
207#
208# There are certain things in build.prop that we don't want to
209# ship with the sdk; remove them.
210
211# This must be a list of entire property keys followed by
212# "=" characters, without any internal spaces.
213sdk_build_prop_remove := \
214 ro.build.user= \
215 ro.build.host= \
216 ro.product.brand= \
217 ro.product.manufacturer= \
218 ro.product.device=
219# TODO: Remove this soon-to-be obsolete property
220sdk_build_prop_remove += ro.build.product=
221INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
222$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
223 @echo SDK buildinfo: $@
224 @mkdir -p $(dir $@)
225 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000226 $(sdk_build_prop_remove)))" $< > $@.tmp
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700227 $(hide) for x in $(strip $(sdk_build_prop_remove)); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000228 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800229 $(hide) mv $@.tmp $@
230
Bob Badour5acd4362022-04-12 18:31:35 -0700231$(call declare-0p-target,$(INSTALLED_SDK_BUILD_PROP_TARGET))
232
The Android Open Source Project88b60792009-03-03 19:28:42 -0800233# -----------------------------------------------------------------
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800234# declare recovery ramdisk files
235ifeq ($(BUILDING_RECOVERY_IMAGE),true)
236INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
237endif
238
239# -----------------------------------------------------------------
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800240# Declare vendor ramdisk fragments
241INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
242
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800243ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
244 ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
245 $(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \
246 BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set)
247 endif
248 INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery
249 VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT)
250 VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
251 BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY
252 .KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR
253endif
254
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800255# Validation check and assign default --ramdisk_type.
256$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
257 $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
258 $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
259 $(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))) \
260 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
261 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
262 $(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
263 $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
264 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
265)
266
267# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
268$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
269 $(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
270 $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
271 $(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)) \
272 $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
273 ) \
274)
275INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
276
Yi-Yo Chiang378b7792021-04-09 20:09:13 +0800277# Strip the list in case of any whitespace.
278INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \
279 $(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS))
280
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800281# Assign --ramdisk_name for each vendor ramdisk fragment.
282$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
283 $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
284 $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
285 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
286 $(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
287)
288
289# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700290# kernel modules
291
292# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
293DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
294
J. Avilaa2ceec62020-05-12 23:40:02 +0000295define copy-and-strip-kernel-module
296$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000297 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000298endef
299
Colin Cross4f60e362019-06-05 11:53:43 -0700300# $(1): modules list
301# $(2): output dir
302# $(3): mount point
303# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700304# $(5): module load list
305# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800306# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000307# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700308# $(9): module directory name
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800309# $(10): extra modules that might be dependency of modules in this partition, but should not be copied to output dir
310# $(11): mount point for extra modules
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800311# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700312define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700313 $(if $(9), \
314 $(eval _dir := $(9)/), \
315 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000316 $(foreach module,$(1), \
317 $(eval _src := $(module)) \
318 $(if $(8), \
319 $(eval _src := $(8)/$(notdir $(module))) \
320 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700321 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800322 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9),$(10),$(11))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700323 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
324 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
325 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
326 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700327endef
328
329# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700330# $(2): mount point
331# $(3): staging dir
332# $(4): module load list
333# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800334# $(6): module archive
335# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700336# $(8): module directory name
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800337# $(9): extra modules which should not be copied to output dir, but might be dependency of modules in this partition
338# $(10): mount point for extra modules
Steve Muckle810a0ba2019-11-13 13:29:02 -0800339# TODO(b/144844424): If a module archive is being used, this step (which
340# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
341# the output directory. This should be moved to a module with a
342# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
343# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700344define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700345$(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 -0700346$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700347$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800348$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MODULES := $(strip $(9))
Steve Muckle474e4d02019-06-19 12:56:48 -0700349$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800350$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MOUNT_POINT := $(10)
Steve Muckle2335d762020-05-28 18:39:38 -0700351$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800352$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(10)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700353$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700354$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
Steve Muckle474e4d02019-06-19 12:56:48 -0700355$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800356$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
357$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
358$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700359 @echo depmod $$(PRIVATE_STAGING_DIR)
360 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700361 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800362 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700363 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800364 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700365 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800366 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
367 )
368 $(if $(1),\
369 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
370 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
371 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
372 done; \
373 )
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800374 # The ln -sf + find -delete sequence is to remove any modules in
375 # PRIVATE_EXTRA_MODULES which have same basename as MODULES in PRIVATE_MODULES
376 # Basically, it computes a set difference. When there is a duplicate module
377 # present in both directories, we want modules in PRIVATE_MODULES to take
378 # precedence. Since depmod does not provide any guarantee about ordering of
379 # dependency resolution, we achieve this by maually removing any duplicate
380 # modules with lower priority.
381 $(if $(9),\
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800382 mkdir -p $$(PRIVATE_EXTRA_MODULE_DIR); \
Kelvin Zhang21b6cad2022-12-06 16:03:30 -0800383 find $$(PRIVATE_EXTRA_MODULE_DIR) -maxdepth 1 -type f -name "*.ko" -delete; \
384 cp $$(PRIVATE_EXTRA_MODULES) $$(PRIVATE_EXTRA_MODULE_DIR); \
385 ln -sf $$(PRIVATE_MODULE_DIR)/*.ko $$(PRIVATE_EXTRA_MODULE_DIR); \
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800386 find $$(PRIVATE_EXTRA_MODULE_DIR) -type l -delete; \
387 )
Colin Cross4f60e362019-06-05 11:53:43 -0700388 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
389 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700390 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
391 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700392endef
393
Steve Muckle474e4d02019-06-19 12:56:48 -0700394# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700395# $(2): modules list
396# $(3): module load list
397# $(4): module load list filename
398# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700399define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700400 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
401 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700402endef
403
404# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700405# $(2): modules list
406# $(3): module load list
407# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700408define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700409$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
410$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
411 @echo load-list $$(@)
412 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700413endef
414
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800415# $(1): source options file
416# $(2): destination pathname
417# Returns a build rule that checks the syntax of and installs a kernel modules
418# options file. Strip and squeeze any extra space and blank lines.
419# For use via $(eval).
420define build-image-kernel-modules-options-file
421$(2): $(1)
422 @echo "libmodprobe options $$(@)"
423 $(hide) mkdir -p "$$(dir $$@)"
424 $(hide) rm -f "$$@"
425 $(hide) awk <"$$<" >"$$@" \
426 '/^#/ { print; next } \
427 NF == 0 { next } \
428 NF < 2 || $$$$1 != "options" \
429 { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
430 exit_status = 1; next } \
431 { $$$$1 = $$$$1; print } \
432 END { exit exit_status }'
433endef
434
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800435# $(1): source blocklist file
436# $(2): destination pathname
437# Returns a build rule that checks the syntax of and installs a kernel modules
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800438# blocklist file. Strip and squeeze any extra space and blank lines.
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800439# For use via $(eval).
440define build-image-kernel-modules-blocklist-file
441$(2): $(1)
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800442 @echo "libmodprobe blocklist $$(@)"
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800443 $(hide) mkdir -p "$$(dir $$@)"
444 $(hide) rm -f "$$@"
445 $(hide) awk <"$$<" >"$$@" \
446 '/^#/ { print; next } \
447 NF == 0 { next } \
448 NF != 2 || $$$$1 != "blocklist" \
449 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
450 exit_status = 1; next } \
451 { $$$$1 = $$$$1; print } \
452 END { exit exit_status }'
453endef
454
Steve Muckle2335d762020-05-28 18:39:38 -0700455# $(1): image name
456# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
457# $(3): mount point
458# $(4): module load filename
459# $(5): stripped staging directory
460# $(6): kernel module directory name (top is an out of band value for no directory)
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800461# $(7): list of extra modules that might be dependency of modules in this partition
462# $(8): mount point for extra modules. e.g. system
463
Steve Muckle2335d762020-05-28 18:39:38 -0700464define build-image-kernel-modules-dir
465$(if $(filter top,$(6)),\
466 $(eval _kver :=)$(eval _sep :=),\
467 $(eval _kver := $(6))$(eval _sep :=_))\
468$(if $(5),\
469 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
470 $(eval _stripped_staging_dir :=))\
471$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
472 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
473 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Kelvin Zhangb66b11e2022-12-05 13:04:42 -0800474 $(if $(filter false,$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver))),\
475 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) :=),) \
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800476 $(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),$(7),$(8)))) \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800477$(if $(_kver), \
478 $(eval _dir := $(_kver)/), \
479 $(eval _dir :=)) \
480$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
481 $(eval $(call build-image-kernel-modules-options-file, \
482 $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
483 $(2)/lib/modules/$(_dir)modules.options)) \
484 $(2)/lib/modules/$(_dir)modules.options) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800485$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
486 $(eval $(call build-image-kernel-modules-blocklist-file, \
487 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800488 $(2)/lib/modules/$(_dir)modules.blocklist)) \
489 $(2)/lib/modules/$(_dir)modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700490endef
491
492# $(1): kernel module directory name (top is an out of band value for no directory)
493define build-recovery-as-boot-load
494$(if $(filter top,$(1)),\
495 $(eval _kver :=)$(eval _sep :=),\
496 $(eval _kver := $(1))$(eval _sep :=_))\
497 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
498 $(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))))
499endef
500
501# $(1): kernel module directory name (top is an out of band value for no directory)
502define build-vendor-ramdisk-recovery-load
503$(if $(filter top,$(1)),\
504 $(eval _kver :=)$(eval _sep :=),\
505 $(eval _kver := $(1))$(eval _sep :=_))\
506 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
507 $(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))))
508endef
509
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700510# $(1): kernel module directory name (top is an out of band value for no directory)
511define build-vendor-charger-load
512$(if $(filter top,$(1)),\
513 $(eval _kver :=)$(eval _sep :=),\
514 $(eval _kver := $(1))$(eval _sep :=_))\
515 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
516 $(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))))
517endef
518
Steve Mucklee1b10862019-07-10 10:49:37 -0700519ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
520 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
521 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700522 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700523 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
524endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700525
Steve Muckle69280d22019-07-11 12:23:38 -0700526ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
527 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700528endif
529
Steve Mucklee1b10862019-07-10 10:49:37 -0700530ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700531 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700532 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700533 endif
534endif
535
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800536ifneq ($(BOARD_DO_NOT_STRIP_RECOVERY_MODULES),true)
537 RECOVERY_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery_stripped)
538else
539 RECOVERY_STRIPPED_MODULE_STAGING_DIR :=
540endif
541
J. Avilaa2ceec62020-05-12 23:40:02 +0000542ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
543 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
544else
545 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
546endif
Colin Cross4f60e362019-06-05 11:53:43 -0700547
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700548ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
549 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
550else
551 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
552endif
553
Lucas Weif57333f2022-02-24 10:30:15 +0800554ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_KERNEL_RAMDISK_MODULES),true)
555 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_kernel_ramdisk_stripped)
556else
557 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
558endif
559
Steve Muckle2335d762020-05-28 18:39:38 -0700560BOARD_KERNEL_MODULE_DIRS += top
Kelvin Zhang395d3df2022-12-07 10:36:10 -0800561
562# Default to not generating modules.dep for kernel modules on system
563# side. We should only load these modules if they are depended by vendor
564# side modules.
565ifeq ($(BOARD_SYSTEM_KERNEL_MODULES_LOAD),)
566 BOARD_SYSTEM_KERNEL_MODULES_LOAD := false
567endif
568
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800569$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800570 $(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 +0800571 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800572 $(if $(vendor_ramdisk_fragment), \
573 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
574 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
575 $(eval ### else ###), \
576 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
577 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800578 $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
Lucas Weif57333f2022-02-24 10:30:15 +0800579 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_KERNEL_RAMDISK,$(TARGET_VENDOR_KERNEL_RAMDISK_OUT),,modules.load,$(VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800580 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
Kelvin Zhangd5f06112022-12-02 15:19:30 -0800581 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(kmd),$(BOARD_SYSTEM_KERNEL_MODULES),system)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800582 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
583 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(kmd))) \
Ramji Jiyani49b70b62022-12-01 00:55:10 +0000584 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,SYSTEM,$(if $(filter true,$(BOARD_USES_SYSTEM_DLKMIMAGE)),$(TARGET_OUT_SYSTEM_DLKM),$(TARGET_OUT_SYSTEM)),system,modules.load,,$(kmd))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700585 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800586 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
587 $(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 -0700588
589# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800590# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700591# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900592# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700593# $2 certificate
594# $3 private key
595# $4 compressed
596# $5 partition tag
597# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100598define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700599$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
600$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
601$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
602$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700603
604endef
605
Jaewoong Jung704b4542020-06-29 19:37:53 -0700606# -----------------------------------------------------------------
607# Merge an individual apkcerts output into the final apkcerts.txt output.
608# Use a macro to make it compatible with _apkcerts_write_line
609# $1 apkcerts file to be merged
610# $2 output file
611define _apkcerts_merge
612$(hide) cat $1 >> $2
613
614endef
615
The Android Open Source Project88b60792009-03-03 19:28:42 -0800616name := $(TARGET_PRODUCT)
617ifeq ($(TARGET_BUILD_TYPE),debug)
618 name := $(name)_debug
619endif
620name := $(name)-apkcerts-$(FILE_NAME_TAG)
621intermediates := \
622 $(call intermediates-dir-for,PACKAGING,apkcerts)
623APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700624all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
625$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800626# We don't need to really build all the modules.
627# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700628$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800629 @echo APK certs list: $@
630 @mkdir -p $(dir $@)
631 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700632 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700633 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
634 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
635 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700636 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700637 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Victor Hsieh89415a82022-09-09 14:16:33 -0700638 $(if $(filter true,$(PRODUCT_FSVERITY_GENERATE_METADATA)),\
639 $(call _apkcerts_write_line,BuildManifest,$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system,$@) \
640 $(if $(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),\
Victor Hsiehadc94a12022-09-20 11:46:09 -0700641 $(call _apkcerts_write_line,BuildManifestSystemExt,$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system_ext,$@)))
Ying Wangd9a88d52012-10-26 09:21:28 -0700642 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700643 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800644
Bob Badour5acd4362022-04-12 18:31:35 -0700645$(call declare-0p-target,$(APKCERTS_FILE))
646
The Android Open Source Project88b60792009-03-03 19:28:42 -0800647.PHONY: apkcerts-list
648apkcerts-list: $(APKCERTS_FILE)
649
Ying Wang15e487a2011-02-15 10:56:18 -0800650ifneq (,$(TARGET_BUILD_APPS))
651 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900652 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800653endif
Ying Wangefb21682010-07-23 16:42:13 -0700654
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900655
The Android Open Source Project88b60792009-03-03 19:28:42 -0800656# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700657# build system stats
658BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
659$(BUILD_SYSTEM_STATS):
660 @rm -f $@
661 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
662 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700663$(call declare-1p-target,$(BUILD_SYSTEM_STATS),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700664$(call dist-for-goals,droidcore-unbundled,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700665
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700666# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800667# build /product/etc/security/avb/system_other.avbpubkey if needed
668ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800669ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800670INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
671ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800672endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800673endif # BUILDING_SYSTEM_OTHER_IMAGE
674
675# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700676# Modules ready to be converted to Soong, ordered by how many
677# modules depend on them.
678SOONG_CONV := $(sort $(SOONG_CONV))
679SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
680$(SOONG_CONV_DATA):
681 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700682 @$(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 -0700683
Bob Badour5acd4362022-04-12 18:31:35 -0700684$(call declare-1p-target,$(SOONG_CONV_DATA),build)
685
Colin Crossfdea8932017-12-06 14:38:40 -0800686SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700687SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
688$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
689 @rm -f $@
690 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
Bob Badour5acd4362022-04-12 18:31:35 -0700691$(call declare-1p-target,$(SOONG_TO_CONVERT),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700692$(call dist-for-goals,droidcore-unbundled,$(SOONG_TO_CONVERT))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700693
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700694$(PRODUCT_OUT)/product_packages.txt:
695 @rm -f $@
696 echo "" > $@
697 $(foreach x,$(PRODUCT_PACKAGES),echo $(x) >> $@$(newline))
698
Joe Onorato02fb89a2020-06-27 00:10:23 -0700699MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700700PRODUCT_PACKAGES_TXT := $(PRODUCT_OUT)/product_packages.txt
Joe Onorato02fb89a2020-06-27 00:10:23 -0700701MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
702$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700703$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato02fb89a2020-06-27 00:10:23 -0700704 @rm -f $@
705 $(hide) $(MK2BP_CATALOG_SCRIPT) \
706 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700707 --product-packages=$(PRODUCT_PACKAGES_TXT) \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700708 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
709 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700710 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700711 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700712 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700713$(call declare-1p-target,$(MK2BP_REMAINING_HTML),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700714$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_HTML))
Joe Onorato02fb89a2020-06-27 00:10:23 -0700715
Joe Onorato31986072020-08-10 09:58:49 -0700716MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700717$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato31986072020-08-10 09:58:49 -0700718 @rm -f $@
719 $(hide) $(MK2BP_CATALOG_SCRIPT) \
720 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700721 --product-packages=$(PRODUCT_PACKAGES_TXT) \
722 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700723 --mode=csv \
724 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700725$(call declare-1p-target,$(MK2BP_REMAINING_CSV))
Bill Peckham315b98a2021-06-15 19:35:06 -0700726$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_CSV))
Joe Onorato31986072020-08-10 09:58:49 -0700727
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700728# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800729# Modules use -Wno-error, or added default -Wall -Werror
730WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
731$(WALL_WERROR):
732 @rm -f $@
733 echo "# Modules using -Wno-error" >> $@
734 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Yi Kongee99ddf2022-05-19 20:13:55 +0800735 echo "# Modules that allow warnings" >> $@
736 for m in $(sort $(SOONG_MODULES_WARNINGS_ALLOWED) $(MODULES_WARNINGS_ALLOWED)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800737
Bob Badour5acd4362022-04-12 18:31:35 -0700738$(call declare-0p-target,$(WALL_WERROR))
739
Bill Peckham315b98a2021-06-15 19:35:06 -0700740$(call dist-for-goals,droidcore-unbundled,$(WALL_WERROR))
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800741
742# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700743# C/C++ flag information for modules
Bill Peckham315b98a2021-06-15 19:35:06 -0700744$(call dist-for-goals,droidcore-unbundled,$(SOONG_MODULES_CFLAG_ARTIFACTS))
Jesse Paid0046922019-09-13 17:02:32 -0700745
Bob Badour5acd4362022-04-12 18:31:35 -0700746$(foreach a,$(SOONG_MODULES_CFLAG_ARTIFACTS),$(call declare-0p-target,$(call word-colon,1,$(a))))
747
Jesse Paid0046922019-09-13 17:02:32 -0700748# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800749# Modules missing profile files
750PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
751$(PGO_PROFILE_MISSING):
752 @rm -f $@
753 echo "# Modules missing PGO profile files" >> $@
754 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
755
Bob Badour5acd4362022-04-12 18:31:35 -0700756$(call declare-0p-target,$(PGO_PROFILE_MISSING))
757
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800758$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
759
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000760CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
761$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
762 rm -f $@
763 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700764$(call declare-0p-target,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000765$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
766
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800767# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700768# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700769# for future OTA packages installed by this system. Actual product
770# deliverables will be re-signed by hand. We expect this file to
771# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700772DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700773
774
Jeff Browne33ba4c2011-07-11 22:11:46 -0700775# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776# if they don't do anything.
777.PHONY: systemimage
778systemimage:
779
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800780# -----------------------------------------------------------------
781
782.PHONY: event-log-tags
783
Joe Onoratob7510532010-07-14 10:22:54 -0700784# Produce an event logs tag file for everything we know about, in order
785# to properly allocate numbers. Then produce a file that's filtered
786# for what's going to be installed.
787
788all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
789
Colin Crossdc8f8e42012-04-12 13:25:54 -0700790event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
791
Joe Onoratob7510532010-07-14 10:22:54 -0700792# Include tags from all packages that we know about
793all_event_log_tags_src := \
794 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
795
Dan Willemsena3f66322020-05-28 15:46:33 -0700796$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
797$(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 -0700798 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900799 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700800
Bob Badour5acd4362022-04-12 18:31:35 -0700801$(call declare-0p-target,$(all_event_log_tags_file))
802
Doug Zongkera34fa952011-02-23 12:17:29 -0800803# Include tags from all packages included in this product, plus all
804# tags that are part of the system (ie, not in a vendor/ or device/
805# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800806event_log_tags_src := \
807 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800808 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800809 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800810 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
811 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800812
Dan Willemsena3f66322020-05-28 15:46:33 -0700813$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700814$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700815$(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 -0800816 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900817 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800818
Bob Badour2f66fd12022-03-09 17:30:24 -0800819$(eval $(call declare-0p-target,$(event_log_tags_file)))
820
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800821event-log-tags: $(event_log_tags_file)
822
823ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
824
Colin Cross79a76ec2022-03-21 15:06:11 -0700825# Initialize INSTALLED_FILES_OUTSIDE_IMAGES with the list of all device files,
826# files installed in images will be filtered out later.
827INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out \
828 $(PRODUCT_OUT)/apex/% \
Colin Cross41e93ea2022-03-25 17:31:49 -0700829 $(PRODUCT_OUT)/fake_packages/% \
Colin Cross79a76ec2022-03-21 15:06:11 -0700830 $(PRODUCT_OUT)/testcases/%, \
831 $(filter $(PRODUCT_OUT)/%,$(ALL_DEFAULT_INSTALLED_MODULES)))
Joe Onoratob7510532010-07-14 10:22:54 -0700832
The Android Open Source Project88b60792009-03-03 19:28:42 -0800833# #################################################################
834# Targets for boot/OS images
835# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800836ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
837 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000838 ifdef BOARD_PREBUILT_BOOTLOADER
839 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
840 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
841 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800842 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
843 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
844 else
845 INSTALLED_2NDBOOTLOADER_TARGET :=
846 endif
847else
848 INSTALLED_BOOTLOADER_MODULE :=
849 INSTALLED_2NDBOOTLOADER_TARGET :=
850endif # TARGET_NO_BOOTLOADER
851ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700852 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
853 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
854 $(PRODUCT_OUT)/$(k))
855 else
856 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
857 endif
Ying Wangc6349742014-01-13 16:14:20 -0800858else
859 INSTALLED_KERNEL_TARGET :=
860endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800861
862# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700863# the root dir
Colin Cross79a76ec2022-03-21 15:06:11 -0700864INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_ROOT_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Tom Cherryd14b8952018-08-09 14:26:00 -0700865INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800866 $(ALL_DEFAULT_INSTALLED_MODULES))
867
Colin Cross79a76ec2022-03-21 15:06:11 -0700868
Luis Hector Chavezff489932018-07-03 15:41:40 -0700869INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
870INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
871$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700872$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700873 @echo Installed file list: $@
SzuWei Linc230b0b2021-12-30 13:48:01 +0800874 mkdir -p $(TARGET_ROOT_OUT)
Petri Gynther728e0bd2021-03-06 13:29:28 -0800875 mkdir -p $(dir $@)
876 rm -f $@
877 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
878 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700879
Bob Badoure9bdbc52022-03-10 11:31:07 -0800880$(call declare-0p-target,$(INSTALLED_FILES_FILE_ROOT))
Bob Badour5acd4362022-04-12 18:31:35 -0700881$(call declare-0p-target,$(INSTALLED_FILES_JSON_ROOT))
Bob Badoure9bdbc52022-03-10 11:31:07 -0800882
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800883#------------------------------------------------------------------
884# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700885ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800886INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700887ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800888$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800889 cat $^ > $@
890endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700891endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800892
Tom Cherryd14b8952018-08-09 14:26:00 -0700893# -----------------------------------------------------------------
894# the ramdisk
Colin Cross79a76ec2022-03-21 15:06:11 -0700895INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -0800896ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700897INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
Tom Cherryd14b8952018-08-09 14:26:00 -0700898 $(ALL_DEFAULT_INSTALLED_MODULES))
899
900INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
901INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
902$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700903$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700904 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800905 mkdir -p $(TARGET_RAMDISK_OUT)
906 mkdir -p $(dir $@)
907 rm -f $@
908 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
909 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700910
Bob Badourebdefc02022-02-12 15:39:22 -0800911$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -0700912$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -0800913
Joe Onorato64d85d02009-04-09 19:31:12 -0700914BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
915
J. Avila3f6560e2020-05-11 20:20:03 +0000916ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
917# -l enables the legacy format used by the Linux kernel
918COMPRESSION_COMMAND_DEPS := $(LZ4)
919COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
920RAMDISK_EXT := .lz4
921else
922COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
923COMPRESSION_COMMAND := $(MINIGZIP)
924RAMDISK_EXT := .gz
925endif
926
Vincent Donnefort4a5fd832022-12-22 13:48:55 +0000927# This file contains /dev nodes description added to the generic ramdisk
928RAMDISK_NODE_LIST := $(PRODUCT_OUT)/ramdisk_node_list
929
Joe Onorato64d85d02009-04-09 19:31:12 -0700930# We just build this directly to the install location.
931INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900932$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
Vincent Donnefort4a5fd832022-12-22 13:48:55 +0000933$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(RAMDISK_NODE_LIST) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800934 $(call pretty,"Target ramdisk: $@")
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900935 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
936ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
937 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
938endif
Vincent Donnefort4a5fd832022-12-22 13:48:55 +0000939 $(hide) $(MKBOOTFS) -n $(RAMDISK_NODE_LIST) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800940
Bob Badourebdefc02022-02-12 15:39:22 -0800941$(call declare-1p-container,$(INSTALLED_RAMDISK_TARGET),)
942$(call declare-container-license-deps,$(INSTALLED_RAMDISK_TARGET),$(INTERNAL_RAMDISK_FILE),$(PRODUCT_OUT)/:/)
943
Justin Yundd15ec12022-09-23 10:47:21 +0900944UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -0800945
Ying Wangad7fd292013-08-08 16:34:29 -0700946.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000947ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700948 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000949 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800950
Dan Willemsen67495202019-01-16 12:42:05 -0800951endif # BUILDING_RAMDISK_IMAGE
952
The Android Open Source Project88b60792009-03-03 19:28:42 -0800953# -----------------------------------------------------------------
954# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700955
956# This is defined here since we may be building recovery as boot
957# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700958ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
959 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
960else
961 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
962endif
963
Yifan Hong0674a6e2020-10-22 14:37:01 -0700964INTERNAL_PREBUILT_BOOTIMAGE :=
965
966my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
967ifdef my_installed_prebuilt_gki_apex
968 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
969 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
970 endif # len(my_installed_prebuilt_gki_apex) > 1
971
972 ifdef BOARD_PREBUILT_BOOTIMAGE
973 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
974 endif # BOARD_PREBUILT_BOOTIMAGE defined
975
976 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
977 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
978 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
Bob Badoura60beee2022-09-07 15:34:12 -0700979 $(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Yifan Hong0674a6e2020-10-22 14:37:01 -0700980
981 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
982
983else # my_installed_prebuilt_gki_apex not defined
984
Steve Muckle04b6f052020-08-09 14:36:56 -0700985# $1: boot image target
986# returns the kernel used to make the bootimage
987define bootimage-to-kernel
988 $(if $(BOARD_KERNEL_BINARIES),\
989 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
990 $(INSTALLED_KERNEL_TARGET))
991endef
992
Steve Muckle903a1ca2020-05-07 17:32:10 -0700993ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
994 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
995endif
996
997# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800998# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700999define get-bootimage-partition-size
Peter Collingbourne730200e2022-02-16 13:32:53 -08001000$(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
1001endef
1002
1003# $1: partition size
1004define get-partition-size-argument
1005 $(if $(1),--partition_size $(1),--dynamic_partition_size)
Steve Muckle903a1ca2020-05-07 17:32:10 -07001006endef
Chris Grossa784ef12019-04-22 11:09:57 -07001007
celeste wange3d43202022-08-12 08:36:37 +00001008ifndef BOARD_PREBUILT_BOOTIMAGE
1009
Chris Grossa784ef12019-04-22 11:09:57 -07001010ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001011INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -07001012 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001013
Bowgo Tsai85578e02022-04-19 10:50:59 +08001014# TODO(b/229701033): clean up BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK.
1015ifneq ($(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08001016 ifneq ($(BUILDING_INIT_BOOT_IMAGE),true)
1017 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
Devin Moore380d9e42021-11-04 19:01:19 +00001018 endif
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001019endif
1020
Steve Mucklee1b10862019-07-10 10:49:37 -07001021ifndef BUILDING_VENDOR_BOOT_IMAGE
1022ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1023 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1024endif
1025endif
1026
The Android Open Source Project88b60792009-03-03 19:28:42 -08001027INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
1028
Yifan Hong46aff092020-10-28 13:50:47 -07001029# kernel cmdline/base/pagesize in boot.
1030# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
1031# device-specific.
1032# - If not using GKI:
1033# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
1034# - Otherwise, put them in boot.
1035ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07001036 ifdef GENERIC_KERNEL_CMDLINE
1037 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1038 endif
Yifan Hong46aff092020-10-28 13:50:47 -07001039else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
1040 ifdef INTERNAL_KERNEL_CMDLINE
1041 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1042 endif
1043 ifdef BOARD_KERNEL_BASE
1044 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1045 endif
1046 ifdef BOARD_KERNEL_PAGESIZE
1047 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1048 endif
1049endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001050
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001051ifdef BOARD_GKI_SIGNING_KEY_PATH
1052 # GKI boot images will not set system version & SPL value in the header.
1053 # They can be set by the device manufacturer in the AVB properties instead.
1054 INTERNAL_MKBOOTIMG_VERSION_ARGS :=
1055else
1056 INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -07001057 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001058 --os_patch_level $(PLATFORM_SECURITY_PATCH)
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001059endif # BOARD_GKI_SIGNING_KEY_PATH
Sami Tolvanen3303d902016-03-15 16:49:30 +00001060
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001061# $(1): image target to certify
1062# $(2): out certificate target
1063# $(3): image name
1064# $(4): additional AVB arguments
1065define generate_generic_boot_image_certificate
1066 rm -rf "$(2)"
1067 mkdir -p "$(dir $(2))"
1068 $(GENERATE_GKI_CERTIFICATE) $(INTERNAL_GKI_CERTIFICATE_ARGS) \
1069 --additional_avb_args "$(4)" \
1070 --name "$(3)" --output "$(2)" "$(1)"
1071endef
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001072
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001073INTERNAL_GKI_CERTIFICATE_ARGS :=
1074INTERNAL_GKI_CERTIFICATE_DEPS :=
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001075ifdef BOARD_GKI_SIGNING_KEY_PATH
1076 ifndef BOARD_GKI_SIGNING_ALGORITHM
1077 $(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
1078 endif
1079
1080 INTERNAL_GKI_CERTIFICATE_ARGS := \
1081 --key "$(BOARD_GKI_SIGNING_KEY_PATH)" \
1082 --algorithm "$(BOARD_GKI_SIGNING_ALGORITHM)" \
1083 --avbtool "$(AVBTOOL)"
1084
1085 # Quote and pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string argument.
1086 ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
1087 INTERNAL_GKI_CERTIFICATE_ARGS += --additional_avb_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
1088 endif
1089
1090 INTERNAL_GKI_CERTIFICATE_DEPS := \
1091 $(GENERATE_GKI_CERTIFICATE) \
1092 $(BOARD_GKI_SIGNING_KEY_PATH) \
1093 $(AVBTOOL)
1094
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001095endif
1096
Chris Grossa784ef12019-04-22 11:09:57 -07001097# Define these only if we are building boot
1098ifdef BUILDING_BOOT_IMAGE
1099INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1100
The Android Open Source Project88b60792009-03-03 19:28:42 -08001101ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001102$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001103endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -04001104
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001105$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
1106
1107ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -04001108
Steve Muckle04b6f052020-08-09 14:36:56 -07001109# $1: boot image target
1110define build_boot_board_avb_enabled
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001111 $(eval kernel := $(call bootimage-to-kernel,$(1)))
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001112 $(MKBOOTIMG) --kernel $(kernel) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001113 $(if $(BOARD_GKI_SIGNING_KEY_PATH), \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001114 $(eval boot_signature := $(call intermediates-dir-for,PACKAGING,generic_boot)/$(notdir $(1)).boot_signature) \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001115 $(eval kernel_signature := $(call intermediates-dir-for,PACKAGING,generic_kernel)/$(notdir $(kernel)).boot_signature) \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001116 $(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 +08001117 $(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 +08001118 cat $(kernel_signature) >> $(boot_signature) $(newline) \
1119 $(call assert-max-image-size,$(boot_signature),16 << 10) $(newline) \
1120 truncate -s $$(( 16 << 10 )) $(boot_signature) $(newline) \
1121 cat "$(boot_signature)" >> $(1))
Yifan Hongebe65f82020-10-15 14:48:07 -07001122 $(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 -07001123 $(AVBTOOL) add_hash_footer \
1124 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001125 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) \
Steve Muckle04b6f052020-08-09 14:36:56 -07001126 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1127 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1128endef
1129
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001130$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001131 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001132 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -04001133
Bob Badoura60beee2022-09-07 15:34:12 -07001134$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08001135$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES) $(INTERNAL_GKI_CERTIFICATE_DEPS),$(PRODUCT_OUT)/:/)
1136
Justin Yundd15ec12022-09-23 10:47:21 +09001137UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001138
David Zeuthen0eb10972016-09-28 17:55:27 -04001139.PHONY: bootimage-nodeps
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001140bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001141 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001142 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001143
hungweichenb2dd6832022-08-08 09:16:30 +00001144else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # BOARD_AVB_ENABLE != true
David Riley17be3d32015-03-03 08:54:11 -08001145
Steve Muckle04b6f052020-08-09 14:36:56 -07001146# $1: boot image target
1147define build_boot_supports_vboot
1148 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
1149 $(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 -07001150 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001151endef
1152
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001153$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001154 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001155 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -08001156
Bob Badoura60beee2022-09-07 15:34:12 -07001157$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08001158$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1159
Justin Yundd15ec12022-09-23 10:47:21 +09001160UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001161
David Riley17be3d32015-03-03 08:54:11 -08001162.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001163bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001164 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001165 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -08001166
1167else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001168
Steve Muckle04b6f052020-08-09 14:36:56 -07001169# $1: boot image target
1170define build_boot_novboot
1171 $(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 -07001172 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001173endef
1174
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001175$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001176 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001177 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -07001178
Bob Badoura60beee2022-09-07 15:34:12 -07001179$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08001180$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1181
Justin Yundd15ec12022-09-23 10:47:21 +09001182UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001183
Ying Wangad7fd292013-08-08 16:34:29 -07001184.PHONY: bootimage-nodeps
1185bootimage-nodeps: $(MKBOOTIMG)
1186 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001187 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -07001188
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001189endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -07001190endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001191
Tao Baob1a2e352018-08-14 16:17:12 -07001192else # TARGET_NO_KERNEL == "true"
celeste wange3d43202022-08-12 08:36:37 +00001193INSTALLED_BOOTIMAGE_TARGET :=
1194endif # TARGET_NO_KERNEL
1195
1196else # BOARD_PREBUILT_BOOTIMAGE defined
Yifan Hong0674a6e2020-10-22 14:37:01 -07001197INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +09001198INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001199
1200ifeq ($(BOARD_AVB_ENABLE),true)
1201$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
1202 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1203 $(AVBTOOL) add_hash_footer \
1204 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001205 $(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001206 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1207 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001208
Bob Badoura60beee2022-09-07 15:34:12 -07001209$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",bool)
Bob Badourebdefc02022-02-12 15:39:22 -08001210$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_BOOTIMAGE),$(PRODUCT_OUT)/:/)
1211
Justin Yundd15ec12022-09-23 10:47:21 +09001212UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001213else
1214$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
1215 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1216endif # BOARD_AVB_ENABLE
1217
Tao Baob1a2e352018-08-14 16:17:12 -07001218endif # BOARD_PREBUILT_BOOTIMAGE
celeste wange3d43202022-08-12 08:36:37 +00001219
Yifan Hong0674a6e2020-10-22 14:37:01 -07001220endif # my_installed_prebuilt_gki_apex not defined
1221
1222my_apex_extracted_boot_image :=
1223my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001224
1225# -----------------------------------------------------------------
Devin Moore380d9e42021-11-04 19:01:19 +00001226# init boot image
1227ifeq ($(BUILDING_INIT_BOOT_IMAGE),true)
1228
1229INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1230$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_RAMDISK_TARGET)
1231
Yi-Yo Chiang8b0776d2022-06-30 17:33:29 +08001232INTERNAL_INIT_BOOT_IMAGE_ARGS := --ramdisk $(INSTALLED_RAMDISK_TARGET)
1233
Devin Moore380d9e42021-11-04 19:01:19 +00001234ifdef BOARD_KERNEL_PAGESIZE
1235 INTERNAL_INIT_BOOT_IMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1236endif
1237
1238ifeq ($(BOARD_AVB_ENABLE),true)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08001239$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
Devin Moore380d9e42021-11-04 19:01:19 +00001240 $(call pretty,"Target init_boot image: $@")
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001241 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output "$@"
Devin Moore380d9e42021-11-04 19:01:19 +00001242 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
1243 $(AVBTOOL) add_hash_footer \
1244 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001245 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001246 --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1247 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001248
1249$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1250$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_GENERIC_RAMDISK_BOOT_SIGNATURE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001251else
1252$(INSTALLED_INIT_BOOT_IMAGE_TARGET):
1253 $(call pretty,"Target init_boot image: $@")
1254 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output $@
1255 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
Bob Badourebdefc02022-02-12 15:39:22 -08001256
1257$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001258endif
1259
Justin Yundd15ec12022-09-23 10:47:21 +09001260UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001261
Devin Moore380d9e42021-11-04 19:01:19 +00001262else # BUILDING_INIT_BOOT_IMAGE is not true
1263
1264ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
1265INTERNAL_PREBUILT_INIT_BOOT_IMAGE := $(BOARD_PREBUILT_INIT_BOOT_IMAGE)
1266INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1267
1268ifeq ($(BOARD_AVB_ENABLE),true)
1269$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
1270 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
1271 $(AVBTOOL) add_hash_footer \
1272 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001273 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001274 --partition_name boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1275 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001276
1277$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1278$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_PREBUILT_INIT_BOOT_IMAGE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001279else
1280$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE)
1281 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
Bob Badourebdefc02022-02-12 15:39:22 -08001282
1283$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001284endif # BOARD_AVB_ENABLE
1285
Justin Yundd15ec12022-09-23 10:47:21 +09001286UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001287
Devin Moore380d9e42021-11-04 19:01:19 +00001288else # BOARD_PREBUILT_INIT_BOOT_IMAGE not defined
1289INSTALLED_INIT_BOOT_IMAGE_TARGET :=
1290endif # BOARD_PREBUILT_INIT_BOOT_IMAGE
1291
1292endif # BUILDING_INIT_BOOT_IMAGE is not true
Ramji Jiyani10655232022-01-20 06:43:09 +00001293
1294# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001295# vendor boot image
Colin Cross79a76ec2022-03-21 15:06:11 -07001296INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Steve Mucklee1b10862019-07-10 10:49:37 -07001297ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1298
Steve Mucklee1b10862019-07-10 10:49:37 -07001299INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
Steve Mucklee1b10862019-07-10 10:49:37 -07001300 $(ALL_DEFAULT_INSTALLED_MODULES))
1301
Petri Gynther6a6d6212021-03-06 00:45:53 -08001302INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001303
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001304# Exclude recovery files in the default vendor ramdisk if including a standalone
1305# recovery ramdisk in vendor_boot.
Yifan Hong881df392020-10-09 14:29:39 -07001306ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001307ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
Yifan Hong881df392020-10-09 14:29:39 -07001308$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1309$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1310endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001311endif
Yifan Hong881df392020-10-09 14:29:39 -07001312
J. Avila3f6560e2020-05-11 20:20:03 +00001313$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001314 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001315
Petri Gynther828828b2021-03-04 11:04:03 -08001316INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1317$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08001318 @echo "Target vendor ramdisk: $@"
Petri Gynther828828b2021-03-04 11:04:03 -08001319 $(copy-file-to-target)
Petri Gynther828828b2021-03-04 11:04:03 -08001320
Bob Badourebdefc02022-02-12 15:39:22 -08001321$(call declare-1p-container,$(INSTALLED_VENDOR_RAMDISK_TARGET),)
1322$(call declare-container-license-deps,$(INSTALLED_VENDOR_RAMDISK_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
1323
1324VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_RAMDISK_TARGET)
1325
Petri Gynther6ff52012020-11-20 11:59:41 -08001326INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1327INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1328$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1329$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1330$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001331 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001332 mkdir -p $(dir $@)
1333 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001334 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1335 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001336
Bob Badourebdefc02022-02-12 15:39:22 -08001337$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07001338$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08001339
Steve Mucklee1b10862019-07-10 10:49:37 -07001340ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Lucas Weif57333f2022-02-24 10:30:15 +08001341 ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1342 # If we have vendor_kernel_boot partition, we migrate dtb image to that image
1343 # and allow dtb in vendor_boot to be empty.
1344 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1345 endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001346endif
1347ifdef BOARD_KERNEL_BASE
1348 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1349endif
1350ifdef BOARD_KERNEL_PAGESIZE
1351 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1352endif
1353ifdef INTERNAL_KERNEL_CMDLINE
1354 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1355endif
1356
Devin Moore50509012021-01-13 10:45:04 -08001357ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001358 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1359 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001360 rm -f $@
1361 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1362 printf "%s\n" $(param) >> $@;)
1363 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1364endif
1365
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001366# $(1): Build target name
1367# $(2): Staging dir to be compressed
1368# $(3): Build dependencies
1369define build-vendor-ramdisk-fragment-target
1370$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1371 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1372endef
1373
1374# $(1): Ramdisk name
1375define build-vendor-ramdisk-fragment
1376$(strip \
1377 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1378 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1379 $(build_target) \
1380)
1381endef
1382
1383# $(1): Ramdisk name
1384# $(2): Prebuilt file path
1385define build-prebuilt-vendor-ramdisk-fragment
1386$(strip \
1387 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1388 $(eval $(call copy-one-file,$(2),$(build_target))) \
1389 $(build_target) \
1390)
1391endef
1392
1393INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1394INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1395
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001396$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001397 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1398 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1399 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1400 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001401 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001402 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1403 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1404)
1405
Steve Mucklee1b10862019-07-10 10:49:37 -07001406INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1407$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001408$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001409ifeq ($(BOARD_AVB_ENABLE),true)
1410$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1411 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001412 $(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 -07001413 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1414 $(AVBTOOL) add_hash_footer \
1415 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001416 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Steve Mucklee1b10862019-07-10 10:49:37 -07001417 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1418 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1419else
1420$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1421 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001422 $(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 -07001423 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1424endif
Bob Badourebdefc02022-02-12 15:39:22 -08001425
1426$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
1427$(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)/:/)
1428VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001429endif # BUILDING_VENDOR_BOOT_IMAGE
1430
1431# -----------------------------------------------------------------
Lucas Weif57333f2022-02-24 10:30:15 +08001432# vendor kernel boot image
1433ifeq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1434
1435INTERNAL_VENDOR_KERNEL_RAMDISK_FILES := $(filter $(TARGET_VENDOR_KERNEL_RAMDISK_OUT)/%, \
Lucas Weif57333f2022-02-24 10:30:15 +08001436 $(ALL_DEFAULT_INSTALLED_MODULES))
1437
1438INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_kernel_boot)/vendor_kernel_ramdisk.cpio$(RAMDISK_EXT)
1439
1440$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
1441 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
1442
1443INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_kernel_ramdisk.img
1444$(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1445 @echo "Target vendor kernel ramdisk: $@"
1446 $(copy-file-to-target)
1447
1448INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-kernel-ramdisk.txt
1449INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK:.txt=.json)
1450$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK)
1451$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1452$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
1453 @echo Installed file list: $@
1454 mkdir -p $(dir $@)
1455 rm -f $@
1456 $(FILESLIST) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) > $(@:.txt=.json)
1457 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
1458
Bob Badour5acd4362022-04-12 18:31:35 -07001459$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK))
1460$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK))
1461
Lucas Weif57333f2022-02-24 10:30:15 +08001462INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS := --vendor_ramdisk $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1463INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_kernel_boot.img
1464$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1465
1466ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1467 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1468 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
1469endif
1470ifdef BOARD_KERNEL_PAGESIZE
1471 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1472endif
1473
1474
1475ifeq ($(BOARD_AVB_ENABLE),true)
1476$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_KERNEL_BOOTIMAGE_KEY_PATH)
1477 $(call pretty,"Target vendor_kernel_boot image: $@")
1478 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1479 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1480 $(AVBTOOL) add_hash_footer \
1481 --image $@ \
1482 $(call get-partition-size-argument,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)) \
1483 --partition_name vendor_kernel_boot $(INTERNAL_AVB_VENDOR_KERNEL_BOOT_SIGNING_ARGS) \
1484 $(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)
1485else
1486$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):
1487 $(call pretty,"Target vendor_kernel_boot image: $@")
1488 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1489 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1490endif
Bob Badour5acd4362022-04-12 18:31:35 -07001491$(call declare-1p-container,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
1492ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1493$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),\
1494 $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET),\
1495 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1496else
1497$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET),$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1498endif
Lucas Weif57333f2022-02-24 10:30:15 +08001499endif # BUILDING_VENDOR_KERNEL_BOOT_IMAGE
1500
1501# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001502# NOTICE files
1503#
Steve Blockd14d3b42012-03-01 11:34:41 +00001504# We are required to publish the licenses for all code under BSD, GPL and
1505# Apache licenses (and possibly other more exotic ones as well). We err on the
1506# side of caution, so the licenses for other third-party code are included here
1507# too.
1508#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001509# This needs to be before the systemimage rules, because it adds to
1510# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1511# go into the systemimage.
1512
Steve Block495e5852012-02-29 19:18:08 +00001513.PHONY: notice_files
1514
Bob Badourebdefc02022-02-12 15:39:22 -08001515# Convert license metadata into xml notice file.
1516# $(1) - Output target notice filename
1517# $(2) - Product name
1518# $(3) - File title
1519# $(4) - License metadata file roots
1520# $(5) - Prefixes to strip
1521#
1522define xml-notice-rule
1523$(1): PRIVATE_PRODUCT := $(2)
1524$(1): PRIVATE_MESSAGE := $(3)
Bob Badour5acd4362022-04-12 18:31:35 -07001525$(1): PRIVATE_DEPS := $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001526$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badour5acd4362022-04-12 18:31:35 -07001527 OUT_DIR=$(OUT_DIR) $(XMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $$(PRIVATE_DEPS)
Bob Badourebdefc02022-02-12 15:39:22 -08001528
1529notice_files: $(1)
1530endef
1531
1532# Convert license metadata into text notice file.
1533# $(1) - Output target notice filename
1534# $(2) - Product name
1535# $(3) - File title
1536# $(4) - License metadata file roots
1537# $(5) - Prefixes to strip
1538#
1539define text-notice-rule
1540$(1): PRIVATE_PRODUCT := $(2)
1541$(1): PRIVATE_MESSAGE := $(3)
1542$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001543 OUT_DIR=$(OUT_DIR) $(TEXTNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001544
1545notice_files: $(1)
1546endef
1547
1548# Conversion license metadata into html notice file.
1549# $(1) - Output target notice filename
1550# $(2) - Product name
1551# $(3) - File title
1552# $(4) - License metadata file roots
1553# $(5) - Prefixes to strip
1554#
1555define html-notice-rule
1556$(1): PRIVATE_PRODUCT := $(2)
1557$(1): PRIVATE_MESSAGE := $(3)
1558$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001559 OUT_DIR=$(OUT_DIR) $(HTMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001560
1561notice_files: $(1)
1562endef
1563
Bob Badour6259a092022-03-23 23:28:40 -07001564$(KATI_obsolete_var combine-notice-files, To create notice files use xml-notice-rule, html-notice-rule, or text-notice-rule.)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001565
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001566# Notice file logic isn't relevant for TARGET_BUILD_APPS
1567ifndef TARGET_BUILD_APPS
1568
The Android Open Source Project88b60792009-03-03 19:28:42 -08001569# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1570# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1571# the src subdirectory.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001572kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001573
Bob Badour4b25c902020-01-28 13:23:39 -08001574# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1575# reasons--not to be flashed onto any device. Targets under these directories
1576# need no associated notice file on the device UI.
1577exclude_target_dirs := apex
1578
Steven Morelandae69e572017-12-15 14:49:55 -08001579# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001580ifneq ($(PRODUCT_NOTICE_SPLIT),true)
Bob Badourebdefc02022-02-12 15:39:22 -08001581#target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001582target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1583installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Bob Badour879cfa82021-04-15 10:41:38 -07001584
1585$(call declare-0p-target,$(target_notice_file_html_gz))
1586$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001587else
Bob Badourebdefc02022-02-12 15:39:22 -08001588# target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001589target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001590installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1591
1592target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001593target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1594installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001595
1596target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
Dario Freniadc972d2018-07-09 18:38:38 +01001597target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1598installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001599
Justin Yun6151e3f2019-06-25 15:58:13 +09001600target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
Justin Yun6151e3f2019-06-25 15:58:13 +09001601target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1602installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001603
Chris Gross15d96552019-07-16 14:38:43 -07001604target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
Chris Gross15d96552019-07-16 14:38:43 -07001605target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1606installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1607
Yifan Hong3d3f0302020-05-11 18:35:11 -07001608target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
Yifan Hong3d3f0302020-05-11 18:35:11 -07001609target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1610installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1611
Yifan Hongc83f9e92020-07-15 16:57:47 -07001612target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
Yifan Hongc83f9e92020-07-15 16:57:47 -07001613target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1614installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1615
Ramji Jiyani13a41372022-01-27 07:05:08 +00001616target_system_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.txt
Ramji Jiyani13a41372022-01-27 07:05:08 +00001617target_system_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.xml.gz
1618installed_system_dlkm_notice_xml_gz := $(TARGET_OUT_SYSTEM_DLKM)/etc/NOTICE.xml.gz
1619
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001620# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1621# being built. A notice xml file must depend on all modules that could potentially
1622# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001623license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001624# Only files copied to a system image need system image notices.
1625license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001626# Phonys/fakes don't have notice files (though their deps might)
1627license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001628# testcases are not relevant to the system image.
1629license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001630# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001631license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001632# system_other is relevant to system partition.
1633license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001634license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1635license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001636license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001637license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001638license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001639license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001640license_modules_odm_dlkm := $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001641license_modules_agg := $(license_modules_system) \
1642 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001643 $(license_modules_product) \
1644 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001645 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001646 $(license_modules_vendor_dlkm) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001647 $(license_modules_odm_dlkm) \
1648 $(license_modules_system_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001649# targets used for debug symbols only and do not get copied to the device
1650license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1651
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001652license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001653license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1654
1655# Identify the other targets we expect to have notices for:
1656# targets copied to the device but are not readable by the UI (e.g. must boot
1657# into a different partition to read or don't have an associated /etc
1658# directory) must have their notices built somewhere readable.
1659license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1660license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1661license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1662license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1663license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1664license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001665license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001666license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1667license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1668license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1669license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1670license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1671license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1672
1673# after removing targets in system images, targets reported in system images, and
1674# targets used for debug symbols that do not need notices, nothing must remain.
1675license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1676$(call maybe-print-list-and-error, $(license_modules_rest), \
1677 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001678
Chris Grossaad39b32019-06-13 09:43:26 -07001679# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1680# update its notice file, so include those notices in the system partition instead
1681ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001682license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001683system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1684system_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 -07001685else
Bob Badour4b25c902020-01-28 13:23:39 -08001686license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001687system_xml_directories := xml_system
1688system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001689endif
1690
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001691endif # PRODUCT_NOTICE_SPLIT
1692
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001693ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001694
Bob Badour56e0de52022-08-02 17:46:48 +00001695need_vendor_notice:=false
1696ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1697 need_vendor_notice:=true
1698endif
1699
1700ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
1701 need_vendor_notice:=true
1702endif
1703
1704ifdef BUILDING_VENDOR_IMAGE
1705 need_vendor_notice:=true
1706endif
1707
1708ifeq (true,$(need_vendor_notice))
1709ifneq (,$(installed_vendor_notice_xml_gz))
1710ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1711endif
1712endif
1713
1714need_vendor_notice:=
1715
1716ifdef BUILDING_ODM_IMAGE
1717ifneq (,$(installed_odm_notice_xml_gz))
1718ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
1719endif
1720endif
1721
1722ifdef BUILDING_PRODUCT_IMAGE
1723ifneq (,$(installed_product_notice_xml_gz))
1724ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1725endif
1726endif
1727
1728ifdef BUILDING_SYSTEM_EXT_IMAGE
1729ifneq (,$(installed_system_ext_notice_xml_gz))
1730ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1731endif
1732endif
1733
1734ifdef BUILDING_VENDOR_DLKM_IMAGE
1735ifneq (,$(installed_vendor_dlkm_notice_xml_gz)
1736ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
1737endif
1738endif
1739
1740ifdef BUILDING_ODM_DLKM_IMAGE
1741ifneq (,$(installed_odm_dlkm_notice_xml_gz))
1742ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
1743endif
1744endif
1745
1746ifdef BUILDING_SYSTEM_DLKM_IMAGE
1747ifneq (,$(installed_system_dlkm_notice_xml_gz))
1748ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_dlkm_notice_xml_gz)
1749endif
1750endif
1751
Ying Wang62c81f82013-08-22 20:02:03 -07001752endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001753
Bob Badoura60beee2022-09-07 15:34:12 -07001754# Presently none of the prebuilts etc. comply with policy to have a license text. Fake one here.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001755$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001756
Bob Badoura60beee2022-09-07 15:34:12 -07001757ifneq (,$(strip $(INSTALLED_KERNEL_TARGET)))
1758$(call declare-license-metadata,$(INSTALLED_KERNEL_TARGET),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
1759endif
Bob Badourebdefc02022-02-12 15:39:22 -08001760
Bob Badoura60beee2022-09-07 15:34:12 -07001761# No matter where it gets copied from, a copied linux kernel is licensed under "GPL 2.0 only"
1762$(eval $(call declare-copy-files-license-metadata,,:kernel,SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,kernel))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001763
Doug Zongker8678df42009-06-15 14:30:14 -07001764
The Android Open Source Project88b60792009-03-03 19:28:42 -08001765# #################################################################
1766# Targets for user images
1767# #################################################################
1768
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001769# These options tell the recovery updater/installer how to mount the partitions writebale.
1770# <fstype>=<fstype_opts>[|<fstype_opts>]...
1771# fstype_opts := <opt>[,<opt>]...
1772# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001773# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1774DEFAULT_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 -07001775
Tao Baodba635a2019-06-24 10:39:54 -07001776INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001777 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001778 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001779 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001780
Bob Badour2f66fd12022-03-09 17:30:24 -08001781$(call declare-1p-target,$(MKE2FS_CONF),system/extras)
1782
Tao Baodba635a2019-06-24 10:39:54 -07001783ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1784INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001785endif
1786
Yifan Hongcfb917a2020-05-07 14:58:20 -07001787ifneq ($(filter \
1788 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1789 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1790 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1791 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1792 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1793 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001794 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001795 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001796 ,erofs),)
David Anderson94ad5bb2022-03-04 10:57:58 -08001797INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
David Andersonf54665f2022-03-04 14:42:18 -08001798ifeq ($(BOARD_EROFS_USE_LEGACY_COMPRESSION),true)
1799BOARD_EROFS_COMPRESSOR ?= "lz4"
1800else
Kelvin Zhang37d49292021-12-01 14:21:24 -08001801BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
Gao Xiang961041a2020-06-17 13:59:16 +08001802endif
David Andersonf54665f2022-03-04 14:42:18 -08001803endif
Gao Xiang961041a2020-06-17 13:59:16 +08001804
1805ifneq ($(filter \
1806 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1807 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1808 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1809 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1810 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1811 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1812 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001813 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001814 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001815INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1816endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001817
Tao Baodba635a2019-06-24 10:39:54 -07001818ifeq ($(BOARD_AVB_ENABLE),true)
1819INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1820endif
1821
1822# Get a colon-separated list of search paths.
1823INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1824
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001825# Collects file_contexts files from modules to be installed
1826$(call merge-fc-files, \
1827 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1828 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1829
Alex Klyubin092c9022017-03-13 13:28:34 -07001830SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001831
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001832INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1833
David Anderson707e6f52021-09-21 22:24:43 -07001834# $(1) the partition name (eg system)
1835# $(2) the image prop file
1836define add-common-flags-to-image-props
1837$(eval _var := $(call to-upper,$(1)))
1838$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
1839$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
1840endef
1841
1842# $(1) the partition name (eg system)
1843# $(2) the image prop file
1844define add-common-ro-flags-to-image-props
1845$(eval _var := $(call to-upper,$(1)))
David Anderson64b351b2021-10-13 00:20:43 -07001846$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001847$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESS_HINTS),$(hide) echo "$(1)_erofs_compress_hints=$(BOARD_$(_var)IMAGE_EROFS_COMPRESS_HINTS)" >> $(2))
David Anderson64b351b2021-10-13 00:20:43 -07001848$(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 -07001849$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
1850$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
1851$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
1852$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
1853$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
1854$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
1855$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
1856$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
1857$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
1858$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
1859$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
1860$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
1861$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
1862$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
1863$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
1864$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
David Anderson5f4aa6c2021-09-23 17:03:14 -07001865$(if $(or $(_size), $(_reserved), $(_headroom)),,
1866 $(hide) echo "$(1)_disable_sparse=true" >> $(2))
David Anderson707e6f52021-09-21 22:24:43 -07001867$(call add-common-flags-to-image-props,$(1),$(2))
David Anderson9e95a022021-08-31 21:32:45 -07001868endef
1869
Ying Wangbd93d422011-10-28 17:02:30 -07001870# $(1): the path of the output dictionary file
Ramji Jiyani13a41372022-01-27 07:05:08 +00001871# $(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 -07001872# $(3): additional "key=value" pairs to append to the dictionary file.
1873define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001874$(if $(filter $(2),system),\
Bowgo Tsai867ab662019-01-29 13:30:18 +08001875 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001876 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001877 $(call add-common-ro-flags-to-image-props,system,$(1))
Chris Gross203191b2020-05-30 02:39:12 +00001878)
1879$(if $(filter $(2),system_other),\
1880 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
David Anderson9e95a022021-08-31 21:32:45 -07001881 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
1882 $(hide) echo "system_other_disable_sparse=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001883)
Yifan Hong760d3c02018-05-30 11:16:46 -07001884$(if $(filter $(2),userdata),\
1885 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1886 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001887 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1888 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kim55c16dd2020-10-12 19:50:05 -07001889 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001890 $(call add-common-flags-to-image-props,userdata,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001891)
Yifan Hong760d3c02018-05-30 11:16:46 -07001892$(if $(filter $(2),cache),\
1893 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1894 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001895 $(call add-common-flags-to-image-props,cache,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001896)
1897$(if $(filter $(2),vendor),\
David Anderson707e6f52021-09-21 22:24:43 -07001898 $(call add-common-ro-flags-to-image-props,vendor,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001899)
1900$(if $(filter $(2),product),\
David Anderson707e6f52021-09-21 22:24:43 -07001901 $(call add-common-ro-flags-to-image-props,product,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001902)
Justin Yun6151e3f2019-06-25 15:58:13 +09001903$(if $(filter $(2),system_ext),\
David Anderson707e6f52021-09-21 22:24:43 -07001904 $(call add-common-ro-flags-to-image-props,system_ext,$(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001905)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001906$(if $(filter $(2),odm),\
David Anderson707e6f52021-09-21 22:24:43 -07001907 $(call add-common-ro-flags-to-image-props,odm,$(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001908)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001909$(if $(filter $(2),vendor_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001910 $(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001911)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001912$(if $(filter $(2),odm_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001913 $(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001914)
Ramji Jiyani13a41372022-01-27 07:05:08 +00001915$(if $(filter $(2),system_dlkm),\
1916 $(call add-common-ro-flags-to-image-props,system_dlkm,$(1))
1917)
Yifan Hong760d3c02018-05-30 11:16:46 -07001918$(if $(filter $(2),oem),\
1919 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1920 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1921 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1922 $(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 -07001923 $(call add-common-flags-to-image-props,oem,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001924)
Tao Bao3602eca2018-07-10 10:53:55 -07001925$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001926
Cole Faust8fc7bef2022-06-15 16:10:49 -07001927$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT2)),$(hide) echo "fs_type=ext2" >> $(1),
1928 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT3)),$(hide) echo "fs_type=ext3" >> $(1),
1929 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT4)),$(hide) echo "fs_type=ext4" >> $(1))))
1930
1931$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)),,$(hide) echo "extfs_sparse_flag=-s" >> $(1))
1932$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED)),,$(hide) echo "erofs_sparse_flag=-s" >> $(1))
1933$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)),,$(hide) echo "squashfs_sparse_flag=-s" >> $(1))
1934$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)),,$(hide) echo "f2fs_sparse_flag=-S" >> $(1))
David Anderson40a821f2021-09-22 18:02:01 -07001935$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001936$(if $(BOARD_EROFS_COMPRESS_HINTS),$(hide) echo "erofs_default_compress_hints=$(BOARD_EROFS_COMPRESS_HINTS)" >> $(1))
David Anderson64b351b2021-10-13 00:20:43 -07001937$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
1938$(if $(BOARD_EROFS_SHARE_DUP_BLOCKS),$(hide) echo "erofs_share_dup_blocks=$(BOARD_EROFS_SHARE_DUP_BLOCKS)" >> $(1))
David Andersonf54665f2022-03-04 14:42:18 -08001939$(if $(BOARD_EROFS_USE_LEGACY_COMPRESSION),$(hide) echo "erofs_use_legacy_compression=$(BOARD_EROFS_USE_LEGACY_COMPRESSION)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001940$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1941$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1942$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001943$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001944$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1945$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1946$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001947$(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 -07001948$(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 -07001949$(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 +00001950$(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 +00001951$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1952$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1953$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1954$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1955$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001956$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001957$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1958$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1959$(if $(BOARD_AVB_ENABLE),\
1960 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1961 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1962 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1963 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001964$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1965$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1966$(if $(BOARD_AVB_ENABLE),\
1967 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1968 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001969 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001970$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1971$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1972$(if $(BOARD_AVB_ENABLE),\
1973 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1974 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1975 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1976 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001977$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1978$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1979$(if $(BOARD_AVB_ENABLE),\
1980 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1981 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1982 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1983 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001984$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001985$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001986 $(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 +01001987$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001988 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1989 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1990 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1991 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001992$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1993$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1994$(if $(BOARD_AVB_ENABLE),\
1995 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1996 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1997 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1998 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001999$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2000$(if $(BOARD_AVB_ENABLE),\
2001 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2002$(if $(BOARD_AVB_ENABLE),\
2003 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
2004 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
2005 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
2006 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002007$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2008$(if $(BOARD_AVB_ENABLE),\
2009 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2010$(if $(BOARD_AVB_ENABLE),\
2011 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
2012 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
2013 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
2014 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Ramji Jiyani13a41372022-01-27 07:05:08 +00002015$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2016$(if $(BOARD_AVB_ENABLE),\
2017 $(hide) echo "avb_system_dlkm_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2018$(if $(BOARD_AVB_ENABLE),\
2019 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
2020 $(hide) echo "avb_system_dlkm_key_path=$(BOARD_AVB_SYSTEM_DLKM_KEY_PATH)" >> $(1)
2021 $(hide) echo "avb_system_dlkm_algorithm=$(BOARD_AVB_SYSTEM_DLKM_ALGORITHM)" >> $(1)
2022 $(hide) echo "avb_system_dlkm_rollback_index_location=$(BOARD_SYSTEM_SYSTEM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002023$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
2024 $(hide) echo "recovery_as_boot=true" >> $(1))
Bowgo Tsai85578e02022-04-19 10:50:59 +08002025$(if $(filter true,$(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK)),\
2026 $(hide) echo "gki_boot_image_without_ramdisk=true" >> $(1))
Tom Cherryd14b8952018-08-09 14:26:00 -07002027$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01002028$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
2029 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07002030$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
2031endef
2032
2033# $(1): the path of the output dictionary file
2034# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07002035PROP_DICTIONARY_IMAGES := oem
2036ifdef BUILDING_CACHE_IMAGE
2037 PROP_DICTIONARY_IMAGES += cache
2038endif
2039ifdef BUILDING_SYSTEM_IMAGE
2040 PROP_DICTIONARY_IMAGES += system
2041endif
Chris Gross203191b2020-05-30 02:39:12 +00002042ifdef BUILDING_SYSTEM_OTHER_IMAGE
2043 PROP_DICTIONARY_IMAGES += system_other
2044endif
Daniel Norman72c626f2019-05-13 15:58:14 -07002045ifdef BUILDING_USERDATA_IMAGE
2046 PROP_DICTIONARY_IMAGES += userdata
2047endif
2048ifdef BUILDING_VENDOR_IMAGE
2049 PROP_DICTIONARY_IMAGES += vendor
2050endif
2051ifdef BUILDING_PRODUCT_IMAGE
2052 PROP_DICTIONARY_IMAGES += product
2053endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002054ifdef BUILDING_SYSTEM_EXT_IMAGE
2055 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07002056endif
2057ifdef BUILDING_ODM_IMAGE
2058 PROP_DICTIONARY_IMAGES += odm
2059endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002060ifdef BUILDING_VENDOR_DLKM_IMAGE
2061 PROP_DICTIONARY_IMAGES += vendor_dlkm
2062endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07002063ifdef BUILDING_ODM_DLKM_IMAGE
2064 PROP_DICTIONARY_IMAGES += odm_dlkm
2065endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00002066ifdef BUILDING_SYSTEM_DLKM_IMAGE
2067 PROP_DICTIONARY_IMAGES += system_dlkm
2068endif
Yifan Hong760d3c02018-05-30 11:16:46 -07002069define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07002070 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07002071endef
2072
Yifan Hongbbcba1e2018-06-18 16:32:35 -07002073# $(1): the path of the input dictionary file, where each line has the format key=value
2074# $(2): the key to look up
2075define read-image-prop-dictionary
2076$$(grep '$(2)=' $(1) | cut -f2- -d'=')
2077endef
2078
The Android Open Source Project88b60792009-03-03 19:28:42 -08002079# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07002080# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07002081
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002082# Recovery image exists if we are building recovery, or building recovery as boot.
Colin Cross79a76ec2022-03-21 15:06:11 -07002083INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RECOVERY_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Chris Grossa784ef12019-04-22 11:09:57 -07002084ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002085
Ying Wang37526142015-03-10 12:02:57 -07002086INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
2087 $(ALL_DEFAULT_INSTALLED_MODULES))
2088
Tao Bao10fc9492018-08-14 12:17:48 -07002089INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
2090INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
2091
Colin Cross359f4212020-12-02 15:14:04 -08002092ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2093INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
2094endif
2095
Tao Bao10fc9492018-08-14 12:17:48 -07002096# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
2097# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
2098# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
2099# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08002100$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07002101
2102$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002103$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07002104 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002105 mkdir -p $(dir $@)
2106 rm -f $@
2107 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
2108 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07002109
Bob Badour5acd4362022-04-12 18:31:35 -07002110$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RECOVERY)))
2111$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RECOVERY)))
2112
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002113recovery_sepolicy := \
2114 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07002115 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002116 $(TARGET_RECOVERY_ROOT_OUT)/plat_service_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002117 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002118 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002119 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_service_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002120 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
2121 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002122 $(TARGET_RECOVERY_ROOT_OUT)/vendor_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002123 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08002124 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002125 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
2126 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002127 $(TARGET_RECOVERY_ROOT_OUT)/product_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002128 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08002129
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002130# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
2131# SELinux files
2132IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
2133
Steve Muckle04b6f052020-08-09 14:36:56 -07002134# if building multiple boot images from multiple kernels, use the first kernel listed
2135# for the recovery image
2136recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002137recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07002138recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08002139
Anton Hansson45a40da2019-01-18 14:06:34 +00002140# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
2141# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
2142# which get remapped to a bucket.
2143recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07002144ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
2145recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00002146# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07002147# ------160------240------320----------480------------640------
2148# mdpi hdpi xhdpi xxhdpi xxxhdpi
2149recovery_density := $(strip \
2150 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
2151 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
2152 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
2153 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07002154endif
2155
2156ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
2157recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
2158else
Doug Zongker25d55f82014-04-04 13:51:15 -07002159recovery_resources_common := $(recovery_resources_common)-xhdpi
2160endif
2161
Tao Baoe1e829e2018-08-29 20:36:00 -07002162# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
2163# Note that the font selected here can be overridden for a particular device by putting a font.png
2164# in its private recovery resources.
2165ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07002166recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08002167else
Dan Willemsen97672232020-05-27 00:09:16 -07002168recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08002169endif
2170
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002171
2172# We will only generate the recovery background text images if the variable
2173# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
2174# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
2175# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
2176# BoardConfig in order to use this feature.
2177ifeq ($(recovery_density),xxxhdpi)
2178TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
2179else ifeq ($(recovery_density),xxhdpi)
2180TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
2181endif
2182
2183ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
2184# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
2185ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
2186 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
2187else
2188 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
2189endif
2190
2191
Dan Willemsen97672232020-05-27 00:09:16 -07002192RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002193RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
2194RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
2195RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
2196RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
2197
xunchangcc57d312018-12-07 12:12:17 -08002198RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
2199RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
2200RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
2201RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
2202RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
2203
2204generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002205 $(RECOVERY_INSTALLING_TEXT_FILE) \
2206 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
2207 $(RECOVERY_ERASING_TEXT_FILE) \
2208 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08002209 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
2210 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
2211 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
2212 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
2213 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
2214 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002215
Dan Willemsen97672232020-05-27 00:09:16 -07002216resource_dir := bootable/recovery/tools/recovery_l10n/res/
2217resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002218image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08002219zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002220$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07002221$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002222$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
2223$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08002224$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002225$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08002226$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002227 recovery_installing \
2228 recovery_installing_security \
2229 recovery_erasing \
2230 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08002231 recovery_no_command
2232$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002233 recovery_cancel_wipe_data \
2234 recovery_factory_data_reset \
2235 recovery_try_again \
2236 recovery_wipe_data_menu_header \
2237 recovery_wipe_data_confirmation
2238$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07002239$(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 -08002240 # Prepares the font directory.
2241 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
2242 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08002243 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002244 @rm -rf $(dir $@)
2245 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08002246 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08002247 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08002248 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002249 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
2250 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
2251 --text_name $(text_name) \
2252 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2253 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002254 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002255 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002256else
2257RECOVERY_INSTALLING_TEXT_FILE :=
2258RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2259RECOVERY_ERASING_TEXT_FILE :=
2260RECOVERY_ERROR_TEXT_FILE :=
2261RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002262RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2263RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2264RECOVERY_TRY_AGAIN_TEXT_FILE :=
2265RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2266RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002267endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2268
Ying Wang9a175682015-08-06 11:47:47 -07002269ifndef TARGET_PRIVATE_RES_DIRS
2270TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2271endif
Doug Zongker4647f122009-07-02 09:00:54 -07002272recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002273 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002274recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002275
2276
Andrew Boiefa61ff02012-09-28 09:33:45 -07002277ifdef TARGET_RECOVERY_FSTAB
2278recovery_fstab := $(TARGET_RECOVERY_FSTAB)
Cole Faust64c2ddb2022-01-07 12:44:31 -08002279else ifdef TARGET_RECOVERY_FSTAB_GENRULE
2280# Specifies a soong genrule module that generates an fstab.
2281recovery_fstab := $(call intermediates-dir-for,ETC,$(TARGET_RECOVERY_FSTAB_GENRULE))/$(TARGET_RECOVERY_FSTAB_GENRULE)
Andrew Boiefa61ff02012-09-28 09:33:45 -07002282else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002283recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002284endif
Tao Baoc3c17532016-06-10 10:11:54 -07002285ifdef TARGET_RECOVERY_WIPE
2286recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002287else
Tao Baoc3c17532016-06-10 10:11:54 -07002288recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002289endif
Tao Bao8beab692015-07-22 12:33:18 -07002290
Tao Bao6d5d6232018-03-09 17:04:42 -08002291# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002292# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002293# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2294# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002295#
2296# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002297# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002298# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002299# b) We build a single image that contains boot and recovery both - no recovery image to install
2300# (BOARD_USES_RECOVERY_AS_BOOT = true);
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002301# c) We include the recovery DTBO image within recovery - not needing the resource file as we
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002302# do bsdiff because boot and recovery will contain different number of entries
2303# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002304# d) We include the recovery ACPIO image within recovery - not needing the resource file as we
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002305# do bsdiff because boot and recovery will contain different number of entries
2306# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002307# e) We build a single image that contains vendor_boot and recovery both - no recovery image to
Yifan Hongef7a9712020-10-20 13:17:42 -07002308# install
2309# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002310
Tom Cherry2929cad2018-09-20 11:04:37 -07002311ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002312 $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002313 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002314# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002315RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2316ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002317else
Tao Bao8beab692015-07-22 12:33:18 -07002318RECOVERY_RESOURCE_ZIP :=
2319endif
Doug Zongker4647f122009-07-02 09:00:54 -07002320
Tao Bao139c7272018-07-31 13:26:54 -07002321INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2322
2323$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002324 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2325 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2326 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2327 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2328 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2329 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2330 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2331 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2332
2333# Parses the given list of build variables and writes their values as build properties if defined.
2334# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2335# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2336# $(1): Map from the build variable names to property names
2337# $(2): Output file
2338define append-recovery-ui-properties
2339echo "#" >> $(2)
2340echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2341echo "#" >> $(2)
2342$(foreach prop,$(1), \
2343 $(eval _varname := $(call word-colon,1,$(prop))) \
2344 $(eval _propname := $(call word-colon,2,$(prop))) \
2345 $(eval _value := $($(_varname))) \
2346 $(if $(_value), \
2347 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2348endef
2349
2350$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002351 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002352 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2353 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2354 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002355 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002356 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002357 $(hide) mkdir -p $(dir $@)
2358 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002359 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002360 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002361 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002362 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002363 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002364 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2365
Bob Badour5acd4362022-04-12 18:31:35 -07002366$(call declare-1p-target,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),build)
2367$(call declare-license-deps,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),\
2368 $(INSTALLED_BUILD_PROP_TARGET) $(INSTALLED_VENDOR_BUILD_PROP_TARGET) $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2369 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET))
2370
Yifan Hong33fd5d42020-09-24 18:18:26 -07002371# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2372# On device with dedicated recovery partition, the file should come from the boot
2373# ramdisk.
2374ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2375INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2376$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2377 $(copy-file-to-target)
Bob Badour5acd4362022-04-12 18:31:35 -07002378
2379$(call declare-1p-target,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),build)
2380$(call declare-license-deps,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),$(INSTALLED_RAMDISK_BUILD_PROP_TARGET))
Yifan Hong33fd5d42020-09-24 18:18:26 -07002381endif
2382
Yifan Hongc56931c2020-10-28 16:35:19 -07002383INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002384
Yifan Hong78860162020-10-28 14:15:21 -07002385ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002386INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002387# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002388ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002389ifdef INTERNAL_KERNEL_CMDLINE
2390 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002391endif # INTERNAL_KERNEL_CMDLINE != ""
2392endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002393ifdef BOARD_KERNEL_BASE
2394 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2395endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002396ifdef BOARD_KERNEL_PAGESIZE
2397 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2398endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002399ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002400ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2401 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2402else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002403 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2404endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002405endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002406ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2407 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2408endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002409ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2410 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2411endif
Yifan Hong3941a872020-10-28 16:33:06 -07002412endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002413ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2414 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2415endif
Doug Zongker4647f122009-07-02 09:00:54 -07002416
Yifan Hong881df392020-10-09 14:29:39 -07002417$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002418 $(INTERNAL_ROOT_FILES) \
2419 $(INSTALLED_RAMDISK_TARGET) \
2420 $(INTERNAL_RECOVERYIMAGE_FILES) \
2421 $(recovery_sepolicy) \
2422 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2423 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002424 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002425 $(recovery_resource_deps) \
2426 $(recovery_fstab)
2427 # Making recovery image
2428 mkdir -p $(TARGET_RECOVERY_OUT)
2429 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2430 # Copying baseline ramdisk...
2431 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2432 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2433 # Modifying ramdisk contents...
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002434 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init
Steve Muckleb3dda772020-03-11 16:03:07 -07002435 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2436 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2437 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2438 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2439 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2440 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2441 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2442 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2443 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2444 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2445 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2446 $(foreach item,$(recovery_fstab), \
2447 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2448 $(if $(strip $(recovery_wipe)), \
2449 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2450 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2451 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002452 $(hide) touch $@
2453
2454$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002455 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002456
Ying Wang747b9f12015-01-30 14:05:22 -08002457# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002458# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002459define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002460 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002461 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002462 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002463 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002464 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002465 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002466 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002467 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2468 $(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 +08002469 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002470 $(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 -07002471 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002472 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2473 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002474 $(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),\
2475 $(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 -08002476endef
2477
Dan Willemsend120ac62020-06-12 02:39:34 +00002478recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002479ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002480 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002481endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002482ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002483 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002484endif
Tao Baof4866c72018-08-22 14:35:09 -07002485ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002486 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2487 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2488 else
2489 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2490 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002491endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002492ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002493 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002494endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002495ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002496 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002497endif
Tao Baof4866c72018-08-22 14:35:09 -07002498
Dan Willemsend120ac62020-06-12 02:39:34 +00002499ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002500$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002501$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002502 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002503 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Bob Badourebdefc02022-02-12 15:39:22 -08002504
Bob Badoura60beee2022-09-07 15:34:12 -07002505$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",bool)
Bob Badourebdefc02022-02-12 15:39:22 -08002506$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2507
Justin Yundd15ec12022-09-23 10:47:21 +09002508UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BOOTIMAGE_TARGET)
Tao Baof4866c72018-08-22 14:35:09 -07002509endif # BOARD_USES_RECOVERY_AS_BOOT
2510
Dan Willemsend120ac62020-06-12 02:39:34 +00002511$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002512 $(call build-recoveryimage-target, $@, \
2513 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002514
Tao Bao4594d0e2015-12-22 09:47:46 -08002515ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002516$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002517 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002518 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2519 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002520endif
Doug Zongker56588872012-08-20 15:38:58 -07002521
Bob Badourebdefc02022-02-12 15:39:22 -08002522
2523$(call declare-1p-container,$(INSTALLED_RECOVERYIMAGE_TARGET),)
2524$(call declare-container-license-deps,$(INSTALLED_RECOVERYIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2525
Justin Yundd15ec12022-09-23 10:47:21 +09002526UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_RECOVERYIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002527
Ying Wang747b9f12015-01-30 14:05:22 -08002528.PHONY: recoveryimage-nodeps
2529recoveryimage-nodeps:
2530 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002531 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2532 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002533
Chris Grossa784ef12019-04-22 11:09:57 -07002534else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002535RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002536endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002537
2538.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002539recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002540
Jiyong Park03eb0612017-10-04 21:22:41 +09002541ifneq ($(BOARD_NAND_PAGE_SIZE),)
2542$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002543endif
2544
Jiyong Park03eb0612017-10-04 21:22:41 +09002545ifneq ($(BOARD_NAND_SPARE_SIZE),)
2546$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002547endif
2548
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002549
Doug Zongker4647f122009-07-02 09:00:54 -07002550# -----------------------------------------------------------------
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002551# Build debug ramdisk and debug boot image.
Colin Cross79a76ec2022-03-21 15:06:11 -07002552INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002553ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
2554
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002555INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002556 $(ALL_DEFAULT_INSTALLED_MODULES))
2557
2558# Directories to be picked into the debug ramdisk.
2559# As these directories are all merged into one single cpio archive, the order
2560# matters. If there are multiple files with the same pathname, then the last one
2561# wins.
2562#
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002563# ramdisk-debug.img will merge the content from either ramdisk.img or
2564# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
2565# is set or not.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002566ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002567 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT)
2568 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002569else # BOARD_USES_RECOVERY_AS_BOOT == true
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002570 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT)
2571 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002572endif # BOARD_USES_RECOVERY_AS_BOOT != true
2573
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002574INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT)
2575INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES)
2576
2577# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
2578INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2579INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2580$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2581$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS)
2582$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2583 @echo "Installed file list: $@"
2584 $(hide) rm -f $@
2585 $(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT)
2586 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
2587 $(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2588 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2589
Bob Badourebdefc02022-02-12 15:39:22 -08002590$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_DEBUG_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07002591$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_DEBUG_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08002592
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002593ifdef BUILDING_DEBUG_BOOT_IMAGE
2594
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002595# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002596# the debug ramdisk, which is the original ramdisk plus additional
2597# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2598# When /force_debuggable is present, /init will load userdebug sepolicy
2599# and property files to allow adb root, if the device is unlocked.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002600INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
Bowgo Tsai0013f552019-03-20 17:59:52 +08002601
Bowgo Tsai610286a2021-04-23 11:31:32 +08002602$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002603$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2604 @echo "Target debug ramdisk: $@"
2605 $(hide) rm -f $@
2606 $(hide) mkdir -p $(dir $@)
2607 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002608
Bob Badourebdefc02022-02-12 15:39:22 -08002609$(call declare-1p-container,$(INSTALLED_DEBUG_RAMDISK_TARGET),)
2610$(call declare-container-license-deps,$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2611
Justin Yundd15ec12022-09-23 10:47:21 +09002612UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002613
Bowgo Tsai0013f552019-03-20 17:59:52 +08002614.PHONY: ramdisk_debug-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002615ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002616 @echo "make $@: ignoring dependencies"
2617 $(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET)
2618 $(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS)
2619 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002620
2621# -----------------------------------------------------------------
2622# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2623#
2624# Note: it's intentional to skip signing for boot-debug.img, because it
2625# can only be used if the device is unlocked with verification error.
Steve Muckleb3dda772020-03-11 16:03:07 -07002626ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002627 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002628 $(PRODUCT_OUT)/$(k).img)
2629else
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002630 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
Steve Muckleb3dda772020-03-11 16:03:07 -07002631endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002632
2633# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002634$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002635ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002636 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 +08002637else
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002638 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 +08002639endif
2640
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002641# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2642# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2643# Using a test key to sign boot-debug.img to continue booting with the mismatched
2644# public key, if the device is unlocked.
2645ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002646$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002647endif
2648
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002649BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2650INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2651# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002652# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002653define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002654$(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 +08002655$(AVBTOOL) add_hash_footer \
2656 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002657 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),$(2)))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002658 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2659 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002660$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002661endef
2662
Steve Muckleb3dda772020-03-11 16:03:07 -07002663# $(1): output file
2664define build-debug-bootimage-target
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002665 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002666 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002667 $(BOARD_MKBOOTIMG_ARGS) --output $1
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002668 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
Steve Muckleb3dda772020-03-11 16:03:07 -07002669endef
2670
Bowgo Tsai0013f552019-03-20 17:59:52 +08002671# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002672$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002673 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002674 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002675
Bob Badoura60beee2022-09-07 15:34:12 -07002676$(call declare-container-license-metadata,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
Bob Badourebdefc02022-02-12 15:39:22 -08002677$(call declare-container-license-deps,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(INSTALLED_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2678
Justin Yundd15ec12022-09-23 10:47:21 +09002679UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002680
Bowgo Tsai0013f552019-03-20 17:59:52 +08002681.PHONY: bootimage_debug-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002682bootimage_debug-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002683 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002684 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002685
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002686endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002687
Bowgo Tsai6a683672020-02-14 19:00:15 +08002688# -----------------------------------------------------------------
2689# vendor debug ramdisk
2690# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Colin Cross79a76ec2022-03-21 15:06:11 -07002691INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002692ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2693
Bowgo Tsai610286a2021-04-23 11:31:32 +08002694INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
Bowgo Tsai610286a2021-04-23 11:31:32 +08002695 $(ALL_DEFAULT_INSTALLED_MODULES))
2696
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002697# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk.
2698INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT)
2699INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002700
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002701# Exclude recovery files in the default vendor ramdisk if including a standalone
2702# recovery ramdisk in vendor_boot.
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002703ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002704 ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2705 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT)
2706 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
2707 endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true
2708endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002709
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002710INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT)
2711INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
2712
2713# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created.
2714INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2715INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2716$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2717$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS)
2718$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2719 @echo "Installed file list: $@"
2720 $(hide) rm -f $@
2721 $(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2722 $(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2723 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2724
Bob Badour5acd4362022-04-12 18:31:35 -07002725$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK))
2726$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK))
Bob Badourebdefc02022-02-12 15:39:22 -08002727
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002728INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
2729
Bowgo Tsai610286a2021-04-23 11:31:32 +08002730$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002731$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2732 $(hide) rm -f $@
2733 $(hide) mkdir -p $(dir $@)
2734 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002735
Petri Gyntherd7946d12021-03-10 12:38:15 -08002736INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2737$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002738 @echo "Target debug vendor ramdisk: $@"
Petri Gyntherd7946d12021-03-10 12:38:15 -08002739 $(copy-file-to-target)
Petri Gyntherd7946d12021-03-10 12:38:15 -08002740
Bob Badourebdefc02022-02-12 15:39:22 -08002741$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),)
2742$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2743
2744VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2745
Bowgo Tsai6a683672020-02-14 19:00:15 +08002746# -----------------------------------------------------------------
2747# vendor_boot-debug.img.
2748INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2749
2750# The util to sign vendor_boot-debug.img with a test key.
2751BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2752INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2753# $(1): the vendor bootimage to sign
2754define test-key-sign-vendor-bootimage
2755$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2756$(AVBTOOL) add_hash_footer \
2757 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002758 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsai6a683672020-02-14 19:00:15 +08002759 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2760 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2761$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2762endef
2763
2764ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2765$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2766endif
2767
2768# 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 +08002769$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002770$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002771 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002772 $(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 +08002773 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2774 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2775
Bob Badourebdefc02022-02-12 15:39:22 -08002776$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),)
2777$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2778
2779VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
2780
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002781endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai6a683672020-02-14 19:00:15 +08002782
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002783# Appends a few test harness specific properties into the adb_debug.prop.
2784ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2785ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2786
2787INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES)))
2788INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2789$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET)
2790 $(hide) rm -f $@
2791 $(hide) mkdir -p $(dir $@)
2792ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET
2793 $(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@
2794endif
2795 $(hide) echo "" >> $@
2796 $(hide) echo "#" >> $@
2797 $(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@
2798 $(hide) echo "#" >> $@
2799 $(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \
2800 echo "$(line)" >> $@;)
2801
Bob Badour2f66fd12022-03-09 17:30:24 -08002802$(call declare-1p-target,$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET))
2803
Colin Cross79a76ec2022-03-21 15:06:11 -07002804INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002805INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
2806 $(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002807 $(ALL_DEFAULT_INSTALLED_MODULES))
2808
2809# The order is important here. The test harness ramdisk staging directory has to
2810# come last so that it can override the adb_debug.prop in the debug ramdisk
2811# staging directory.
2812INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2813INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
2814
2815ifdef BUILDING_DEBUG_BOOT_IMAGE
2816
Bowgo Tsai0013f552019-03-20 17:59:52 +08002817# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002818# The test harness ramdisk, which is based off debug_ramdisk, plus a
2819# few additional test-harness-specific properties in adb_debug.prop.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002820INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002821
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002822$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS)
2823$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2824 @echo "Target test harness ramdisk: $@"
2825 $(hide) rm -f $@
2826 $(hide) mkdir -p $(dir $@)
2827 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002828
Bob Badourebdefc02022-02-12 15:39:22 -08002829$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),)
2830$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS),$(PRODUCT_OUT)/:/)
2831
Justin Yundd15ec12022-09-23 10:47:21 +09002832UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002833
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002834.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002835ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002836 @echo "make $@: ignoring dependencies"
2837 $(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2838 $(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS)
2839 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002840
2841# -----------------------------------------------------------------
2842# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2843#
2844# Note: it's intentional to skip signing for boot-test-harness.img, because it
2845# can only be used if the device is unlocked with verification error.
Steve Muckle4866bd62020-04-02 11:31:08 -07002846ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2847 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2848 $(PRODUCT_OUT)/$(k).img)
2849else
2850 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2851endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002852
2853# 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 +08002854$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002855INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2856
2857# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2858# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2859# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2860# public key, if the device is unlocked.
2861ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2862$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2863endif
2864
Steve Muckle4866bd62020-04-02 11:31:08 -07002865# $(1): output file
2866define build-boot-test-harness-target
2867 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002868 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002869 $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002870 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002871endef
2872
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002873# 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 +08002874$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002875 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002876 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002877
Bob Badourebdefc02022-02-12 15:39:22 -08002878$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),)
2879$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2880
Justin Yundd15ec12022-09-23 10:47:21 +09002881UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002882
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002883.PHONY: bootimage_test_harness-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002884bootimage_test_harness-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002885 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002886 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002887
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002888endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002889
Bowgo Tsai87f60012021-07-29 23:35:33 +08002890# -----------------------------------------------------------------
2891# vendor test harness ramdisk, which is a vendor ramdisk combined with
2892# a test harness ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002893ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai87f60012021-07-29 23:35:33 +08002894
2895INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
2896
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002897# The order is important here. The test harness ramdisk staging directory has to
2898# come last so that it can override the adb_debug.prop in the debug ramdisk
2899# staging directory.
2900INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2901INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002902
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002903$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002904$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002905 $(hide) rm -f $@
2906 $(hide) mkdir -p $(dir $@)
2907 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai87f60012021-07-29 23:35:33 +08002908
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002909INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
2910$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2911 @echo "Target test harness vendor ramdisk: $@"
2912 $(copy-file-to-target)
2913
Bob Badourebdefc02022-02-12 15:39:22 -08002914$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),)
2915$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2916
2917VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2918
Bowgo Tsai87f60012021-07-29 23:35:33 +08002919# -----------------------------------------------------------------
2920# vendor_boot-test-harness.img.
2921INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
2922
2923ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2924$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2925endif
2926
2927# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
2928$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
2929$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2930$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
2931 $(call pretty,"Target vendor_boot test harness image: $@")
2932 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
2933 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2934 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2935
Bob Badourebdefc02022-02-12 15:39:22 -08002936$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),)
2937$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2938
2939VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
2940
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002941endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2942
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002943endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2944
Bowgo Tsai87f60012021-07-29 23:35:33 +08002945
Colin Crossbd382142020-08-26 15:08:57 -07002946# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2947# $1: from location (e.g $(TARGET_OUT)/vendor)
2948# $2: destination location (e.g. /vendor)
2949# $3: partition image name (e.g. vendor.img)
2950define create-partition-compat-symlink
2951$(eval \
2952$1:
2953 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2954 mkdir -p $(dir $1)
2955 if [ -d $1 ] && [ ! -h $1 ]; then \
2956 echo 'Non-symlink $1 detected!' 1>&2; \
2957 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2958 exit 1; \
2959 fi
2960 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002961$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002962)
2963$1
2964endef
2965
2966
Inseob Kim135c1f12022-01-06 17:22:07 +09002967# FSVerity metadata generation
2968# Generate fsverity metadata files (.fsv_meta) and build manifest
Victor Hsieh89415a82022-09-09 14:16:33 -07002969# (<partition>/etc/security/fsverity/BuildManifest<suffix>.apk) BEFORE filtering systemimage,
2970# vendorimage, odmimage, productimage files below.
2971ifeq ($(PRODUCT_FSVERITY_GENERATE_METADATA),true)
Inseob Kim135c1f12022-01-06 17:22:07 +09002972
Victor Hsieh89415a82022-09-09 14:16:33 -07002973fsverity-metadata-targets-patterns := \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08002974 $(TARGET_OUT)/framework/% \
Inseob Kim135c1f12022-01-06 17:22:07 +09002975 $(TARGET_OUT)/etc/boot-image.prof \
2976 $(TARGET_OUT)/etc/dirty-image-objects \
Nicolas Geoffray13f28212022-03-18 17:28:14 +00002977 $(TARGET_OUT)/etc/preloaded-classes \
Victor Hsieh89415a82022-09-09 14:16:33 -07002978 $(TARGET_OUT)/etc/classpaths/%.pb \
2979
2980ifdef BUILDING_SYSTEM_EXT_IMAGE
2981fsverity-metadata-targets-patterns += $(TARGET_OUT_SYSTEM_EXT)/framework/%
2982endif
Victor Hsieh89415a82022-09-09 14:16:33 -07002983
2984# Generate fsv_meta
2985fsverity-metadata-targets := $(sort $(filter \
2986 $(fsverity-metadata-targets-patterns), \
Colin Crossa1de5df2022-03-21 14:31:31 -07002987 $(ALL_DEFAULT_INSTALLED_MODULES)))
Inseob Kim135c1f12022-01-06 17:22:07 +09002988
2989define fsverity-generate-metadata
Bob Badour2cd35362022-12-01 17:58:57 -08002990$(call declare-0p-target,$(1).fsv_meta)
2991
Inseob Kim135c1f12022-01-06 17:22:07 +09002992$(1).fsv_meta: PRIVATE_SRC := $(1)
2993$(1).fsv_meta: PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2994$(1).fsv_meta: $(HOST_OUT_EXECUTABLES)/fsverity_metadata_generator $(HOST_OUT_EXECUTABLES)/fsverity $(1)
2995 $$< --fsverity-path $$(PRIVATE_FSVERITY) --signature none \
2996 --hash-alg sha256 --output $$@ $$(PRIVATE_SRC)
2997endef
2998
2999$(foreach f,$(fsverity-metadata-targets),$(eval $(call fsverity-generate-metadata,$(f))))
3000ALL_DEFAULT_INSTALLED_MODULES += $(addsuffix .fsv_meta,$(fsverity-metadata-targets))
3001
Inseob Kim135c1f12022-01-06 17:22:07 +09003002FSVERITY_APK_KEY_PATH := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Victor Hsieh89415a82022-09-09 14:16:33 -07003003FSVERITY_APK_MANIFEST_TEMPLATE_PATH := system/security/fsverity/AndroidManifest.xml
3004
3005# Generate and install BuildManifest<suffix>.apk for the given partition
3006# $(1): path of the output APK
3007# $(2): partition name
3008define fsverity-generate-and-install-manifest-apk
3009fsverity-metadata-targets-$(2) := $(filter $(PRODUCT_OUT)/$(2)/%,\
3010 $(fsverity-metadata-targets))
3011$(1): PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
3012$(1): PRIVATE_AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
3013$(1): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
3014$(1): PRIVATE_VERSION_CODE := $(PLATFORM_SDK_VERSION)
3015$(1): PRIVATE_VERSION_NAME := $(APPS_DEFAULT_VERSION_NAME)
3016$(1): PRIVATE_APKSIGNER := $(HOST_OUT_EXECUTABLES)/apksigner
3017$(1): PRIVATE_MANIFEST := $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH)
3018$(1): PRIVATE_FRAMEWORK_RES := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
3019$(1): PRIVATE_KEY := $(FSVERITY_APK_KEY_PATH)
3020$(1): PRIVATE_INPUTS := $$(fsverity-metadata-targets-$(2))
3021$(1): PRIVATE_ASSETS := $(call intermediates-dir-for,ETC,build_manifest-$(2))/assets
3022$(1): $(HOST_OUT_EXECUTABLES)/fsverity_manifest_generator \
Inseob Kim135c1f12022-01-06 17:22:07 +09003023 $(HOST_OUT_EXECUTABLES)/fsverity $(HOST_OUT_EXECUTABLES)/aapt2 \
Victor Hsieh89415a82022-09-09 14:16:33 -07003024 $(HOST_OUT_EXECUTABLES)/apksigner $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH) \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08003025 $(FSVERITY_APK_KEY_PATH).x509.pem $(FSVERITY_APK_KEY_PATH).pk8 \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09003026 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk \
Victor Hsieh89415a82022-09-09 14:16:33 -07003027 $$(fsverity-metadata-targets-$(2))
3028 rm -rf $$(PRIVATE_ASSETS)
3029 mkdir -p $$(PRIVATE_ASSETS)
Victor Hsieh89415a82022-09-09 14:16:33 -07003030 $$< --fsverity-path $$(PRIVATE_FSVERITY) \
3031 --base-dir $$(PRODUCT_OUT) \
3032 --output $$(PRIVATE_ASSETS)/build_manifest.pb \
3033 $$(PRIVATE_INPUTS)
Victor Hsieh89415a82022-09-09 14:16:33 -07003034 $$(PRIVATE_AAPT2) link -o $$@ \
3035 -A $$(PRIVATE_ASSETS) \
3036 -I $$(PRIVATE_FRAMEWORK_RES) \
3037 --min-sdk-version $$(PRIVATE_MIN_SDK_VERSION) \
3038 --version-code $$(PRIVATE_VERSION_CODE) \
3039 --version-name $$(PRIVATE_VERSION_NAME) \
3040 --manifest $$(PRIVATE_MANIFEST) \
3041 --rename-manifest-package com.android.security.fsverity_metadata.$(2)
3042 $$(PRIVATE_APKSIGNER) sign --in $$@ \
3043 --cert $$(PRIVATE_KEY).x509.pem \
3044 --key $$(PRIVATE_KEY).pk8
Inseob Kim135c1f12022-01-06 17:22:07 +09003045
Victor Hsieh89415a82022-09-09 14:16:33 -07003046ALL_DEFAULT_INSTALLED_MODULES += $(1)
Inseob Kim135c1f12022-01-06 17:22:07 +09003047
Victor Hsieh89415a82022-09-09 14:16:33 -07003048endef # fsverity-generate-and-install-manifest-apk
3049
3050$(eval $(call fsverity-generate-and-install-manifest-apk, \
3051 $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk,system))
3052ifdef BUILDING_SYSTEM_EXT_IMAGE
3053 $(eval $(call fsverity-generate-and-install-manifest-apk, \
3054 $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk,system_ext))
3055endif
Victor Hsieh89415a82022-09-09 14:16:33 -07003056
3057endif # PRODUCT_FSVERITY_GENERATE_METADATA
3058
3059
3060# -----------------------------------------------------------------
3061# system image
Inseob Kim135c1f12022-01-06 17:22:07 +09003062
Colin Cross79a76ec2022-03-21 15:06:11 -07003063INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen37a19862018-10-31 16:31:46 -07003064INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Dan Willemsena3f66322020-05-28 15:46:33 -07003065 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07003066
Colin Crossbd382142020-08-26 15:08:57 -07003067# Create symlink /system/vendor to /vendor if necessary.
3068ifdef BOARD_USES_VENDORIMAGE
3069 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
3070endif
3071
3072# Create symlink /system/product to /product if necessary.
3073ifdef BOARD_USES_PRODUCTIMAGE
3074 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
3075endif
3076
3077# Create symlink /system/system_ext to /system_ext if necessary.
3078ifdef BOARD_USES_SYSTEM_EXTIMAGE
3079 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
3080endif
3081
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003082# -----------------------------------------------------------------
3083# system_dlkm partition image
3084
3085# Create symlinks for system_dlkm on devices with a system_dlkm partition:
3086# /system/lib/modules -> /system_dlkm/lib/modules
3087#
3088# On devices with a system_dlkm partition,
3089# - /system/lib/modules is a symlink to a directory that stores system DLKMs.
3090# - The system_dlkm partition is mounted at /system_dlkm at runtime.
Ramji Jiyani13a41372022-01-27 07:05:08 +00003091ifdef BOARD_USES_SYSTEM_DLKMIMAGE
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003092 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/lib/modules,/system_dlkm/lib/modules,system_dlkm.img)
3093endif
3094
Ying Wang82cceba2012-08-13 15:03:00 -07003095FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003096
3097# ASAN libraries in the system image - add dependency.
3098ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07003099ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07003100 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
3101 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
3102 endif
3103endif
3104
Tom Cherryd14b8952018-08-09 14:26:00 -07003105FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07003106
Ying Wange5e8c5f2011-09-09 16:35:53 -07003107# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08003108ifdef BUILDING_SYSTEM_IMAGE
3109
Kiyoung Kim36481e02020-11-16 10:50:05 +09003110# Install system linker configuration
3111# Collect all available stub libraries installed in system and install with predefined linker configuration
Kiyoung Kim0c079592022-12-01 10:15:10 +09003112# Also append LLNDK libraries in the APEX as required libs
Kiyoung Kim36481e02020-11-16 10:50:05 +09003113SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
Colin Crossd4a054f2022-03-15 15:07:07 -07003114SYSTEM_LINKER_CONFIG_SOURCE := $(call intermediates-dir-for,ETC,system_linker_config)/system_linker_config
3115$(SYSTEM_LINKER_CONFIG): PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE := $(SYSTEM_LINKER_CONFIG_SOURCE)
3116$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE) | conv_linker_config
3117 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE) \
Kiyoung Kim36481e02020-11-16 10:50:05 +09003118 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
Kiyoung Kim0c079592022-12-01 10:15:10 +09003119 $(HOST_OUT_EXECUTABLES)/conv_linker_config append --source $@ --output $@ --key requireLibs \
3120 --value "$(foreach lib,$(LLNDK_MOVED_TO_APEX_LIBRARIES), $(lib).so)"
Kiyoung Kim36481e02020-11-16 10:50:05 +09003121
Bob Badour2f66fd12022-03-09 17:30:24 -08003122$(call declare-1p-target,$(SYSTEM_LINKER_CONFIG),)
Colin Crossd4a054f2022-03-15 15:07:07 -07003123$(call declare-license-deps,$(SYSTEM_LINKER_CONFIG),$(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE))
Bob Badour2f66fd12022-03-09 17:30:24 -08003124
Kiyoung Kim36481e02020-11-16 10:50:05 +09003125FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
3126
Ying Wange5e8c5f2011-09-09 16:35:53 -07003127# installed file list
3128# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
3129# We put installed-files.txt ahead of image itself in the dependency graph
3130# so that we can get the size stat even if the build fails due to too large
3131# system image.
3132INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07003133INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
3134$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003135$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003136 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003137 mkdir -p $(dir $@)
3138 rm -f $@
3139 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
3140 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07003141
Bob Badourebdefc02022-02-12 15:39:22 -08003142$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE)))
Bob Badour5acd4362022-04-12 18:31:35 -07003143$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON)))
Bob Badourebdefc02022-02-12 15:39:22 -08003144
Ying Wange5e8c5f2011-09-09 16:35:53 -07003145.PHONY: installed-file-list
3146installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08003147
Ying Wange5e8c5f2011-09-09 16:35:53 -07003148systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003149 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003150BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
3151
The Android Open Source Project88b60792009-03-03 19:28:42 -08003152# $(1): output file
3153define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07003154 @echo "Target system fs image: $(1)"
3155 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003156 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07003157 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003158 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003159 $(BUILD_IMAGE) \
3160 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
3161 || ( mkdir -p $${DIST_DIR}; \
3162 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
3163 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08003164endef
3165
Dan Willemsen6b72c732019-06-12 21:33:38 +00003166ifeq ($(BOARD_AVB_ENABLE),true)
3167$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
3168endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07003169$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003170 $(call build-systemimage-target,$@)
3171
Bob Badour879cfa82021-04-15 10:41:38 -07003172$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
Bob Badourebdefc02022-02-12 15:39:22 -08003173$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:/)
Bob Badour879cfa82021-04-15 10:41:38 -07003174
Tao Baoe9d61b02018-08-20 21:09:07 -07003175INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07003176SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003177
Tao Baoe9d61b02018-08-20 21:09:07 -07003178# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
3179# compatibility, in case device-specific Makefiles still refer to the old name.
3180INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
3181
Doug Zongker73ef8252009-07-23 15:12:53 -07003182# The system partition needs room for the recovery image as well. We
3183# now store the recovery image as a binary patch using the boot image
3184# as the source (since they are very similar). Generate the patch so
3185# we can see how big it's going to be, and include that in the system
3186# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07003187ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07003188ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07003189ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08003190ifneq (,$(filter true,$(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08003191diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
3192else
3193diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
3194endif
Doug Zongker73ef8252009-07-23 15:12:53 -07003195intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
3196RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08003197$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
3198$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00003199 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07003200 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003201 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07003202 @echo "Construct recovery from boot"
3203 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07003204 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07003205else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
3206RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07003207endif # BOARD_USES_FULL_RECOVERY_IMAGE
3208endif # INSTALLED_RECOVERYIMAGE_TARGET
3209endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07003210
Yifan Hong9a3cad92020-04-27 19:06:59 -07003211$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003212 @echo "Install system fs image: $@"
3213 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003214 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003215
Bob Badour879cfa82021-04-15 10:41:38 -07003216$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
3217$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
3218
Tao Baoe9d61b02018-08-20 21:09:07 -07003219systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003220
Bob Badourebdefc02022-02-12 15:39:22 -08003221SYSTEM_NOTICE_DEPS += $(INSTALLED_SYSTEMIMAGE_TARGET)
Bob Badour879cfa82021-04-15 10:41:38 -07003222
The Android Open Source Project88b60792009-03-03 19:28:42 -08003223.PHONY: systemimage-nodeps snod
3224systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07003225 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003226 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07003227 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00003228 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08003229ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00003230 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08003231endif
3232
Dan Willemsen67495202019-01-16 12:42:05 -08003233endif # BUILDING_SYSTEM_IMAGE
3234
Anton Hansson30e061b2018-11-12 13:36:46 +00003235.PHONY: sync syncsys
3236sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07003237
Ying Wang3a61eeb2016-03-11 10:32:01 -08003238# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07003239# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07003240.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07003241platform:
3242 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07003243
3244.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07003245platform-java:
3246 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07003247
Ying Wang3a61eeb2016-03-11 10:32:01 -08003248# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003249# data partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003250INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_DATA)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003251INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003252 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003253
Dan Willemsen67495202019-01-16 12:42:05 -08003254ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07003255userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003256 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07003257BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
3258
Ying Wangbd93d422011-10-28 17:02:30 -07003259define build-userdataimage-target
3260 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
3261 @mkdir -p $(TARGET_OUT_DATA)
3262 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003263 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003264 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003265 $(BUILD_IMAGE) \
3266 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
3267 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
3268 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07003269endef
3270
Joe Onorato64d85d02009-04-09 19:31:12 -07003271# We just build this directly to the install location.
3272INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003273INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
3274 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003275 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003276$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003277 $(build-userdataimage-target)
3278
Bob Badourebdefc02022-02-12 15:39:22 -08003279$(call declare-1p-container,$(INSTALLED_USERDATAIMAGE_TARGET),)
3280$(call declare-container-license-deps,$(INSTALLED_USERDATAIMAGE_TARGET),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS),$(PRODUCT_OUT)/:/)
3281
Justin Yundd15ec12022-09-23 10:47:21 +09003282UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_USERDATAIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003283
The Android Open Source Project88b60792009-03-03 19:28:42 -08003284.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07003285userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003286 $(build-userdataimage-target)
3287
Dan Willemsen67495202019-01-16 12:42:05 -08003288endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07003289
Andreas Gampe039b5c72017-03-24 16:06:31 -07003290# ASAN libraries in the system image - build rule.
3291ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
3292 $(TARGET_OUT_SHARED_LIBRARIES) \
3293 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
3294 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
3295 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07003296# Extra options: Enforce the system user for the files to avoid having to change ownership.
3297ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07003298# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
3299# enough space.
3300$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07003301 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 -07003302
The Android Open Source Project88b60792009-03-03 19:28:42 -08003303# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04003304# partition table image
3305ifdef BOARD_BPT_INPUT_FILES
3306
3307BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003308BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04003309
3310INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
3311 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003312 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04003313 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
3314
3315ifdef BOARD_BPT_DISK_SIZE
3316INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
3317endif
3318
3319define build-bptimage-target
3320 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
3321 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
3322endef
3323
3324INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003325$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
3326 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
3327
David Zeuthen25328622016-04-08 15:08:03 -04003328$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
3329 $(build-bptimage-target)
3330
Bob Badourebdefc02022-02-12 15:39:22 -08003331$(call declare-1p-container,$(INSTALLED_BPTIMAGE_TARGET),)
3332$(call declare-container-license-deps,$(INSTALLED_BPTIMAGE_TARGET),$(BOARD_BPT_INPUT_FILES),$(PRODUCT_OUT)/:/)
3333
Justin Yundd15ec12022-09-23 10:47:21 +09003334UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BPTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003335
David Zeuthen25328622016-04-08 15:08:03 -04003336.PHONY: bptimage-nodeps
3337bptimage-nodeps:
3338 $(build-bptimage-target)
3339
3340endif # BOARD_BPT_INPUT_FILES
3341
3342# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07003343# cache partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003344INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_CACHE)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003345ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003346INTERNAL_CACHEIMAGE_FILES := \
3347 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
3348
3349cacheimage_intermediates := \
3350 $(call intermediates-dir-for,PACKAGING,cache)
3351BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
3352
3353define build-cacheimage-target
3354 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
3355 @mkdir -p $(TARGET_OUT_CACHE)
3356 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003357 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003358 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003359 $(BUILD_IMAGE) \
3360 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
3361 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
3362 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07003363endef
3364
3365# We just build this directly to the install location.
3366INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003367$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07003368 $(build-cacheimage-target)
3369
Bob Badourebdefc02022-02-12 15:39:22 -08003370$(call declare-1p-container,$(INSTALLED_CACHEIMAGE_TARGET),)
3371$(call declare-container-license-deps,$(INSTALLED_CACHEIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES),$(PRODUCT_OUT)/:/)
3372
Justin Yundd15ec12022-09-23 10:47:21 +09003373UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_CACHEIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003374
Ying Wang9f8e8db2011-11-04 11:37:01 -07003375.PHONY: cacheimage-nodeps
3376cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3377 $(build-cacheimage-target)
3378
Dan Willemsen67495202019-01-16 12:42:05 -08003379else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07003380# we need to ignore the broken cache link when doing the rsync
3381IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08003382endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003383
David Zeuthen0eb10972016-09-28 17:55:27 -04003384# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07003385# system_other partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003386INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_OTHER)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003387ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003388ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07003389# Marker file to identify that odex files are installed
3390INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
3391ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
3392$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
3393 $(hide) touch $@
Bob Badour2f66fd12022-03-09 17:30:24 -08003394
3395$(call declare-0p-target,$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER))
Alex Light4e358ab2016-06-16 14:47:10 -07003396endif
3397
Alex Light4e358ab2016-06-16 14:47:10 -07003398INTERNAL_SYSTEMOTHERIMAGE_FILES := \
3399 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003400 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07003401
Colin Cross6db5b0e2018-11-16 21:26:33 -08003402# system_other dex files are installed as a side-effect of installing system image files
3403INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
3404
Alex Light4e358ab2016-06-16 14:47:10 -07003405INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07003406INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
3407$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003408$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07003409 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003410 mkdir -p $(dir $@)
3411 rm -f $@
3412 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
3413 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07003414
Bob Badourebdefc02022-02-12 15:39:22 -08003415$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEMOTHER)))
Bob Badour5acd4362022-04-12 18:31:35 -07003416$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEMOTHER)))
Bob Badourebdefc02022-02-12 15:39:22 -08003417
Bowgo Tsai867ab662019-01-29 13:30:18 +08003418# Determines partition size for system_other.img.
3419ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
3420ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
3421INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
3422endif
3423endif
3424
3425ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
3426INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
3427endif
3428
Alex Light4e358ab2016-06-16 14:47:10 -07003429systemotherimage_intermediates := \
3430 $(call intermediates-dir-for,PACKAGING,system_other)
3431BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
3432
3433# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
3434define build-systemotherimage-target
3435 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
3436 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
3437 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003438 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003439 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003440 $(BUILD_IMAGE) \
3441 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
3442 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
3443 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07003444endef
3445
3446# We just build this directly to the install location.
3447INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003448ifneq (true,$(SANITIZE_LITE))
3449# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07003450$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
3451 $(build-systemotherimage-target)
Bob Badourebdefc02022-02-12 15:39:22 -08003452
3453$(call declare-1p-container,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),)
3454$(call declare-container-license-deps,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES),$(PRODUCT_OUT)/:/)
3455
3456UNMOUNTED_NOTICE_DEPS += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003457endif
Alex Light4e358ab2016-06-16 14:47:10 -07003458
3459.PHONY: systemotherimage-nodeps
3460systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3461 $(build-systemotherimage-target)
3462
Dan Willemsen67495202019-01-16 12:42:05 -08003463endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003464
3465
3466# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07003467# vendor partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003468INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003469ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07003470INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07003471 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003472 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07003473
Ying Wang8da19e32015-09-15 14:22:12 -07003474
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003475# Create symlink /vendor/odm to /odm if necessary.
3476ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003477 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003478endif
3479
Yifan Honge51dff22020-06-23 17:26:57 -07003480# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
3481# /vendor/lib/modules -> /vendor_dlkm/lib/modules
3482#
3483# On devices with a vendor_dlkm partition,
3484# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
3485# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
3486# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3487# are hidden.
3488# On devices without a vendor_dlkm partition,
3489# - /vendor/lib/modules stores vendor DLKMs directly.
3490# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
3491# See system/core/rootdir/Android.mk for a list of created symlinks.
3492# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
3493# are not guaranteed to exist on all devices.
3494ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003495 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 -07003496endif
3497
Colin Crossbd382142020-08-26 15:08:57 -07003498INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
3499INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3500$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
3501$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3502 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003503 mkdir -p $(dir $@)
3504 rm -f $@
3505 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
3506 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07003507
Bob Badour5acd4362022-04-12 18:31:35 -07003508$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR))
3509$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR))
Bob Badourebdefc02022-02-12 15:39:22 -08003510
Ying Wanga0febe52013-03-20 11:02:05 -07003511vendorimage_intermediates := \
3512 $(call intermediates-dir-for,PACKAGING,vendor)
3513BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003514define build-vendorimage-target
3515 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3516 @mkdir -p $(TARGET_OUT_VENDOR)
3517 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003518 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003519 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003520 $(BUILD_IMAGE) \
3521 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3522 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003523 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003524endef
3525
3526# We just build this directly to the install location.
3527INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003528$(INSTALLED_VENDORIMAGE_TARGET): \
3529 $(INTERNAL_USERIMAGES_DEPS) \
3530 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003531 $(INSTALLED_FILES_FILE_VENDOR) \
3532 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003533 $(build-vendorimage-target)
3534
Bob Badourebdefc02022-02-12 15:39:22 -08003535VENDOR_NOTICE_DEPS += $(INSTALLED_VENDORIMAGE_TARGET)
3536
Bob Badour5acd4362022-04-12 18:31:35 -07003537$(call declare-container-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08003538$(call declare-container-license-deps,$(INSTALLED_VENDORIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(RECOVERY_FROM_BOOT_PATH),$(PRODUCT_OUT)/:/)
3539
Steven Morelanda2e734d2017-03-07 12:10:09 -08003540.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003541vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003542 $(build-vendorimage-target)
3543
Colin Cross91a52272017-06-20 16:57:52 -07003544sync: $(INTERNAL_VENDORIMAGE_FILES)
3545
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003546else ifdef BOARD_PREBUILT_VENDORIMAGE
3547INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3548$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
Bob Badour5acd4362022-04-12 18:31:35 -07003549$(if $(strip $(ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC)),,\
3550 $(if $(strip $(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
Bob Badourba337242022-05-27 19:40:41 -07003551 $(call declare-copy-target-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_PREBUILT_VENDORIMAGE)),\
Bob Badour5acd4362022-04-12 18:31:35 -07003552 $(call declare-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)))
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003553endif
Ying Wanga0febe52013-03-20 11:02:05 -07003554
Ying Wang9f8e8db2011-11-04 11:37:01 -07003555# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003556# product partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003557INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_PRODUCT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003558ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003559INTERNAL_PRODUCTIMAGE_FILES := \
3560 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003561 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003562
3563INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003564INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3565$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003566$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003567 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003568 mkdir -p $(dir $@)
3569 rm -f $@
3570 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3571 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003572
Bob Badour5acd4362022-04-12 18:31:35 -07003573$(call declare-0p-target,$(INSTALLED_FILES_FILE_PRODUCT))
3574$(call declare-0p-target,$(INSTALLED_FILES_JSON_PRODUCT))
Bob Badourebdefc02022-02-12 15:39:22 -08003575
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003576productimage_intermediates := \
3577 $(call intermediates-dir-for,PACKAGING,product)
3578BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3579define build-productimage-target
3580 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3581 @mkdir -p $(TARGET_OUT_PRODUCT)
3582 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003583 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003584 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003585 $(BUILD_IMAGE) \
3586 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3587 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3588 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003589endef
3590
3591# We just build this directly to the install location.
3592INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003593$(INSTALLED_PRODUCTIMAGE_TARGET): \
3594 $(INTERNAL_USERIMAGES_DEPS) \
3595 $(INTERNAL_PRODUCTIMAGE_FILES) \
3596 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003597 $(build-productimage-target)
3598
Bob Badourebdefc02022-02-12 15:39:22 -08003599PRODUCT_NOTICE_DEPS += $(INSTALLED_PRODUCTIMAGE_TARGET)
3600
3601$(call declare-1p-container,$(INSTALLED_PRODUCTIMAGE_TARGET),)
3602$(call declare-container-license-deps,$(INSTALLED_PRODUCTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT),$(PRODUCT_OUT)/:/)
3603
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003604.PHONY: productimage-nodeps pnod
3605productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3606 $(build-productimage-target)
3607
3608sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3609
3610else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3611INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3612$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3613endif
3614
3615# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003616# system_ext partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003617INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_EXT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Justin Yun6151e3f2019-06-25 15:58:13 +09003618ifdef BUILDING_SYSTEM_EXT_IMAGE
3619INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3620 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003621 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003622
Justin Yun6151e3f2019-06-25 15:58:13 +09003623INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3624INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3625$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3626$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003627 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003628 mkdir -p $(dir $@)
3629 rm -f $@
3630 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3631 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003632
Bob Badour5acd4362022-04-12 18:31:35 -07003633$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_EXT))
3634$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_EXT))
Bob Badourebdefc02022-02-12 15:39:22 -08003635
Justin Yun6151e3f2019-06-25 15:58:13 +09003636system_extimage_intermediates := \
3637 $(call intermediates-dir-for,PACKAGING,system_ext)
3638BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3639define build-system_extimage-target
3640 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3641 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3642 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3643 $(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 -07003644 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003645 $(BUILD_IMAGE) \
3646 $(TARGET_OUT_SYSTEM_EXT) \
3647 $(system_extimage_intermediates)/system_ext_image_info.txt \
3648 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3649 $(TARGET_OUT)
3650 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003651endef
3652
3653# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003654INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003655$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3656 $(INTERNAL_USERIMAGES_DEPS) \
3657 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3658 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003659 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003660
Bob Badourebdefc02022-02-12 15:39:22 -08003661SYSTEM_EXT_NOTICE_DEPS += $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
3662
3663$(call declare-1p-container,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),)
3664$(call declare-container-license-deps,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_EXT),$(PRODUCT_OUT)/:/)
3665
Justin Yun6151e3f2019-06-25 15:58:13 +09003666.PHONY: systemextimage-nodeps senod
3667systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3668 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003669
Justin Yun6151e3f2019-06-25 15:58:13 +09003670sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003671
Justin Yun6151e3f2019-06-25 15:58:13 +09003672else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3673INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3674$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003675endif
3676
3677# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003678# odm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003679INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003680ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003681INTERNAL_ODMIMAGE_FILES := \
3682 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003683 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003684
Colin Crossbd382142020-08-26 15:08:57 -07003685# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3686# /odm/lib/modules -> /odm_dlkm/lib/modules
3687#
3688# On devices with a odm_dlkm partition,
3689# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3690# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3691# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3692# are hidden.
3693# On devices without a odm_dlkm partition,
3694# - /odm/lib/modules stores odm DLKMs directly.
3695# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3696# See system/core/rootdir/Android.mk for a list of created symlinks.
3697# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3698# are not guaranteed to exist on all devices.
3699ifdef BOARD_USES_ODM_DLKMIMAGE
3700 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3701endif
3702
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003703INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3704INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3705$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003706$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003707 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003708 mkdir -p $(dir $@)
3709 rm -f $@
3710 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3711 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003712
Bob Badour5acd4362022-04-12 18:31:35 -07003713$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM))
3714$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM))
Bob Badourebdefc02022-02-12 15:39:22 -08003715
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003716odmimage_intermediates := \
3717 $(call intermediates-dir-for,PACKAGING,odm)
3718BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3719define build-odmimage-target
3720 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3721 @mkdir -p $(TARGET_OUT_ODM)
3722 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003723 $(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
3724 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003725 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003726 $(BUILD_IMAGE) \
3727 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3728 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3729 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003730endef
3731
3732# We just build this directly to the install location.
3733INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003734$(INSTALLED_ODMIMAGE_TARGET): \
3735 $(INTERNAL_USERIMAGES_DEPS) \
3736 $(INTERNAL_ODMIMAGE_FILES) \
3737 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003738 $(build-odmimage-target)
3739
Bob Badourebdefc02022-02-12 15:39:22 -08003740ODM_NOTICE_DEPS += $(INSTALLED_ODMIMAGE_TARGET)
3741
3742$(call declare-1p-container,$(INSTALLED_ODMIMAGE_TARGET),)
3743$(call declare-container-license-deps,$(INSTALLED_ODMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM),$(PRODUCT_OUT)/:/)
3744
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003745.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003746odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003747 $(build-odmimage-target)
3748
3749sync: $(INTERNAL_ODMIMAGE_FILES)
3750
3751else ifdef BOARD_PREBUILT_ODMIMAGE
3752INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3753$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3754endif
3755
3756# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003757# vendor_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003758INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003759ifdef BUILDING_VENDOR_DLKM_IMAGE
3760INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3761 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003762 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003763
3764INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3765INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3766$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3767$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3768 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003769 mkdir -p $(dir $@)
3770 rm -f $@
3771 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3772 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003773
Bob Badour5acd4362022-04-12 18:31:35 -07003774$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DLKM))
3775$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003776
Yifan Hongcfb917a2020-05-07 14:58:20 -07003777vendor_dlkmimage_intermediates := \
3778 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3779BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3780define build-vendor_dlkmimage-target
3781 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3782 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3783 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003784 $(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
3785 vendor_dlkm, skip_fsck=true)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003786 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3787 $(BUILD_IMAGE) \
3788 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3789 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3790 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3791endef
3792
3793# We just build this directly to the install location.
3794INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3795$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3796 $(INTERNAL_USERIMAGES_DEPS) \
3797 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3798 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3799 $(build-vendor_dlkmimage-target)
3800
Bob Badourebdefc02022-02-12 15:39:22 -08003801VENDOR_DLKM_NOTICE_DEPS += $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
3802
3803$(call declare-1p-container,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),)
3804$(call declare-container-license-deps,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR_DLKM),$(PRODUCT_OUT)/:/)
3805
Yifan Hongcfb917a2020-05-07 14:58:20 -07003806.PHONY: vendor_dlkmimage-nodeps vdnod
3807vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3808 $(build-vendor_dlkmimage-target)
3809
3810sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3811
3812else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3813INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3814$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3815endif
3816
3817# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003818# odm_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003819INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003820ifdef BUILDING_ODM_DLKM_IMAGE
3821INTERNAL_ODM_DLKMIMAGE_FILES := \
3822 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003823 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003824
3825INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3826INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3827$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3828$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3829 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003830 mkdir -p $(dir $@)
3831 rm -f $@
3832 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3833 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003834
Bob Badour5acd4362022-04-12 18:31:35 -07003835$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM_DLKM))
3836$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003837
Yifan Hongf496f1b2020-07-15 16:52:59 -07003838odm_dlkmimage_intermediates := \
3839 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3840BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3841define build-odm_dlkmimage-target
3842 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3843 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3844 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003845 $(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
3846 odm_dlkm, skip_fsck=true)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003847 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3848 $(BUILD_IMAGE) \
3849 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3850 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3851 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3852endef
3853
3854# We just build this directly to the install location.
3855INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3856$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3857 $(INTERNAL_USERIMAGES_DEPS) \
3858 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3859 $(INSTALLED_FILES_FILE_ODM_DLKM)
3860 $(build-odm_dlkmimage-target)
3861
Bob Badourebdefc02022-02-12 15:39:22 -08003862ODM_DLKM_NOTICE_DEPS += $(INSTALLED_ODM_DLKMIMAGE_TARGET)
3863
3864$(call declare-1p-container,$(INSTALLED_ODM_DLKMIMAGE_TARGET),)
3865$(call declare-container-license-deps,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM_DLKM),$(PRODUCT_OUT)/:/)
3866
Yifan Hongf496f1b2020-07-15 16:52:59 -07003867.PHONY: odm_dlkmimage-nodeps odnod
3868odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3869 $(build-odm_dlkmimage-target)
3870
3871sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3872
3873else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3874INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3875$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3876endif
3877
Ramji Jiyani13a41372022-01-27 07:05:08 +00003878# -----------------------------------------------------------------
3879# system_dlkm partition image
3880
Colin Cross79a76ec2022-03-21 15:06:11 -07003881INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Ramji Jiyani13a41372022-01-27 07:05:08 +00003882ifdef BUILDING_SYSTEM_DLKM_IMAGE
3883
3884INTERNAL_SYSTEM_DLKMIMAGE_FILES := \
3885 $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,\
3886 $(ALL_DEFAULT_INSTALLED_MODULES))
3887
3888INSTALLED_FILES_FILE_SYSTEM_DLKM := $(PRODUCT_OUT)/installed-files-system_dlkm.txt
3889INSTALLED_FILES_JSON_SYSTEM_DLKM := $(INSTALLED_FILES_FILE_SYSTEM_DLKM:.txt=.json)
3890$(INSTALLED_FILES_FILE_SYSTEM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_DLKM)
3891$(INSTALLED_FILES_FILE_SYSTEM_DLKM): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3892 @echo Installed file list: $@
3893 mkdir -p $(dir $@)
Ramji Jiyani13a41372022-01-27 07:05:08 +00003894 rm -f $@
3895 $(FILESLIST) $(TARGET_OUT_SYSTEM_DLKM) > $(@:.txt=.json)
3896 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3897
Bob Badour5acd4362022-04-12 18:31:35 -07003898$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_DLKM))
3899$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003900
Ramji Jiyani13a41372022-01-27 07:05:08 +00003901system_dlkmimage_intermediates := \
3902 $(call intermediates-dir-for,PACKAGING,system_dlkm)
3903BUILT_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3904define build-system_dlkmimage-target
3905 $(call pretty,"Target system_dlkm fs image: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)")
3906 @mkdir -p $(TARGET_OUT_SYSTEM_DLKM)
3907 @mkdir -p $(system_dlkmimage_intermediates) && rm -rf $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt
3908 $(call generate-image-prop-dictionary, $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt, \
3909 system_dlkm, skip_fsck=true)
3910 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3911 $(BUILD_IMAGE) \
3912 $(TARGET_OUT_SYSTEM_DLKM) $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt \
3913 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3914 $(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
3915endef
3916
3917# We just build this directly to the install location.
3918INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
3919$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): \
3920 $(INTERNAL_USERIMAGES_DEPS) \
3921 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
3922 $(INSTALLED_FILES_FILE_SYSTEM_DLKM)
3923 $(build-system_dlkmimage-target)
3924
Bob Badour56e0de52022-08-02 17:46:48 +00003925SYSTEM_DLKM_NOTICE_DEPS += $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
3926
3927$(call declare-1p-container,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),)
3928$(call declare-container-license-deps,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_DLKM),$(PRODUCT_OUT)/:/)
3929
Ramji Jiyani13a41372022-01-27 07:05:08 +00003930.PHONY: system_dlkmimage-nodeps sdnod
3931system_dlkmimage-nodeps sdnod: | $(INTERNAL_USERIMAGES_DEPS)
3932 $(build-system_dlkmimage-target)
3933
3934sync: $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
3935
3936else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
3937INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3938$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_DLKMIMAGE),$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)))
3939endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07003940
3941# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003942# dtbo image
3943ifdef BOARD_PREBUILT_DTBOIMAGE
3944INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3945
3946ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003947$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003948 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3949 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003950 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003951 $(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003952 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3953 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08003954
3955$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_TARGET),)
3956$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_TARGET),$(BOARD_PREBUILT_DTBOIMAGE),$(PRODUCT_OUT)/:/)
3957
Justin Yundd15ec12022-09-23 10:47:21 +09003958UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003959else
3960$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3961 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3962endif
3963
Tao Bao0da43472018-08-22 22:53:41 -07003964endif # BOARD_PREBUILT_DTBOIMAGE
3965
Andrew Scull9b103e42020-11-29 14:04:28 +00003966# -----------------------------------------------------------------
3967# Protected VM firmware image
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003968ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Pierre-Clément Tosiadbf4da2022-09-09 15:57:58 +01003969
3970.PHONY: pvmfwimage
3971pvmfwimage: $(INSTALLED_PVMFWIMAGE_TARGET)
3972
Andrew Scull9b103e42020-11-29 14:04:28 +00003973INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00003974INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01003975INSTALLED_PVMFW_BINARY_TARGET := $(call module-installed-files,pvmfw_bin)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003976INTERNAL_PVMFWIMAGE_FILES := $(call module-target-built-files,pvmfw_img)
Pierre-Clément Tosi615f0812022-10-26 16:05:16 +01003977INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,pvmfw_embedded_key)
Jiyong Parke219f002022-12-16 14:30:03 +09003978INTERNAL_PVMFW_SYMBOL := $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/pvmfw
Bob Badourebdefc02022-02-12 15:39:22 -08003979
3980$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003981$(call declare-container-license-deps,$(INSTALLED_PVMFWIMAGE_TARGET),$(INTERNAL_PVMFWIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badourebdefc02022-02-12 15:39:22 -08003982
Justin Yundd15ec12022-09-23 10:47:21 +09003983UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_PVMFWIMAGE_TARGET)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003984
Jiyong Parke219f002022-12-16 14:30:03 +09003985# Place the unstripped pvmfw image to the symbols directory
3986$(INTERNAL_PVMFWIMAGE_FILES): |$(INTERNAL_PVMFW_SYMBOL)
3987
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003988$(eval $(call copy-one-file,$(INTERNAL_PVMFWIMAGE_FILES),$(INSTALLED_PVMFWIMAGE_TARGET)))
Andrew Scull9b103e42020-11-29 14:04:28 +00003989
Andrew Scullbbc930b2022-02-17 22:34:27 +00003990$(INSTALLED_PVMFWIMAGE_TARGET): $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)
3991
3992$(eval $(call copy-one-file,$(INTERNAL_PVMFW_EMBEDDED_AVBKEY),$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)))
3993
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003994endif # BOARD_USES_PVMFWIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00003995
Tao Bao0da43472018-08-22 22:53:41 -07003996# Returns a list of image targets corresponding to the given list of partitions. For example, it
3997# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3998# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003999# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07004000define images-for-partitions
Bowgo Tsai4f62aa02022-01-04 14:21:39 +08004001$(strip $(foreach item,$(1),\
4002 $(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
4003 $(if $(filter $(item),init_boot),$(INSTALLED_INIT_BOOT_IMAGE_TARGET),\
Ramji Jiyani13a41372022-01-27 07:05:08 +00004004 $(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))))
Tao Bao0da43472018-08-22 22:53:41 -07004005endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07004006
4007# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07004008# custom images
4009INSTALLED_CUSTOMIMAGES_TARGET :=
4010
4011ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4012INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
4013
4014# Sign custom image.
4015# $(1): the prebuilt custom image.
4016# $(2): the mount point of the prebuilt custom image.
4017# $(3): the signed custom image target.
4018define sign_custom_image
4019$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
4020 @echo Target custom image: $(3)
4021 mkdir -p $(dir $(3))
4022 cp $(1) $(3)
4023ifeq ($(BOARD_AVB_ENABLE),true)
4024 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
4025 $(AVBTOOL) add_hashtree_footer \
4026 --image $(3) \
4027 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
4028 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08004029 $(call get-partition-size-argument,$(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE)) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004030 --partition_name $(2) \
4031 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
4032 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
4033endif
4034INSTALLED_CUSTOMIMAGES_TARGET += $(3)
4035endef
4036
4037$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4038 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
4039 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
4040endif
4041
4042# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004043# vbmeta image
4044ifeq ($(BOARD_AVB_ENABLE),true)
4045
4046BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004047AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004048
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004049ifdef BOARD_AVB_KEY_PATH
4050$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
4051else
4052# If key path isn't specified, use the 4096-bit test key.
4053BOARD_AVB_ALGORITHM := SHA256_RSA4096
4054BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
4055endif
4056
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004057# AVB signing for system_other.img.
4058ifdef BUILDING_SYSTEM_OTHER_IMAGE
4059ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
4060$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
4061else
4062# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
4063BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
4064BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
4065endif
4066
Bowgo Tsaie4544b12019-02-27 10:15:51 +08004067$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
4068 @echo Extracting system_other avb key: $@
4069 @rm -f $@
4070 @mkdir -p $(dir $@)
4071 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08004072
Bob Badourebdefc02022-02-12 15:39:22 -08004073$(eval $(call declare-0p-target,$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET),))
4074
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004075ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
4076BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
4077endif
4078
4079BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
4080endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
4081
Tao Bao744c4c72018-08-20 21:09:07 -07004082INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07004083 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07004084 $(BOARD_AVB_VBMETA_VENDOR)
4085
4086# Not allowing the same partition to appear in multiple groups.
4087ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07004088 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07004089endif
4090
cfig1aeef722019-09-20 22:45:06 +08004091# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
4092# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
4093# details.
Yifan Hong65afc072020-04-17 10:08:10 -07004094ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08004095ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4096$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07004097 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08004098 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
4099endif
4100endif
4101
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004102# Appends os version as a AVB property descriptor.
4103SYSTEM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4104BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
4105 --prop com.android.build.system.os_version:$(SYSTEM_OS_VERSION)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004106
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004107PRODUCT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4108BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
4109 --prop com.android.build.product.os_version:$(PRODUCT_OS_VERSION)
4110
4111SYSTEM_EXT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4112BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
4113 --prop com.android.build.system_ext.os_version:$(SYSTEM_EXT_OS_VERSION)
4114
4115INIT_BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4116BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4117 --prop com.android.build.init_boot.os_version:$(INIT_BOOT_OS_VERSION)
4118
4119BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4120BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4121 --prop com.android.build.boot.os_version:$(BOOT_OS_VERSION)
4122
4123VENDOR_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4124BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4125 --prop com.android.build.vendor.os_version:$(VENDOR_OS_VERSION)
4126
4127ODM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4128BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4129 --prop com.android.build.odm.os_version:$(ODM_OS_VERSION)
4130
4131VENDOR_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4132BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4133 --prop com.android.build.vendor_dlkm.os_version:$(VENDOR_DLKM_OS_VERSION)
4134
4135ODM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4136BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4137 --prop com.android.build.odm_dlkm.os_version:$(ODM_DLKM_OS_VERSION)
4138
4139SYSTEM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4140BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4141 --prop com.android.build.system_dlkm.os_version:$(SYSTEM_DLKM_OS_VERSION)
4142
4143# Appends fingerprint and security patch level as a AVB property descriptor.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004144BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004145 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004146 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
4147
4148BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004149 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004150 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
4151
Justin Yun6151e3f2019-06-25 15:58:13 +09004152BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004153 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004154 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004155
Bowgo Tsai9b548012019-05-14 16:57:03 +08004156BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsai8c7f8202022-02-22 14:47:45 +08004157 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004158
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004159BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004160 --prop com.android.build.init_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004161
Tao Bao19b02fe2019-10-09 00:04:28 -07004162BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
4163 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4164
Lucas Weif57333f2022-02-24 10:30:15 +08004165BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS += \
4166 --prop com.android.build.vendor_kernel_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4167
Tao Bao19b02fe2019-10-09 00:04:28 -07004168BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
4169 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4170
Bowgo Tsai9b548012019-05-14 16:57:03 +08004171BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004172 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004173
4174BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004175 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004176
Yifan Hongcfb917a2020-05-07 14:58:20 -07004177BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004178 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004179
Yifan Hongf496f1b2020-07-15 16:52:59 -07004180BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004181 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004182
Ramji Jiyani13a41372022-01-27 07:05:08 +00004183BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004184 --prop com.android.build.system_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004185
Tao Bao19b02fe2019-10-09 00:04:28 -07004186BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
4187 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4188
Andrew Scull9b103e42020-11-29 14:04:28 +00004189BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4190 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4191
Bowgo Tsai9b548012019-05-14 16:57:03 +08004192# The following vendor- and odm-specific images needs explicit SPL set per board.
Devin Moore380d9e42021-11-04 19:01:19 +00004193# TODO(b/210875415) Is this security_patch property used? Should it be removed from
4194# boot.img when there is no platform ramdisk included in it?
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004195ifdef BOOT_SECURITY_PATCH
4196BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4197 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004198endif
4199
4200ifdef INIT_BOOT_SECURITY_PATCH
4201BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4202 --prop com.android.build.init_boot.security_patch:$(INIT_BOOT_SECURITY_PATCH)
4203else ifdef BOOT_SECURITY_PATCH
Devin Moore380d9e42021-11-04 19:01:19 +00004204BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4205 --prop com.android.build.init_boot.security_patch:$(BOOT_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004206endif
4207
4208ifdef VENDOR_SECURITY_PATCH
4209BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4210 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
4211endif
4212
4213ifdef ODM_SECURITY_PATCH
4214BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4215 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
4216endif
4217
Yifan Hongcfb917a2020-05-07 14:58:20 -07004218ifdef VENDOR_DLKM_SECURITY_PATCH
4219BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4220 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
4221endif
4222
Yifan Hongf496f1b2020-07-15 16:52:59 -07004223ifdef ODM_DLKM_SECURITY_PATCH
4224BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4225 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
4226endif
4227
Ramji Jiyani13a41372022-01-27 07:05:08 +00004228ifdef SYSTEM_DLKM_SECURITY_PATCH
4229BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4230 --prop com.android.build.system_dlkm.security_patch:$(SYSTEM_DLKM_SECURITY_PATCH)
4231endif
4232
Andrew Scull9b103e42020-11-29 14:04:28 +00004233ifdef PVMFW_SECURITY_PATCH
4234BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4235 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
4236endif
4237
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004238BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Devin Moore380d9e42021-11-04 19:01:19 +00004239INIT_BOOT_FOOTER_ARGS := BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07004240VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Lucas Weif57333f2022-02-24 10:30:15 +08004241VENDOR_KERNEL_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004242DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00004243PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004244SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
4245VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05004246RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004247PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09004248SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004249ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07004250VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07004251ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Ramji Jiyani13a41372022-01-27 07:05:08 +00004252SYSTEM_DLKM_FOOTER_ARGS := BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004253
Tao Bao0da43472018-08-22 22:53:41 -07004254# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004255# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07004256define _check-and-set-avb-chain-args
4257$(eval part := $(1))
4258$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004259
4260$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
4261$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
4262$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
4263$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4264$(if $($(_key_path)),,$(error $(_key_path) is not defined))
4265$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
4266$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
4267$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4268
4269# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
4270$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
4271$(eval $(_signing_args) := \
4272 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
4273
cfig1aeef722019-09-20 22:45:06 +08004274# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
4275# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07004276$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08004277 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4278 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004279
Tao Bao744c4c72018-08-20 21:09:07 -07004280# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07004281# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07004282$(if $(filter $(part),$(part:vbmeta_%=%)),\
4283 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
4284 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004285endef
4286
Tao Bao0da43472018-08-22 22:53:41 -07004287# Checks and sets the required build variables for an AVB partition. The partition will be
4288# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07004289# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
4290# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004291# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
4292# but vbmeta would capture the image descriptor of only the first boot
4293# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07004294# $(1): Partition name, e.g. boot or system.
4295define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07004296$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07004297$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07004298 $(if $(_in_chained_vbmeta),\
4299 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07004300 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07004301 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004302 $(if $(filter boot,$(1)),\
4303 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4304 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
4305 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4306 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07004307endef
4308
Hongguang Chenf23364d2020-04-27 18:36:36 -07004309# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
4310# $(1): the custom partition to enable AVB chain.
4311define check-and-set-custom-avb-chain-args
4312$(eval part := $(1))
4313$(eval PART=$(call to-upper,$(part)))
4314$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4315$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4316
4317INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4318 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
4319endef
4320
Tao Baob1a2e352018-08-14 16:17:12 -07004321ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004322$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07004323endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004324
Devin Moore380d9e42021-11-04 19:01:19 +00004325ifdef INSTALLED_INIT_BOOT_IMAGE_TARGET
4326$(eval $(call check-and-set-avb-args,init_boot))
4327endif
4328
Steve Mucklee1b10862019-07-10 10:49:37 -07004329ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4330$(eval $(call check-and-set-avb-args,vendor_boot))
4331endif
4332
Lucas Weif57333f2022-02-24 10:30:15 +08004333ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
4334$(eval $(call check-and-set-avb-args,vendor_kernel_boot))
4335endif
4336
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004337ifdef INSTALLED_SYSTEMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004338$(eval $(call check-and-set-avb-args,system))
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004339endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004340
4341ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004342$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004343endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004344
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004345ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004346$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004347endif
4348
Justin Yun6151e3f2019-06-25 15:58:13 +09004349ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4350$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07004351endif
4352
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004353ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004354$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004355endif
4356
Yifan Hongcfb917a2020-05-07 14:58:20 -07004357ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
4358$(eval $(call check-and-set-avb-args,vendor_dlkm))
4359endif
4360
Yifan Hongf496f1b2020-07-15 16:52:59 -07004361ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
4362$(eval $(call check-and-set-avb-args,odm_dlkm))
4363endif
4364
Ramji Jiyani13a41372022-01-27 07:05:08 +00004365ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
4366$(eval $(call check-and-set-avb-args,system_dlkm))
4367endif
4368
Yueyao Zhu211c9012017-04-27 00:34:50 -07004369ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004370$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004371endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07004372
Andrew Scull9b103e42020-11-29 14:04:28 +00004373ifdef INSTALLED_PVMFWIMAGE_TARGET
4374$(eval $(call check-and-set-avb-args,pvmfw))
4375endif
4376
David Zeuthen8fecb282017-12-01 16:24:01 -05004377ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004378$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05004379endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08004380
David Anderson7709ab22018-10-15 14:41:34 -07004381# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
4382ifdef BOARD_AVB_VBMETA_SYSTEM
4383$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07004384endif
4385
4386ifdef BOARD_AVB_VBMETA_VENDOR
4387$(eval $(call check-and-set-avb-args,vbmeta_vendor))
4388endif
4389
Hongguang Chenf23364d2020-04-27 18:36:36 -07004390ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4391$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4392 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
4393endif
4394
Tao Bao0da43472018-08-22 22:53:41 -07004395BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07004396BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07004397BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
4398
4399ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07004400# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07004401BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07004402endif
Tao Bao0da43472018-08-22 22:53:41 -07004403
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004404ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004405BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004406endif
4407
David Anderson7709ab22018-10-15 14:41:34 -07004408ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
4409BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
4410 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07004411endif
4412
4413ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
4414BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
4415 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07004416endif
4417
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004418# $(1): the directory to extract public keys to
4419define extract-avb-chain-public-keys
4420 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
4421 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
4422 --output $(1)/boot.avbpubkey)
Devin Moore380d9e42021-11-04 19:01:19 +00004423 $(if $(BOARD_AVB_INIT_BOOT_KEY_PATH),\
4424 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_INIT_BOOT_KEY_PATH) \
4425 --output $(1)/init_boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07004426 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
4427 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
4428 --output $(1)/vendor_boot.avbpubkey)
Lucas Weif57333f2022-02-24 10:30:15 +08004429 $(if $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH),\
4430 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH) \
4431 --output $(1)/vendor_kernel_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004432 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
4433 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
4434 --output $(1)/system.avbpubkey)
4435 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
4436 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
4437 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004438 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
4439 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
4440 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09004441 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
4442 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
4443 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004444 $(if $(BOARD_AVB_ODM_KEY_PATH),\
4445 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
4446 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004447 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
4448 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
4449 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004450 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
4451 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
4452 --output $(1)/odm_dlkm.avbpubkey)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004453 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
4454 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH) \
4455 --output $(1)/system_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004456 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
4457 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
4458 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00004459 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
4460 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
4461 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05004462 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
4463 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
4464 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07004465 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
4466 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4467 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07004468 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
4469 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4470 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07004471 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
4472 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4473 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
4474 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004475endef
4476
Tao Bao744c4c72018-08-20 21:09:07 -07004477# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
4478# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07004479# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09004480# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
4481# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07004482# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004483# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07004484# $(2): Output filename.
4485define build-chained-vbmeta-image
4486 $(call pretty,"Target chained vbmeta image: $@")
4487 $(hide) $(AVBTOOL) make_vbmeta_image \
4488 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
4489 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
4490 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
4491 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
4492 --output $@
4493endef
4494
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004495ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07004496ifdef BOARD_AVB_VBMETA_SYSTEM
4497INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
4498$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004499 $(AVBTOOL) \
4500 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
4501 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07004502 $(call build-chained-vbmeta-image,vbmeta_system)
Bob Badourebdefc02022-02-12 15:39:22 -08004503
4504$(call declare-1p-container,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET),)
4505
4506SYSTEM_NOTICE_DEPS += $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004507endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004508endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07004509
4510ifdef BOARD_AVB_VBMETA_VENDOR
4511INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
4512$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004513 $(AVBTOOL) \
4514 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
4515 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07004516 $(call build-chained-vbmeta-image,vbmeta_vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08004517
4518$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
4519
Justin Yundd15ec12022-09-23 10:47:21 +09004520UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004521endif
4522
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004523define build-vbmetaimage-target
4524 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004525 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
4526 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004527 $(hide) $(AVBTOOL) make_vbmeta_image \
4528 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07004529 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004530 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
4531 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004532 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004533endef
4534
Paul Trautrim4e143232019-08-13 16:30:57 +09004535ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004536INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07004537$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4538 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
4539
David Zeuthen8fecb282017-12-01 16:24:01 -05004540$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004541 $(AVBTOOL) \
4542 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00004543 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004544 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Lucas Weif57333f2022-02-24 10:30:15 +08004545 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004546 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4547 $(INSTALLED_VENDORIMAGE_TARGET) \
4548 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004549 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004550 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004551 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004552 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004553 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004554 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004555 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004556 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004557 $(INSTALLED_RECOVERYIMAGE_TARGET) \
4558 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
4559 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
4560 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4561 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4562 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004563 $(build-vbmetaimage-target)
4564
Bob Badourebdefc02022-02-12 15:39:22 -08004565$(call declare-1p-container,$(INSTALLED_VBMETAIMAGE_TARGET),)
4566
4567UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETAIMAGE_TARGET)
4568
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004569.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08004570vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4571 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004572vbmetaimage-nodeps:
4573 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09004574endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004575
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004576endif # BOARD_AVB_ENABLE
4577
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004578# List of files from all images
4579INTERNAL_ALLIMAGES_FILES := \
4580 $(FULL_SYSTEMIMAGE_DEPS) \
4581 $(INTERNAL_RAMDISK_FILES) \
4582 $(INTERNAL_USERDATAIMAGE_FILES) \
4583 $(INTERNAL_VENDORIMAGE_FILES) \
4584 $(INTERNAL_PRODUCTIMAGE_FILES) \
4585 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4586 $(INTERNAL_ODMIMAGE_FILES) \
4587 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4588 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004589 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
Jiyong Parke219f002022-12-16 14:30:03 +09004590 $(INTERNAL_PVMFWIMAGE_FILES) \
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004591
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004592# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004593# Check VINTF of build
4594
Ramji Jiyani13a41372022-01-27 07:05:08 +00004595# Note: vendor_dlkm, odm_dlkm, and system_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004596ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07004597
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004598intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
4599check_vintf_all_deps :=
4600
Rob Seymour3f1c9572022-07-28 21:56:28 +00004601APEX_OUT := $(PRODUCT_OUT)/apex
4602# -----------------------------------------------------------------
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004603# Create apex-info-file.xml
Rob Seymour3f1c9572022-07-28 21:56:28 +00004604
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004605apex_dirs := \
Rob Seymour3f1c9572022-07-28 21:56:28 +00004606 $(TARGET_OUT)/apex/% \
4607 $(TARGET_OUT_SYSTEM_EXT)/apex/% \
4608 $(TARGET_OUT_VENDOR)/apex/% \
4609 $(TARGET_OUT_ODM)/apex/% \
4610 $(TARGET_OUT_PRODUCT)/apex/% \
4611
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004612apex_files := $(sort $(filter $(apex_dirs), $(INTERNAL_ALLIMAGES_FILES)))
4613APEX_INFO_FILE := $(APEX_OUT)/apex-info-list.xml
Rob Seymour3f1c9572022-07-28 21:56:28 +00004614
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004615# dump_apex_info scans $(PRODUCT_OUT)/apex and writes apex-info-list.xml there.
4616# This relies on the fact that rules for .apex files install the contents in $(PRODUCT_OUT)/apex.
4617$(APEX_INFO_FILE): $(HOST_OUT_EXECUTABLES)/dump_apex_info $(apex_files)
Rob Seymour3f1c9572022-07-28 21:56:28 +00004618 @echo "Creating apex-info-file in $(PRODUCT_OUT) "
Jooyung Han8af44a92022-11-24 18:36:47 +09004619 $< --root_dir $(PRODUCT_OUT)
Rob Seymour3f1c9572022-07-28 21:56:28 +00004620
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004621apex_files :=
4622apex_dirs :=
Rob Seymour3f1c9572022-07-28 21:56:28 +00004623
Yifan Hongaf9b0702020-01-21 12:46:57 -08004624# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
4625# because they are only used for prebuilt images.
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004626# APEX files in /vendor/apex can have VINTF fragments as well.
Yifan Hongaf9b0702020-01-21 12:46:57 -08004627check_vintf_common_srcs_patterns := \
4628 $(TARGET_OUT)/etc/vintf/% \
4629 $(TARGET_OUT_VENDOR)/etc/vintf/% \
4630 $(TARGET_OUT_ODM)/etc/vintf/% \
4631 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
4632 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004633 $(TARGET_OUT_VENDOR)/apex/% \
Yifan Hongaf9b0702020-01-21 12:46:57 -08004634
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004635check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08004636check_vintf_common_srcs_patterns :=
4637
4638check_vintf_has_system :=
4639check_vintf_has_vendor :=
4640
Yifan Hong28ffd732020-03-13 13:11:10 -07004641ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
4642$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
4643endif
4644ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
4645$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
4646endif
4647
Yifan Hong605ea042020-01-14 21:36:00 +00004648# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08004649check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
4650ifneq ($(check_vintf_system_deps),)
4651check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00004652
Yifan Hongfd150d32021-03-09 12:19:11 -08004653check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00004654check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004655$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00004656 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
Bob Badour5acd4362022-04-12 18:31:35 -07004657$(call declare-0p-target,$(check_vintf_system_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004658check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00004659
Devin Moore62d0a732022-10-13 16:50:50 +00004660# -- Check framework manifest against frozen manifests for GSI targets. They need to be compatible.
4661ifneq (true, $(BUILDING_VENDOR_IMAGE))
4662 vintffm_log := $(intermediates)/vintffm.log
4663endif
Yifan Hong7a157b02020-10-20 17:08:11 +00004664check_vintf_all_deps += $(vintffm_log)
4665$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
4666 @( $< --check --dirmap /system:$(TARGET_OUT) \
4667 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
4668
Bob Badour5acd4362022-04-12 18:31:35 -07004669$(call declare-0p-target,$(vintffm_log))
4670
Yifan Hongaf9b0702020-01-21 12:46:57 -08004671endif # check_vintf_system_deps
4672check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004673
4674# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004675check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004676check_vintf_vendor_deps += $(filter $(TARGET_OUT_VENDOR)/apex/%, $(check_vintf_common_srcs))
4677ifneq ($(strip $(check_vintf_vendor_deps)),)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004678check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08004679check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00004680check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07004681# Check vendor SKU=(empty) case when:
4682# - DEVICE_MANIFEST_FILE is not empty; OR
4683# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004684$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004685 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4686 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004687 $(DEVICE_MANIFEST_SKUS)
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004688$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps) $(APEX_INFO_FILE)
Yifan Hong28ffd732020-03-13 13:11:10 -07004689 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004690 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) --dirmap /apex:$(APEX_OUT) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004691 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4692 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Bob Badour5acd4362022-04-12 18:31:35 -07004693$(call declare-0p-target,$(check_vintf_vendor_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004694check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08004695endif # check_vintf_vendor_deps
4696check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004697
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004698# -- Kernel version and configurations.
4699ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
4700
Yifan Hong605ea042020-01-14 21:36:00 +00004701BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
4702BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
4703
4704my_board_extracted_kernel :=
4705
4706# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
4707# from INSTALLED_KERNEL_TARGET.
4708ifdef BOARD_KERNEL_CONFIG_FILE
4709ifdef BOARD_KERNEL_VERSION
4710$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
4711 cp $< $@
4712$(BUILT_KERNEL_VERSION_FILE):
4713 echo $(BOARD_KERNEL_VERSION) > $@
4714
Bob Badour5acd4362022-04-12 18:31:35 -07004715$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4716$(call declare-0p-target,$(BUILT_KERNEL_VERSION_FILE))
4717
Yifan Hong605ea042020-01-14 21:36:00 +00004718my_board_extracted_kernel := true
4719endif # BOARD_KERNEL_VERSION
4720endif # BOARD_KERNEL_CONFIG_FILE
4721
4722ifneq ($(my_board_extracted_kernel),true)
Yifan Hong605ea042020-01-14 21:36:00 +00004723# Tools for decompression that is not in PATH.
4724# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
4725# Algorithms that are in the script but not in this list will be found in PATH.
4726my_decompress_tools := \
4727 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
4728
Yifan Hongb1627772021-07-14 15:01:50 -07004729endif # my_board_extracted_kernel
4730
4731ifneq ($(my_board_extracted_kernel),true)
4732ifdef INSTALLED_KERNEL_TARGET
Yifan Hong605ea042020-01-14 21:36:00 +00004733$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4734$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4735$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07004736$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
4737 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00004738 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08004739 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00004740
Bob Badour5acd4362022-04-12 18:31:35 -07004741$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4742
Yifan Hongb1627772021-07-14 15:01:50 -07004743my_board_extracted_kernel := true
Yifan Hong605ea042020-01-14 21:36:00 +00004744endif # INSTALLED_KERNEL_TARGET
Yifan Hongb1627772021-07-14 15:01:50 -07004745endif # my_board_extracted_kernel
4746
4747ifneq ($(my_board_extracted_kernel),true)
4748ifdef INSTALLED_BOOTIMAGE_TARGET
4749$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4750$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4751$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
4752$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
4753$(BUILT_KERNEL_CONFIGS_FILE): \
4754 $(HOST_OUT_EXECUTABLES)/unpack_bootimg \
4755 $(EXTRACT_KERNEL) \
4756 $(INSTALLED_BOOTIMAGE_TARGET)
4757 $(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
4758 $(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
4759 --output-configs $@ \
4760 --output-release $(BUILT_KERNEL_VERSION_FILE)
4761
Bob Badour5acd4362022-04-12 18:31:35 -07004762$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4763
Yifan Hongb1627772021-07-14 15:01:50 -07004764my_board_extracted_kernel := true
4765endif # INSTALLED_BOOTIMAGE_TARGET
4766endif # my_board_extracted_kernel
4767
4768ifneq ($(my_board_extracted_kernel),true)
4769$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
4770 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
4771 cannot be built into OTA update package. You can fix this by: \
4772 (1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
4773 so that kernel information will be extracted from the built kernel; or \
4774 (2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
4775 (3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
4776 BOARD_KERNEL_VERSION manually; or \
4777 (4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
4778# Clear their values to indicate that these two files does not exist.
4779BUILT_KERNEL_CONFIGS_FILE :=
4780BUILT_KERNEL_VERSION_FILE :=
4781endif
4782
4783my_decompress_tools :=
4784my_board_extracted_kernel :=
Yifan Hong605ea042020-01-14 21:36:00 +00004785
Yifan Hongc0f904e2021-03-17 11:25:31 -07004786endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4787
4788# -- Check VINTF compatibility of build.
4789# Skip partial builds; only check full builds. Only check if:
4790# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
4791# - system / vendor VINTF metadata exists
4792# - Building product / system_ext / odm images if board has product / system_ext / odm images
4793ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4794ifeq ($(check_vintf_has_system),true)
4795ifeq ($(check_vintf_has_vendor),true)
4796ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
4797ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
4798ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
4799
4800check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
4801check_vintf_all_deps += $(check_vintf_compatible_log)
4802
4803check_vintf_compatible_args :=
Jooyung Hanc9cc48b2022-12-16 14:49:43 +09004804check_vintf_compatible_deps := $(check_vintf_common_srcs) $(APEX_INFO_FILE)
Yifan Hongc0f904e2021-03-17 11:25:31 -07004805
4806ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004807ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004808check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004809check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004810endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004811endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4812
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004813check_vintf_compatible_args += \
4814 --dirmap /system:$(TARGET_OUT) \
4815 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4816 --dirmap /odm:$(TARGET_OUT_ODM) \
4817 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4818 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
Rob Seymour3f1c9572022-07-28 21:56:28 +00004819 --dirmap /apex:$(APEX_OUT) \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004820
4821ifdef PRODUCT_SHIPPING_API_LEVEL
4822check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4823endif # PRODUCT_SHIPPING_API_LEVEL
4824
4825$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4826$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004827# Check ODM SKU=(empty) case when:
4828# - ODM_MANIFEST_FILES is not empty; OR
4829# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004830$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004831 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
4832 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004833 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07004834# Check vendor SKU=(empty) case when:
4835# - DEVICE_MANIFEST_FILE is not empty; OR
4836# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004837$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004838 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4839 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004840 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004841$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08004842 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
4843 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004844 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
4845 @echo -n -e 'Args: \n ' >> $@
4846 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07004847 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4848 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004849 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004850 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
4851 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4852 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004853
Bob Badour5acd4362022-04-12 18:31:35 -07004854$(call declare-0p-target,$(check_vintf_compatible_log))
4855
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004856check_vintf_compatible_log :=
4857check_vintf_compatible_args :=
4858check_vintf_compatible_deps :=
4859
4860endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4861endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4862endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004863endif # check_vintf_has_vendor
4864endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004865endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4866
4867# Add all logs of VINTF checks to dist builds
4868droid_targets: $(check_vintf_all_deps)
4869$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4870
4871# Helper alias to check all VINTF of current build.
4872.PHONY: check-vintf-all
4873check-vintf-all: $(check_vintf_all_deps)
4874 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4875
Yifan Hongaf9b0702020-01-21 12:46:57 -08004876check_vintf_has_vendor :=
4877check_vintf_has_system :=
4878check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004879check_vintf_all_deps :=
4880intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004881endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004882
4883# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004884# Check image sizes <= size of super partition
4885
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004886ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004887
4888ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004889
Tianjie16bcac12021-05-13 15:44:43 -07004890PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
4891
4892# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
4893ifdef BUILDING_SYSTEM_OTHER_IMAGE
4894PARTITIONS_AND_OTHER_IN_SUPER += system_other
4895endif # BUILDING_SYSTEM_OTHER_IMAGE
4896
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004897# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004898# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004899define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004900 mkdir -p $(dir $(1))
4901 rm -f $(1)
4902 $(call dump-super-image-info, $(1))
Tianjie16bcac12021-05-13 15:44:43 -07004903 $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004904 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004905 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004906endef
4907
Yifan Hongd11953c2021-03-11 14:47:48 -08004908check_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 -07004909droid_targets: $(check_all_partition_sizes_log)
4910$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004911
Yifan Hong30910932019-10-25 20:36:55 -07004912$(check_all_partition_sizes_log): \
4913 $(CHECK_PARTITION_SIZES) \
Tianjie16bcac12021-05-13 15:44:43 -07004914 $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
Yifan Hong30910932019-10-25 20:36:55 -07004915 $(call check-all-partition-sizes-target, \
4916 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4917 $@)
4918
Bob Badour5acd4362022-04-12 18:31:35 -07004919$(call declare-0p-target,$(check_all_partition_sizes_log))
4920
Yifan Hong30910932019-10-25 20:36:55 -07004921.PHONY: check-all-partition-sizes
4922check-all-partition-sizes: $(check_all_partition_sizes_log)
4923
4924.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004925check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004926 $(call check-all-partition-sizes-target, \
4927 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004928
Yifan Hong2dae5722018-07-31 12:47:27 -07004929endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004930
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004931endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004932
4933# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004934# bring in the installer image generation defines if necessary
4935ifeq ($(TARGET_USE_DISKINSTALLER),true)
4936include bootable/diskinstaller/config.mk
4937endif
4938
4939# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004940# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004941
Ying Wangbd2d0242015-09-22 11:17:52 -07004942ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004943 build_ota_package := false
4944 build_otatools_package := false
4945else
Tao Bao9be20c72019-04-08 21:11:59 -07004946 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004947 build_ota_package := true
4948 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4949 build_ota_package := false
4950 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004951 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004952 build_ota_package := false
4953 endif
4954 ifeq ($(TARGET_PRODUCT),sdk)
4955 build_ota_package := false
4956 endif
Yifan Hongf32f65c2021-07-14 14:19:12 -07004957 # A target without a kernel may be one of the following:
Yifan Hong8c1e5262021-07-19 16:35:05 +00004958 # - A generic target. In this case, the OTA package usually isn't built.
4959 # PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
4960 # generation.
4961 # - A real device target, with TARGET_NO_KERNEL set to true and
4962 # BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
4963 # an OTA package.
Tao Bao9be20c72019-04-08 21:11:59 -07004964 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4965 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4966 build_ota_package := false
4967 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004968 ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4969 ifeq ($(TARGET_NO_KERNEL),true)
4970 build_ota_package := false
4971 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004972 endif # INSTALLED_BOOTIMAGE_TARGET == ""
Yifan Hongbf777872021-07-19 16:28:49 +00004973 ifeq ($(recovery_fstab),)
4974 build_ota_package := false
4975 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004976 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004977
Tao Bao9be20c72019-04-08 21:11:59 -07004978 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004979 build_otatools_package := true
4980 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4981 build_otatools_package := false
4982 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004983endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004984
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004985ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004986
4987INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004988 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004989 add_img_to_target_files \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004990 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004991 append2simg \
4992 avbtool \
4993 blk_alloc_to_base_fs \
4994 boot_signer \
4995 brillo_update_payload \
4996 brotli \
4997 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004998 build_image \
4999 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07005000 build_verity_metadata \
5001 build_verity_tree \
5002 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07005003 check_ota_package_signature \
5004 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005005 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07005006 checkvintf \
5007 delta_generator \
5008 e2fsck \
5009 e2fsdroid \
5010 fc_sort \
5011 fec \
Woody Line4164192022-03-21 18:29:41 +08005012 fsck.erofs \
Jaegeuk Kim01da65f2021-06-08 18:24:46 -07005013 fsck.f2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07005014 fs_config \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08005015 generate_gki_certificate \
Tao Bao96daeeb2019-05-01 21:17:13 -07005016 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08005017 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07005018 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07005019 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005020 imgdiff \
5021 libconscrypt_openjdk_jni \
5022 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08005023 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07005024 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07005025 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07005026 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07005027 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005028 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08005029 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07005030 mkbootfs \
5031 mkbootimg \
5032 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08005033 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08005034 mkfs.erofs \
Cole Faustb0002082022-09-05 18:34:56 -07005035 mkf2fsuserimg \
Tao Bao96daeeb2019-05-01 21:17:13 -07005036 mksquashfs \
Cole Faustb0002082022-09-05 18:34:56 -07005037 mksquashfsimage \
Tao Bao96daeeb2019-05-01 21:17:13 -07005038 mkuserimg_mke2fs \
Kelvin Zhang83eb9f72022-03-15 11:12:50 -07005039 ota_extractor \
Tao Bao8821d642019-08-05 12:05:45 -07005040 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08005041 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08005042 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07005043 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08005044 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07005045 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07005046 sign_apex \
5047 sign_target_files_apks \
Jooyung Han8caba5e2021-10-27 03:58:09 +09005048 sign_virt_apex \
Tao Bao96daeeb2019-05-01 21:17:13 -07005049 signapk \
5050 simg2img \
5051 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07005052 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07005053 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08005054 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07005055 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07005056 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005057 verity_signer \
5058 verity_verifier \
5059 zipalign \
Kelvin Zhangb673bbf2021-08-20 10:09:20 -07005060 zucchini \
Tao Bao5e04c382017-02-22 16:38:19 -08005061
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005062# Additional tools to unpack and repack the apex file.
5063INTERNAL_OTATOOLS_MODULES += \
5064 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00005065 apex_compression_tool \
Dennis Shen888539c2022-11-07 18:53:10 +00005066 blkid \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005067 deapexer \
5068 debugfs_static \
Baligh Uddin67ab6892022-10-17 17:17:42 +00005069 dump_apex_info \
Dennis Shen888539c2022-11-07 18:53:10 +00005070 fsck.erofs \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005071 merge_zips \
5072 resize2fs \
5073 soong_zip \
5074
Anton Hansson8dab0a62019-03-28 15:45:40 +00005075ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005076INTERNAL_OTATOOLS_MODULES += \
5077 futility \
5078 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08005079endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08005080
Tao Bao96daeeb2019-05-01 21:17:13 -07005081INTERNAL_OTATOOLS_FILES := \
5082 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005083
Ying Wang06898662010-06-17 17:52:18 -07005084.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07005085otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07005086
Tao Bao96daeeb2019-05-01 21:17:13 -07005087# For each module, recursively resolve its host shared library dependencies. Then we have a full
5088# list of modules whose installed files need to be packed.
5089INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
5090 $(sort $(INTERNAL_OTATOOLS_MODULES) \
5091 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005092
Tao Bao96daeeb2019-05-01 21:17:13 -07005093INTERNAL_OTATOOLS_PACKAGE_FILES := \
5094 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
5095
5096INTERNAL_OTATOOLS_PACKAGE_FILES += \
5097 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
hungweichenf1f5dd32022-08-17 08:01:50 +00005098 -name "*.pk8"))
Tao Bao93ab8442018-10-12 11:03:04 -07005099
Hongguang07babe02022-10-31 17:21:22 -07005100ifneq (,$(wildcard packages/modules))
Hongguang547812d2022-10-31 10:20:14 -07005101INTERNAL_OTATOOLS_PACKAGE_FILES += \
5102 $(sort $(shell find packages/modules -type f -name "*.x509.pem" -o -name "*.pk8" -o -name \
5103 "key.pem"))
Hongguang07babe02022-10-31 17:21:22 -07005104endif
Hongguang547812d2022-10-31 10:20:14 -07005105
Tao Bao93ab8442018-10-12 11:03:04 -07005106ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07005107INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07005108 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07005109 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07005110endif
5111ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07005112INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07005113 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
5114 -name "atx_metadata.bin"))
5115endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005116ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005117INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00005118 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07005119endif
5120
Tao Bao96daeeb2019-05-01 21:17:13 -07005121INTERNAL_OTATOOLS_RELEASETOOLS := \
Kelvin Zhanged714e02022-09-22 12:42:24 -07005122 $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
5123 \( -type f -o -type l \) -print | sort)
Tao Bao96daeeb2019-05-01 21:17:13 -07005124
5125BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
5126$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
5127$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
5128$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
5129$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07005130$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005131 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07005132 rm -rf $@ $(PRIVATE_ZIP_ROOT)
5133 mkdir -p $(dir $@)
5134 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
5135 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08005136 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07005137 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005138
Bob Badour5acd4362022-04-12 18:31:35 -07005139$(call declare-1p-container,$(BUILT_OTATOOLS_PACKAGE),build)
5140$(call declare-container-license-deps,$(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS),$(BUILT_OTATOOLS_PACKAGE):)
5141
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005142.PHONY: otatools-package
5143otatools-package: $(BUILT_OTATOOLS_PACKAGE)
5144
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005145endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005146
The Android Open Source Project88b60792009-03-03 19:28:42 -08005147# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07005148# misc_info.txt
5149
5150INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
5151
5152ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
5153# default to common dir for device vendor
5154tool_extensions := $(TARGET_DEVICE_DIR)/../common
5155else
5156tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
5157endif
5158.KATI_READONLY := tool_extensions
5159
Steve Muckle903a1ca2020-05-07 17:32:10 -07005160# $1: boot image file name
5161define misc_boot_size
5162$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
5163endef
5164
Daniel Normane1e48082019-06-27 13:55:23 -07005165$(INSTALLED_MISC_INFO_TARGET):
5166 rm -f $@
5167 $(call pretty,"Target misc_info.txt: $@")
5168 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
5169 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
5170ifdef BOARD_FLASH_BLOCK_SIZE
5171 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
5172endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07005173ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
5174 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
5175 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07005176endif
5177ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
5178 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07005179else
5180 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005181endif
Devin Moore380d9e42021-11-04 19:01:19 +00005182ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
5183 $(hide) echo "init_boot=true" >> $@
5184 $(hide) echo "init_boot_size=$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)" >> $@
5185endif
J. Avila98cd4cc2020-06-10 20:09:10 +00005186ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
5187 echo "lz4_ramdisks=true" >> $@
5188endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005189ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5190 echo "vendor_boot=true" >> $@
5191 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
5192endif
Lucas Weif57333f2022-02-24 10:30:15 +08005193ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
5194 echo "vendor_kernel_boot=true" >> $@
5195 echo "vendor_kernel_boot_size=$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)" >> $@
5196endif
Daniel Normane1e48082019-06-27 13:55:23 -07005197ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5198 $(hide) echo "no_recovery=true" >> $@
5199endif
5200ifdef BOARD_INCLUDE_RECOVERY_DTBO
5201 $(hide) echo "include_recovery_dtbo=true" >> $@
5202endif
5203ifdef BOARD_INCLUDE_RECOVERY_ACPIO
5204 $(hide) echo "include_recovery_acpio=true" >> $@
5205endif
5206ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
5207 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
5208endif
5209ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
5210 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
5211 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5212else
5213 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5214endif
5215 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
5216 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
Jacky Liubeb0b692021-12-29 16:29:05 +08005217ifdef PRODUCT_EXTRA_OTA_KEYS
5218 $(hide) echo "extra_ota_keys=$(PRODUCT_EXTRA_OTA_KEYS)" >> $@
5219endif
Daniel Normane1e48082019-06-27 13:55:23 -07005220ifdef PRODUCT_EXTRA_RECOVERY_KEYS
5221 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
5222endif
5223 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07005224 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005225 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Devin Moore380d9e42021-11-04 19:01:19 +00005226 $(hide) echo 'mkbootimg_init_args=$(BOARD_MKBOOTIMG_INIT_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005227ifdef BOARD_GKI_SIGNING_KEY_PATH
5228 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
5229 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005230 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
5231endif
Daniel Normane1e48082019-06-27 13:55:23 -07005232 $(hide) echo "multistage_support=1" >> $@
5233 $(hide) echo "blockimgdiff_versions=3,4" >> $@
5234ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
5235 $(hide) echo "build_generic_ota_package=true" >> $@
5236endif
5237ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
5238 # OTA scripts are only interested in fingerprint related properties
5239 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
5240endif
5241ifneq (,$(filter address, $(SANITIZE_TARGET)))
5242 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
5243 $(hide) echo "userdata_img_with_data=true" >> $@
5244endif
5245ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
5246 $(hide) echo "full_recovery_image=true" >> $@
5247endif
Bill Peckhame868aec2019-09-17 17:06:47 -07005248ifdef BOARD_USES_VENDORIMAGE
5249 $(hide) echo "board_uses_vendorimage=true" >> $@
5250endif
Daniel Normane1e48082019-06-27 13:55:23 -07005251ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08005252ifeq ($(BUILDING_VBMETA_IMAGE),true)
5253 $(hide) echo "avb_building_vbmeta_image=true" >> $@
5254endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005255 $(hide) echo "avb_enable=true" >> $@
5256 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
5257 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
5258 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
5259 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5260ifdef BOARD_AVB_BOOT_KEY_PATH
5261 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
5262 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
5263 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5264endif # BOARD_AVB_BOOT_KEY_PATH
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08005265 $(hide) echo "avb_init_boot_add_hash_footer_args=$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5266ifdef BOARD_AVB_INIT_BOOT_KEY_PATH
5267 $(hide) echo "avb_init_boot_key_path=$(BOARD_AVB_INIT_BOOT_KEY_PATH)" >> $@
5268 $(hide) echo "avb_init_boot_algorithm=$(BOARD_AVB_INIT_BOOT_ALGORITHM)" >> $@
5269 $(hide) echo "avb_init_boot_rollback_index_location=$(BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5270endif # BOARD_AVB_INIT_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07005271 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5272ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
5273 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
5274 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
5275 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5276endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Lucas Weif57333f2022-02-24 10:30:15 +08005277 echo "avb_vendor_kernel_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5278ifdef BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
5279 echo "avb_vendor_kernel_boot_key_path=$(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH)" >> $@
5280 echo "avb_vendor_kernel_boot_algorithm=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ALGORITHM)" >> $@
5281 echo "avb_vendor_kernel_boot_rollback_index_location=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5282endif # BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07005283 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
5284ifdef BOARD_AVB_RECOVERY_KEY_PATH
5285 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
5286 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
5287 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
5288endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07005289ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
5290 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
5291 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5292 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
5293 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
5294 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
5295 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
5296 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
5297 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
5298endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07005299ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
5300 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
5301 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
5302 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
5303 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
5304 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
5305endif # BOARD_AVB_VBMETA_SYSTEM
5306ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
5307 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
Bowgo Tsaic85a2012022-06-07 11:36:35 +08005308 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS)" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005309 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
5310 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
5311 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
5312endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
5313endif # BOARD_AVB_ENABLE
5314ifdef BOARD_BPT_INPUT_FILES
5315 $(hide) echo "board_bpt_enable=true" >> $@
5316 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
5317 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
5318endif
5319ifdef BOARD_BPT_DISK_SIZE
5320 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
5321endif
5322 $(call generate-userimage-prop-dictionary, $@)
5323ifeq ($(AB_OTA_UPDATER),true)
5324 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
5325 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
5326 $(hide) echo "ab_update=true" >> $@
5327endif
Yifan Hong65afc072020-04-17 10:08:10 -07005328ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
5329 $(hide) echo "allow_non_ab=true" >> $@
5330endif
Daniel Normane1e48082019-06-27 13:55:23 -07005331ifdef BOARD_PREBUILT_DTBOIMAGE
5332 $(hide) echo "has_dtbo=true" >> $@
5333ifeq ($(BOARD_AVB_ENABLE),true)
5334 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
5335 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
5336ifdef BOARD_AVB_DTBO_KEY_PATH
5337 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
5338 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
5339 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
5340endif # BOARD_AVB_DTBO_KEY_PATH
5341endif # BOARD_AVB_ENABLE
5342endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005343ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005344 $(hide) echo "has_pvmfw=true" >> $@
5345ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi592a3ca2021-10-04 11:34:11 +02005346 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@
Andrew Scull9b103e42020-11-29 14:04:28 +00005347 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
5348ifdef BOARD_AVB_PVMFW_KEY_PATH
5349 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
5350 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
5351 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
5352endif # BOARD_AVB_PVMFW_KEY_PATH
5353endif # BOARD_AVB_ENABLE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005354endif # BOARD_USES_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005355 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07005356 @# VINTF checks
5357ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
5358 $(hide) echo "vintf_enforce=true" >> $@
5359endif
5360ifdef ODM_MANIFEST_SKUS
5361 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
5362endif
Yifan Hong28ffd732020-03-13 13:11:10 -07005363ifdef ODM_MANIFEST_FILES
5364 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
5365endif
5366ifdef DEVICE_MANIFEST_SKUS
5367 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
5368endif
5369ifdef DEVICE_MANIFEST_FILE
5370 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
5371endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005372ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
5373 $(hide) echo "bootloader_in_update_package=true" >> $@
5374endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07005375ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
5376 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
5377endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05005378ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5379 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
5380endif
Jose Galmes9c8f6eb2021-07-21 09:34:08 -07005381ifeq ($(BUILDING_WITH_VSDK),true)
5382 $(hide) echo "building_with_vsdk=true" >> $@
5383endif
5384ifeq ($(TARGET_FLATTEN_APEX),false)
5385 $(hide) echo "target_flatten_apex=false" >> $@
5386endif
Daniel Normane1e48082019-06-27 13:55:23 -07005387
Bob Badourebdefc02022-02-12 15:39:22 -08005388$(call declare-0p-target,$(INSTALLED_MISC_INFO_TARGET))
5389
Daniel Normane1e48082019-06-27 13:55:23 -07005390.PHONY: misc_info
5391misc_info: $(INSTALLED_MISC_INFO_TARGET)
5392
Bill Peckham315b98a2021-06-15 19:35:06 -07005393droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
Daniel Normane1e48082019-06-27 13:55:23 -07005394
5395# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005396# A zip of the directories that map to the target filesystem.
5397# This zip can be used to create an OTA package or filesystem image
5398# as a post-build step.
5399#
5400name := $(TARGET_PRODUCT)
5401ifeq ($(TARGET_BUILD_TYPE),debug)
5402 name := $(name)_debug
5403endif
5404name := $(name)-target_files-$(FILE_NAME_TAG)
5405
5406intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
5407BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
5408$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
5409$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005410 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005411
5412# $(1): Directory to copy
5413# $(2): Location to copy it to
5414# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
5415define package_files-copy-root
5416 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
5417 mkdir -p $(2) && \
5418 $(ACP) -rd $(strip $(1))/* $(2); \
5419 fi
5420endef
5421
Tao Baoa04fca32015-11-30 12:22:24 -08005422built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07005423
5424# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08005425ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07005426built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07005427 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07005428endif
5429
The Android Open Source Project88b60792009-03-03 19:28:42 -08005430$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
5431
Dan Willemsen653bea92017-03-21 15:47:37 -07005432tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07005433$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07005434
HÃ¥kan Kvist8cabc712022-05-02 07:43:34 +02005435updater_dep :=
Sen Jiang4438fd92016-03-07 16:51:01 -08005436ifeq ($(AB_OTA_UPDATER),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005437updater_dep += system/update_engine/update_engine.conf
Bob Badour5acd4362022-04-12 18:31:35 -07005438$(call declare-1p-target,system/update_engine/update_engine.conf,system/update_engine)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005439updater_dep += external/zucchini/version_info.h
Bob Badour5acd4362022-04-12 18:31:35 -07005440$(call declare-license-metadata,external/zucchini/version_info.h,legacy_notice,notice,external/zucchini/LICENSE,external/zucchini)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005441updater_dep += $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so
Yifan Hong65afc072020-04-17 10:08:10 -07005442endif
5443
5444# Build OTA tools if non-A/B is allowed
5445ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005446updater_dep += $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07005447endif
Yifan Hong65afc072020-04-17 10:08:10 -07005448
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09005449$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07005450
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005451# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07005452# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005453ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5454$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07005455else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
5456$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005457else
5458$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
5459endif
5460
Dan Willemsen653bea92017-03-21 15:47:37 -07005461ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07005462 ifdef OSRELEASED_DIRECTORY
5463 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
5464 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
5465 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
5466 endif
Tao Baoa835f382019-07-18 15:55:30 -07005467
5468 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
5469 # additionally include radio or bootloader partitions).
5470 ifeq ($(AB_OTA_PARTITIONS),)
5471 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
5472 endif
5473endif
5474
5475ifneq ($(AB_OTA_PARTITIONS),)
5476 ifneq ($(AB_OTA_UPDATER),true)
5477 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
5478 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07005479endif
5480
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005481# Run fs_config while creating the target files package
5482# $1: root directory
5483# $2: add prefix
5484define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08005485(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 -08005486endef
5487
Yifan Hong60bfcc42019-11-01 11:39:45 -07005488define filter-out-missing-vendor
5489$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
5490endef
Petri Gynther09865a42021-03-10 18:23:39 -08005491define filter-out-missing-vendor_dlkm
5492$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
5493endef
5494define filter-out-missing-odm
5495$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
5496endef
5497define filter-out-missing-odm_dlkm
5498$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
5499endef
Ramji Jiyani13a41372022-01-27 07:05:08 +00005500define filter-out-missing-system_dlkm
5501$(if $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(1),$(filter-out system_dlkm,$(1)))
5502endef
5503# Filter out vendor,vendor_dlkm,odm,odm_dlkm,system_dlkm from the list for AOSP targets.
Petri Gynther09865a42021-03-10 18:23:39 -08005504# $(1): list
5505define filter-out-missing-partitions
5506$(call filter-out-missing-vendor,\
5507 $(call filter-out-missing-vendor_dlkm,\
5508 $(call filter-out-missing-odm,\
Ramji Jiyani13a41372022-01-27 07:05:08 +00005509 $(call filter-out-missing-odm_dlkm,\
5510 $(call filter-out-missing-system_dlkm,$(1))))))
Petri Gynther09865a42021-03-10 18:23:39 -08005511endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07005512
5513# Information related to dynamic partitions and virtual A/B. This information
5514# is needed for building the super image (see dump-super-image-info) and
5515# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08005516# $(1): file
5517define dump-dynamic-partitions-info
5518 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
5519 echo "use_dynamic_partitions=true" >> $(1))
5520 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
5521 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08005522 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
5523 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
5524 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00005525 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
5526 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08005527 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
5528 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005529 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
5530 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5531 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
5532 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5533 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
5534 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005535 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005536 $(if $(BOARD_SUPER_PARTITION_GROUPS),
5537 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
5538 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
5539 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
5540 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005541 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 -07005542 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
5543 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07005544 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
5545 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005546 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
5547 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005548 $(if $(BOARD_SUPER_PARTITION_SIZE), \
5549 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
5550 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
5551 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
5552 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
5553 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
5554 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
5555 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005556 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
5557 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05005558 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
5559 echo "virtual_ab_compression=true" >> $(1))
Kelvin Zhangfa91e982022-02-09 11:19:16 -08005560# This value controls the compression algorithm used for VABC
5561# valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
5562# e.g. "none", "gz", "brotli"
5563 $(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD), \
5564 echo "virtual_ab_compression_method=$(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005565 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
5566 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005567endef
5568
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005569# By conditionally including the dependency of the target files package on the
5570# full system image deps, we speed up builds that do not build the system
5571# image.
5572ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005573 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005574else
5575 # releasetools may need the system build.prop even when building a
5576 # system-image-less product.
5577 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BUILD_PROP_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005578endif
5579
5580ifdef BUILDING_USERDATA_IMAGE
5581 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
5582endif
5583
5584ifdef BUILDING_SYSTEM_OTHER_IMAGE
5585 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
5586endif
5587
5588ifdef BUILDING_VENDOR_BOOT_IMAGE
5589 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005590 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Devin Moore55af5062021-06-09 10:44:44 -07005591 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Colin Crosse6431202021-02-24 11:44:55 -08005592 # The vendor ramdisk may be built from the recovery ramdisk.
5593 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
5594 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
5595 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07005596endif
5597
5598ifdef BUILDING_RECOVERY_IMAGE
5599 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08005600 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07005601 # commands in build-recoveryimage-target, which would touch the files under
5602 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
5603 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5604 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5605 else
5606 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
5607 endif
5608 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
5609endif
5610
5611# Conditionally depend on the image files if the image is being built so the
5612# target-files.zip rule doesn't wait on the image creation rule, or the image
5613# if it is coming from a prebuilt.
5614
5615ifdef BUILDING_VENDOR_IMAGE
5616 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
5617else ifdef BOARD_PREBUILT_VENDORIMAGE
5618 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
5619endif
5620
5621ifdef BUILDING_PRODUCT_IMAGE
5622 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
5623else ifdef BOARD_PREBUILT_PRODUCTIMAGE
5624 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
5625endif
5626
5627ifdef BUILDING_SYSTEM_EXT_IMAGE
5628 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
5629else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
5630 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
5631endif
5632
Devin Moore380d9e42021-11-04 19:01:19 +00005633ifneq (,$(BUILDING_BOOT_IMAGE)$(BUILDING_INIT_BOOT_IMAGE))
Colin Cross43f2eb22020-08-26 18:41:29 -07005634 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Devin Moore380d9e42021-11-04 19:01:19 +00005635endif # BUILDING_BOOT_IMAGE != "" || BUILDING_INIT_BOOT_IMAGE != ""
5636
Yifan Hong49968aa2020-11-09 11:52:52 -08005637ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07005638 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5639endif
5640
5641ifdef BUILDING_ODM_IMAGE
5642 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
5643else ifdef BOARD_PREBUILT_ODMIMAGE
5644 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
5645endif
5646
5647ifdef BUILDING_VENDOR_DLKM_IMAGE
5648 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005649else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005650 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
5651endif
5652
5653ifdef BUILDING_ODM_DLKM_IMAGE
5654 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005655else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005656 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005657endif
5658
Ramji Jiyani13a41372022-01-27 07:05:08 +00005659ifdef BUILDING_SYSTEM_DLKM_IMAGE
5660 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
5661else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5662 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
5663endif
5664
Isaac Chen9e09d472019-07-05 17:30:41 +08005665ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07005666 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
5667 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08005668endif
5669
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005670ifdef BOARD_PREBUILT_BOOTLOADER
5671$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005672droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005673endif
5674
The Android Open Source Project88b60792009-03-03 19:28:42 -08005675# Depending on the various images guarantees that the underlying
5676# directories are up-to-date.
5677$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005678 $(INSTALLED_RADIOIMAGE_TARGET) \
5679 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005680 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005681 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00005682 $(INSTALLED_PVMFWIMAGE_TARGET) \
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01005683 $(INSTALLED_PVMFW_BINARY_TARGET) \
Andrew Scullbbc930b2022-02-17 22:34:27 +00005684 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07005685 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005686 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
5687 $(INSTALLED_KERNEL_TARGET) \
Enrico Granatab582e0f2020-10-14 15:17:20 -06005688 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005689 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005690 $(INSTALLED_2NDBOOTLOADER_TARGET) \
5691 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08005692 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005693 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005694 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5695 $(PRODUCT_VENDOR_BASE_FS_PATH) \
5696 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09005697 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005698 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07005699 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07005700 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00005701 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00005702 $(LPMAKE) \
5703 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07005704 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005705 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005706 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005707 $(SOONG_ZIP) \
5708 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07005709 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07005710 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005711 $(BUILT_KERNEL_CONFIGS_FILE) \
5712 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005713 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005714 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005715 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005716 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07005717ifneq (,$(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 -08005718 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005719 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005720# Exclude recovery files in the default vendor ramdisk if including a standalone
5721# recovery ramdisk in vendor_boot.
5722ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005723 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005724 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005725endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005726ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005727ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07005728 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07005729else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07005730 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
5731endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005732endif
Yifan Hong78860162020-10-28 14:15:21 -07005733ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005734ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005735 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005736endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005737ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08005738ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07005739 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08005740else
Steve Mucklee1b10862019-07-10 10:49:37 -07005741 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005742endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005743endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005744ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07005745 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005746endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005747ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005748 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005749endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005750ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07005751ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07005752 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07005753endif # INTERNAL_KERNEL_CMDLINE != ""
5754endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07005755ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005756 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005757endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005758ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005759 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005760endif
Yifan Hong3941a872020-10-28 16:33:06 -07005761endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005762endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08005763 @# Components of the boot image
5764 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07005765 $(hide) mkdir -p $(zip_root)/ROOT
5766 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005767 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08005768 @# If we are using recovery as boot, this is already done when processing recovery.
5769ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005770 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005771 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005772ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005773 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08005774endif
Yifan Hong46aff092020-10-28 13:50:47 -07005775ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07005776 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07005777else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07005778 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08005779ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005780 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005781endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005782ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005783 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005784endif
Doug Zongker38a649f2009-06-17 09:07:09 -07005785ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005786 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005787endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005788ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005789 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005790endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005791endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07005792endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07005793 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
5794 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07005795 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07005796ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5797 mkdir -p $(zip_root)/VENDOR_BOOT
5798 $(call package_files-copy-root, \
5799 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
5800ifdef INSTALLED_DTBIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005801ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
Steve Mucklee1b10862019-07-10 10:49:37 -07005802 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
5803endif
Lucas Weif57333f2022-02-24 10:30:15 +08005804endif # end of INSTALLED_DTBIMAGE_TARGET
Devin Moore50509012021-01-13 10:45:04 -08005805ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
5806 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
5807endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005808ifdef BOARD_KERNEL_BASE
5809 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
5810endif
5811ifdef BOARD_KERNEL_PAGESIZE
5812 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
5813endif
5814 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005815ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
5816 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
5817 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005818 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
5819 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
5820 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
5821 $(if $(prebuilt_ramdisk), \
5822 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
5823 $(call package_files-copy-root, \
5824 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
5825 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
5826 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005827endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07005828endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005829ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
5830 mkdir -p $(zip_root)/VENDOR_KERNEL_BOOT
5831 $(call package_files-copy-root, \
5832 $(TARGET_VENDOR_KERNEL_RAMDISK_OUT),$(zip_root)/VENDOR_KERNEL_BOOT/RAMDISK)
5833ifdef INSTALLED_DTBIMAGE_TARGET
5834 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_KERNEL_BOOT/dtb
5835endif
5836ifdef BOARD_KERNEL_PAGESIZE
5837 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_KERNEL_BOOT/pagesize
5838endif
5839endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08005840ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005841 @# Contents of the system image
5842 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005843 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005844else ifdef INSTALLED_BUILD_PROP_TARGET
5845 @# Copy the system build.prop even if not building a system image
5846 @# because add_img_to_target_files may need it to build other partition
5847 @# images.
5848 $(hide) mkdir -p "$(zip_root)/SYSTEM"
5849 $(hide) cp "$(INSTALLED_BUILD_PROP_TARGET)" "$(patsubst $(TARGET_OUT)/%,$(zip_root)/SYSTEM/%,$(INSTALLED_BUILD_PROP_TARGET))"
Dan Willemsen67495202019-01-16 12:42:05 -08005850endif
5851ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005852 @# Contents of the data image
5853 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005854 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08005855endif
5856ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07005857 @# Contents of the vendor image
5858 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005859 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07005860endif
Dan Willemsen67495202019-01-16 12:42:05 -08005861ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005862 @# Contents of the product image
5863 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005864 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005865endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005866ifdef BUILDING_SYSTEM_EXT_IMAGE
5867 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01005868 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09005869 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01005870endif
Dan Willemsen67495202019-01-16 12:42:05 -08005871ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005872 @# Contents of the odm image
5873 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005874 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005875endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005876ifdef BUILDING_VENDOR_DLKM_IMAGE
5877 @# Contents of the vendor_dlkm image
5878 $(hide) $(call package_files-copy-root, \
5879 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
5880endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005881ifdef BUILDING_ODM_DLKM_IMAGE
5882 @# Contents of the odm_dlkm image
5883 $(hide) $(call package_files-copy-root, \
5884 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
5885endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005886ifdef BUILDING_SYSTEM_DLKM_IMAGE
5887 @# Contents of the system_dlkm image
5888 $(hide) $(call package_files-copy-root, \
5889 $(TARGET_OUT_SYSTEM_DLKM),$(zip_root)/SYSTEM_DLKM)
5890endif
Dan Willemsen67495202019-01-16 12:42:05 -08005891ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07005892 @# Contents of the system_other image
5893 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005894 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07005895endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005896 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07005897 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07005898 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granatab582e0f2020-10-14 15:17:20 -06005899ifdef BUILDING_RAMDISK_IMAGE
5900ifeq (true,$(BOARD_IMG_USE_RAMDISK))
5901 @# Contents of the ramdisk image
5902 $(hide) mkdir -p $(zip_root)/IMAGES
5903 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
5904endif
5905endif
Yifan Hong65afc072020-04-17 10:08:10 -07005906ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08005907ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07005908 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07005909 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07005910endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08005911endif
Doug Zongker8678df42009-06-15 14:30:14 -07005912 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08005913 @# build them.
5914 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07005915 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005916 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005917ifneq ($(tool_extension),)
5918 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
5919endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07005920 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005921 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07005922 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00005923ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
5924 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5925 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005926endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005927ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
5928 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
5929 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005930endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005931ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
5932 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
5933 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005934endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005935ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
5936 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
5937 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01005938endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005939ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
5940 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
5941 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005942endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005943ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
5944 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
5945 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
5946endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005947ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
5948 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
5949 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
5950endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005951ifneq ($(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH),)
5952 $(hide) cp $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
5953 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH))
5954endif
Yifan Hong65afc072020-04-17 10:08:10 -07005955ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07005956ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07005957 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07005958 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07005959endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08005960endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005961ifeq ($(AB_OTA_UPDATER),true)
5962 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07005963 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Kelvin Zhangc06f0622021-11-30 12:38:39 -08005964 $(hide) cp $(TOPDIR)external/zucchini/version_info.h $(zip_root)/META/zucchini_config.txt
Kelvin Zhang6877e812022-01-06 11:12:04 -08005965 $(hide) cp $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so $(zip_root)/META/liblz4.so
Cole Faust90099992022-02-17 11:35:27 -08005966 $(hide) for part in $(sort $(AB_OTA_PARTITIONS)); do \
Alex Deymo8925d332015-10-01 17:38:09 -07005967 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
5968 done
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005969 $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
Sen Jiang8f22e2a2015-11-12 13:53:25 -08005970 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
5971 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005972ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07005973 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
5974 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
5975 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005976endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005977endif
Steve Fungdfbab492015-09-24 18:12:33 -07005978ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07005979 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07005980 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07005981endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07005982ifdef BOARD_PREBUILT_VENDORIMAGE
5983 $(hide) mkdir -p $(zip_root)/IMAGES
5984 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
5985endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005986ifdef BOARD_PREBUILT_PRODUCTIMAGE
5987 $(hide) mkdir -p $(zip_root)/IMAGES
5988 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
5989endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005990ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01005991 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09005992 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01005993endif
Devin Moore380d9e42021-11-04 19:01:19 +00005994ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
Devin Moorecda41f02022-01-05 00:08:39 +00005995 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5996 $(hide) cp $(INSTALLED_INIT_BOOT_IMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Devin Moore380d9e42021-11-04 19:01:19 +00005997endif
Ramji Jiyani034e7772022-01-24 04:00:29 +00005998
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005999ifndef BOARD_PREBUILT_BOOTIMAGE
Yi-Yo Chiang81939002022-01-08 23:46:40 +08006000ifneq (,$(strip $(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES))))
Yifan Hong49968aa2020-11-09 11:52:52 -08006001ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07006002 $(hide) mkdir -p $(zip_root)/IMAGES
6003 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08006004endif # INSTALLED_BOOTIMAGE_TARGET
6005endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaib23656d2021-05-20 00:14:42 +08006006else # BOARD_PREBUILT_BOOTIMAGE is defined
6007 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6008 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
6009endif # BOARD_PREBUILT_BOOTIMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006010ifdef BOARD_PREBUILT_ODMIMAGE
6011 $(hide) mkdir -p $(zip_root)/IMAGES
6012 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
6013endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07006014ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07006015 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07006016 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
6017endif
6018ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
6019 $(hide) mkdir -p $(zip_root)/IMAGES
6020 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07006021endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006022ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
6023 $(hide) mkdir -p $(zip_root)/IMAGES
6024 $(hide) cp $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
6025endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07006026ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07006027 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6028 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08006029endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01006030ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00006031 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6032 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Andrew Scullbbc930b2022-02-17 22:34:27 +00006033 $(hide) cp $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) $(zip_root)/PREBUILT_IMAGES/
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01006034 $(hide) mkdir -p $(zip_root)/PVMFW
6035 $(hide) cp $(INSTALLED_PVMFW_BINARY_TARGET) $(zip_root)/PVMFW/
Pierre-Clément Tosid8248af2021-10-07 12:18:17 +02006036endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00006037ifdef BOARD_PREBUILT_BOOTLOADER
6038 $(hide) mkdir -p $(zip_root)/IMAGES
6039 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
6040endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07006041ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
6042 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6043 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
6044 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
6045endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07006046 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
6047 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
6048 @# INSTALLED_RADIOIMAGE_TARGET.
6049 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
6050 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006051 @# Run fs_config on all the system, vendor, boot ramdisk,
6052 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08006053ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006054 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08006055endif
6056ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006057 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
6058endif
Dan Willemsen67495202019-01-16 12:42:05 -08006059ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006060 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
6061endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006062ifdef BUILDING_SYSTEM_EXT_IMAGE
6063 $(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 +01006064endif
Dan Willemsen67495202019-01-16 12:42:05 -08006065ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006066 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
6067endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006068ifdef BUILDING_VENDOR_DLKM_IMAGE
6069 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
6070endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07006071ifdef BUILDING_ODM_DLKM_IMAGE
6072 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
6073endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006074ifdef BUILDING_SYSTEM_DLKM_IMAGE
6075 $(hide) $(call fs_config,$(zip_root)/SYSTEM_DLKM,system_dlkm/) > $(zip_root)/META/system_dlkm_filesystem_config.txt
6076endif
Tom Cherryd14b8952018-08-09 14:26:00 -07006077 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006078 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08006079 @# BOOT/RAMDISK contains the first stage and recovery ramdisk.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006080 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Devin Moore380d9e42021-11-04 19:01:19 +00006081ifdef BUILDING_INIT_BOOT_IMAGE
6082 $(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK)
6083 $(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt
6084ifdef BOARD_KERNEL_PAGESIZE
6085 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize
6086endif # BOARD_KERNEL_PAGESIZE
6087endif # BUILDING_INIT_BOOT_IMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07006088ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
6089 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
6090endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006091ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
6092 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
6093endif
Dan Willemsen67495202019-01-16 12:42:05 -08006094ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006095 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
6096endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07006097 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07006098ifdef BUILT_KERNEL_CONFIGS_FILE
6099 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
6100endif
6101ifdef BUILT_KERNEL_VERSION_FILE
6102 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
6103endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07006104 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
6105ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6106 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
6107endif
Tao Baocbd6d492019-10-07 22:46:02 -07006108 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
6109 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08006110ifeq ($(BUILD_QEMU_IMAGES),true)
6111 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
6112 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
6113endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08006114 @# Zip everything up, preserving symlinks and placing META/ files first to
6115 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006116 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07006117 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08006118 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07006119
Ying Wanga0febe52013-03-20 11:02:05 -07006120.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08006121target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
6122
Bob Badour5acd4362022-04-12 18:31:35 -07006123$(call declare-1p-container,$(BUILT_TARGET_FILES_PACKAGE),)
6124$(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED_RADIOIMAGE_TARGET) \
6125 $(INSTALLED_RECOVERYIMAGE_TARGET) \
6126 $(INSTALLED_CACHEIMAGE_TARGET) \
6127 $(INSTALLED_DTBOIMAGE_TARGET) \
6128 $(INSTALLED_PVMFWIMAGE_TARGET) \
6129 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
6130 $(INSTALLED_CUSTOMIMAGES_TARGET) \
6131 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
6132 $(INSTALLED_KERNEL_TARGET) \
6133 $(INSTALLED_RAMDISK_TARGET) \
6134 $(INSTALLED_DTBIMAGE_TARGET) \
6135 $(INSTALLED_2NDBOOTLOADER_TARGET) \
6136 $(BOARD_PREBUILT_DTBOIMAGE) \
6137 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
6138 $(BOARD_RECOVERY_ACPIO) \
6139 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
6140 $(PRODUCT_VENDOR_BASE_FS_PATH) \
6141 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
6142 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
6143 $(PRODUCT_ODM_BASE_FS_PATH) \
6144 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
6145 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
6146 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
6147 $(LPMAKE) \
6148 $(SELINUX_FC) \
6149 $(INSTALLED_MISC_INFO_TARGET) \
6150 $(APKCERTS_FILE) \
6151 $(SOONG_APEX_KEYS_FILE) \
6152 $(HOST_OUT_EXECUTABLES)/fs_config \
6153 $(ADD_IMG_TO_TARGET_FILES) \
6154 $(MAKE_RECOVERY_PATCH) \
6155 $(BUILT_KERNEL_CONFIGS_FILE) \
6156 $(BUILT_KERNEL_VERSION_FILE),$(BUILT_TARGET_FILES_PACKAGE):)
6157
Ying Wang4709d7c2014-04-14 17:25:43 -07006158$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07006159
Dan Albert4d323332016-10-14 13:23:06 -07006160# -----------------------------------------------------------------
6161# NDK Sysroot Package
6162NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Colin Crossec65b762022-10-20 14:03:47 -07006163.PHONY: ndk_sysroot
6164ndk_sysroot: $(NDK_SYSROOT_TARGET)
Dan Willemsen14e10262018-06-17 21:54:21 -07006165$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07006166 @echo Package NDK sysroot...
6167 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
6168
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006169ifeq ($(HOST_OS),linux)
Colin Crossec65b762022-10-20 14:03:47 -07006170$(call dist-for-goals,sdk ndk_sysroot,$(NDK_SYSROOT_TARGET))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006171endif
Dan Albert4d323332016-10-14 13:23:06 -07006172
Ying Wang09c4b682015-08-11 11:24:19 -07006173ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07006174# -----------------------------------------------------------------
6175# OTA update package
6176
Yifan Hong50e79542018-11-08 17:44:12 -08006177# $(1): output file
6178# $(2): additional args
6179define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07006180PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07006181 $(OTA_FROM_TARGET_FILES) \
6182 --verbose \
6183 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
6184 --path $(HOST_OUT) \
6185 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
6186 $(2) \
6187 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08006188endef
6189
Tianjie6bd3b1a2020-10-16 18:53:47 -07006190product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07006191ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006192 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07006193endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07006194name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07006195
6196INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08006197INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
6198
Bob Badour5acd4362022-04-12 18:31:35 -07006199$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
6200
Doug Zongker8678df42009-06-15 14:30:14 -07006201$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08006202$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07006203$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07006204 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08006205 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07006206
Bob Badour5acd4362022-04-12 18:31:35 -07006207$(call declare-1p-container,$(INTERNAL_OTA_PACKAGE_TARGET),)
6208$(call declare-container-license-deps,$(INTERNAL_OTA_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6209
Doug Zongker8678df42009-06-15 14:30:14 -07006210.PHONY: otapackage
6211otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
6212
Tao Bao519d1822018-12-27 12:47:23 -08006213ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006214name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08006215
6216INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08006217$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07006218$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
6219 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07006220 $(OTA_FROM_TARGET_FILES) \
6221 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08006222 @echo "Package OTA (retrofit dynamic partitions): $@"
6223 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
6224
Bob Badour5acd4362022-04-12 18:31:35 -07006225$(call declare-1p-container,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),)
6226$(call declare-container-license-deps,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6227
Yifan Hong50e79542018-11-08 17:44:12 -08006228.PHONY: otardppackage
6229
6230otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
6231
Tao Bao519d1822018-12-27 12:47:23 -08006232endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08006233
Tianjie6bd3b1a2020-10-16 18:53:47 -07006234ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
6235name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
6236
6237INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6238$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
6239$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
6240 @echo "Package partial OTA: $@"
6241 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
6242
Bob Badour5acd4362022-04-12 18:31:35 -07006243$(call declare-1p-container,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),)
6244$(call declare-container-license-deps,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6245
6246
Tianjie6bd3b1a2020-10-16 18:53:47 -07006247.PHONY: partialotapackage
6248partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
6249
6250endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
6251
Ying Wang09c4b682015-08-11 11:24:19 -07006252endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07006253
Ying Wang09a00a62010-10-20 14:01:09 -07006254# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01006255# A zip of the appcompat directory containing logs
6256APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
6257# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006258ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07006259$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
6260 $(INTERNAL_RAMDISK_FILES) \
6261 $(INTERNAL_USERDATAIMAGE_FILES) \
6262 $(INTERNAL_VENDORIMAGE_FILES) \
6263 $(INTERNAL_PRODUCTIMAGE_FILES) \
6264 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01006265endif
6266$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
6267$(APPCOMPAT_ZIP): $(SOONG_ZIP)
6268 @echo "appcompat logs: $@"
6269 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6270 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
6271 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
6272 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
6273
Jeongik Cha2522c362021-04-27 23:52:15 +09006274# The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
6275ifeq ($(BUILD_OS),linux)
Jeongik Cha62519de2021-05-13 13:29:39 +09006276ifneq ($(DEX2OAT),)
Saeid Farivar Asanjan0b4f8d52022-08-08 20:23:45 +00006277dexpreopt_tools_deps := $(DEXPREOPT_GEN_DEPS) $(DEXPREOPT_GEN)
Eric Miao1d0fd2c2021-11-08 19:34:50 +00006278dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/dexdump
6279dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/oatdump
Jeongik Cha2522c362021-04-27 23:52:15 +09006280DEXPREOPT_TOOLS_ZIP := $(PRODUCT_OUT)/dexpreopt_tools.zip
6281$(DEXPREOPT_TOOLS_ZIP): $(dexpreopt_tools_deps)
6282$(DEXPREOPT_TOOLS_ZIP): PRIVATE_DEXPREOPT_TOOLS_DEPS := $(dexpreopt_tools_deps)
6283$(DEXPREOPT_TOOLS_ZIP): $(SOONG_ZIP)
6284 $(hide) mkdir -p $(dir $@)
6285 $(hide) $(SOONG_ZIP) -d -o $@ -j $(addprefix -f ,$(PRIVATE_DEXPREOPT_TOOLS_DEPS)) -f $$(realpath $(DEX2OAT))
Bob Badour5acd4362022-04-12 18:31:35 -07006286$(call declare-1p-target,$(DEXPREOPT_TOOLS_ZIP),)
Jeongik Cha62519de2021-05-13 13:29:39 +09006287endif # DEX2OAT is set
6288endif # BUILD_OS == linux
Jeongik Cha2522c362021-04-27 23:52:15 +09006289
Jeongik Chaa8056d62021-04-07 23:57:16 +09006290DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
Jeongik Chab26bf582021-06-08 11:31:31 +09006291
6292$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
6293 $(INSTALLED_VENDORIMAGE_TARGET) \
6294 $(INSTALLED_ODMIMAGE_TARGET) \
6295 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6296
6297ifeq (,$(TARGET_BUILD_UNBUNDLED))
6298$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
6299 $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
6300
6301endif
Jeongik Chaa8056d62021-04-07 23:57:16 +09006302
6303$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
6304 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Chab26bf582021-06-08 11:31:31 +09006305
6306ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006307ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006308 $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006309endif
6310ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006311 $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006312endif
Jeongik Chab26bf582021-06-08 11:31:31 +09006313endif #!TARGET_BUILD_UNBUNDLED
Jeongik Chaa8056d62021-04-07 23:57:16 +09006314 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
6315
Jeongik Chab26bf582021-06-08 11:31:31 +09006316.PHONY: dexpreopt_config_zip
6317dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
6318
Bob Badour5acd4362022-04-12 18:31:35 -07006319$(call declare-1p-target,$(DEXPREOPT_CONFIG_ZIP),)
6320
Dario Frenid1011272018-07-23 20:20:15 +01006321# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006322# A zip of the symbols directory. Keep the full paths to make it
6323# more obvious where these files came from.
Colin Crossac7febc2022-04-06 01:11:20 +00006324# Also produces a textproto containing mappings from elf IDs to symbols
6325# filename, which will allow finding the appropriate symbols to deobfuscate
6326# a stack trace frame.
The Android Open Source Project88b60792009-03-03 19:28:42 -08006327#
Colin Crossac7febc2022-04-06 01:11:20 +00006328
The Android Open Source Project88b60792009-03-03 19:28:42 -08006329name := $(TARGET_PRODUCT)
6330ifeq ($(TARGET_BUILD_TYPE),debug)
6331 name := $(name)_debug
6332endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006333
Colin Crossac7febc2022-04-06 01:11:20 +00006334# The path to the zip file containing binaries with symbols.
6335SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols-$(FILE_NAME_TAG).zip
6336# The path to a file containing mappings from elf IDs to filenames.
6337SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping-$(FILE_NAME_TAG).textproto
6338.KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING
Colin Cross6cdc5d22017-10-20 11:37:33 -07006339# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006340ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006341$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07006342endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006343$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
Colin Crossac7febc2022-04-06 01:11:20 +00006344$(SYMBOLS_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)
6345$(SYMBOLS_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006346 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006347 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006348 $(hide) mkdir -p $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE)) $(PRIVATE_MAPPING_PACKAGING_DIR)
6349 # Find all of the files in the symbols directory and zip them into the symbols zip.
Jiyong Park88e09802019-03-21 15:19:16 +09006350 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07006351 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006352 # Find all of the files in the symbols mapping directory and merge them into the symbols mapping textproto.
6353 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6354 $(hide) $(SYMBOLS_MAP) -merge $(SYMBOLS_MAPPING) -ignore_missing_files @$(PRIVATE_LIST_FILE)
6355$(SYMBOLS_ZIP): .KATI_IMPLICIT_OUTPUTS := $(SYMBOLS_MAPPING)
6356
Bob Badour5acd4362022-04-12 18:31:35 -07006357$(call declare-1p-container,$(SYMBOLS_ZIP),)
6358ifeq (,$(TARGET_BUILD_UNBUNDLED))
6359$(call declare-container-license-deps,$(SYMBOLS_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6360endif
6361
Ryan Campbell81c9d292016-09-12 13:56:50 -07006362# -----------------------------------------------------------------
6363# A zip of the coverage directory.
6364#
Oliver Nguyene91ab232019-04-30 15:14:44 -07006365name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07006366ifeq ($(TARGET_BUILD_TYPE),debug)
6367name := $(name)_debug
6368endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07006369COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006370ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006371$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07006372endif
6373$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
6374$(COVERAGE_ZIP): $(SOONG_ZIP)
6375 @echo "Package coverage: $@"
6376 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6377 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
6378 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
6379 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006380
Bob Badourf2529722022-03-18 11:34:03 -07006381$(call declare-1p-container,$(COVERAGE_ZIP),)
Bob Badour5acd4362022-04-12 18:31:35 -07006382ifeq (,$(TARGET_BUILD_UNBUNDLED))
Bob Badourf2529722022-03-18 11:34:03 -07006383$(call declare-container-license-deps,$(COVERAGE_ZIP),$(INTERNAL_ALLIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badour5acd4362022-04-12 18:31:35 -07006384endif
Bob Badourf2529722022-03-18 11:34:03 -07006385
6386SYSTEM_NOTICE_DEPS += $(COVERAGE_ZIP)
6387
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006388#------------------------------------------------------------------
6389# Export the LLVM profile data tool and dependencies for Clang coverage processing
6390#
6391ifeq (true,$(CLANG_COVERAGE))
6392 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006393 LLVM_COV := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov
Qing Shend058fc32022-09-30 00:27:58 +00006394 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib/x86_64-unknown-linux-gnu/libc++.so.1
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006395 # Use llvm-profdata.zip for backwards compatibility with tradefed code.
6396 LLVM_COVERAGE_TOOLS_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006397
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006398 $(LLVM_COVERAGE_TOOLS_ZIP): $(SOONG_ZIP)
6399 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX) -f $(LLVM_COV)
6400
6401 $(call dist-for-goals,droidcore-unbundled apps_only,$(LLVM_COVERAGE_TOOLS_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006402endif
6403
The Android Open Source Project88b60792009-03-03 19:28:42 -08006404# -----------------------------------------------------------------
6405# A zip of the Android Apps. Not keeping full path so that we don't
6406# include product names when distributing
6407#
6408name := $(TARGET_PRODUCT)
6409ifeq ($(TARGET_BUILD_TYPE),debug)
6410 name := $(name)_debug
6411endif
6412name := $(name)-apps-$(FILE_NAME_TAG)
6413
6414APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07006415$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006416 @echo "Package apps: $@"
6417 $(hide) rm -rf $@
6418 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006419 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
6420 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00006421 echo "No apps to zip up. Generating empty apps archive." ; \
6422 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006423 else \
Anton Hansson6d814982018-11-26 18:12:05 +00006424 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006425 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07006426
Ying Wangbc415dd2012-08-15 12:22:44 -07006427ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07006428#------------------------------------------------------------------
6429# An archive of classes for use in generating code-coverage reports
6430# These are the uninstrumented versions of any classes that were
6431# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07006432# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006433
Colin Crossa6bc3a82017-09-27 14:28:41 -07006434JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Colin Cross330b1fe2021-04-06 18:04:06 -07006435$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
6436$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
6437$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
6438$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006439$(JACOCO_REPORT_CLASSES_ALL) :
6440 @echo "Collecting uninstrumented classes"
Colin Cross330b1fe2021-04-06 18:04:06 -07006441 mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
6442 $(SOONG_ZIP) -o $@ -L 0 \
6443 -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
6444 -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
6445 -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
6446 -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006447
Jiyong Park3c875602021-01-21 12:46:56 +09006448ifeq (,$(TARGET_BUILD_UNBUNDLED))
6449 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
6450endif
Ying Wangbc415dd2012-08-15 12:22:44 -07006451endif # EMMA_INSTRUMENT=true
6452
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006453
Ying Wangae9115a2013-08-22 20:52:47 -07006454#------------------------------------------------------------------
6455# A zip of Proguard obfuscation dictionary files.
Colin Crossac7febc2022-04-06 01:11:20 +00006456# Also produces a textproto containing mappings from the hashes of the
6457# dictionary contents (which are also stored in the dex files on the
6458# devices) to the filename of the proguard dictionary, which will allow
6459# finding the appropriate dictionary to deobfuscate a stack trace frame.
Ying Wangae9115a2013-08-22 20:52:47 -07006460#
Colin Crossac7febc2022-04-06 01:11:20 +00006461
6462# The path to the zip file containing proguard dictionaries.
Ying Wangc62c92c2013-08-28 18:38:25 -07006463PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Crossac7febc2022-04-06 01:11:20 +00006464# The path to the zip file containing mappings from dictionary hashes to filenames.
6465PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping-$(FILE_NAME_TAG).textproto
6466.KATI_READONLY := PROGUARD_DICT_ZIP PROGUARD_DICT_MAPPING
Colin Cross114e8df2019-09-05 17:19:35 -07006467# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006468ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006469$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07006470endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006471$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
Colin Crossac7febc2022-04-06 01:11:20 +00006472$(PROGUARD_DICT_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)
6473$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_filelist)/filelist
6474$(PROGUARD_DICT_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
Ying Wangae9115a2013-08-22 20:52:47 -07006475 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossac7febc2022-04-06 01:11:20 +00006476 rm -rf $@ $(PRIVATE_LIST_FILE)
6477 mkdir -p $(PRIVATE_PACKAGING_DIR) $(PRIVATE_MAPPING_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6478 # Zip all of the files in the proguard dictionary directory.
6479 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -D $(PRIVATE_PACKAGING_DIR)
6480 # Find all of the files in the proguard dictionary mapping directory and merge them into the mapping textproto.
6481 # Strip the PRIVATE_PACKAGING_DIR off the filenames to match soong_zip's -C argument.
6482 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6483 $(SYMBOLS_MAP) -merge $(PROGUARD_DICT_MAPPING) -strip_prefix $(PRIVATE_PACKAGING_DIR)/ -ignore_missing_files @$(PRIVATE_LIST_FILE)
6484$(PROGUARD_DICT_ZIP): .KATI_IMPLICIT_OUTPUTS := $(PROGUARD_DICT_MAPPING)
Ying Wangae9115a2013-08-22 20:52:47 -07006485
Bob Badour5acd4362022-04-12 18:31:35 -07006486$(call declare-1p-container,$(PROGUARD_DICT_ZIP),)
6487ifeq (,$(TARGET_BUILD_UNBUNDLED))
6488$(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6489endif
6490
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006491#------------------------------------------------------------------
6492# A zip of Proguard usage files.
6493#
6494PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
6495# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
6496ifeq (,$(TARGET_BUILD_UNBUNDLED))
6497$(PROGUARD_USAGE_ZIP): \
6498 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6499 $(INSTALLED_RAMDISK_TARGET) \
6500 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00006501 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006502 $(INSTALLED_USERDATAIMAGE_TARGET) \
6503 $(INSTALLED_VENDORIMAGE_TARGET) \
6504 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6505 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6506 $(INSTALLED_ODMIMAGE_TARGET) \
6507 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6508 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00006509 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006510 $(updater_dep)
6511endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006512$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
6513$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006514$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
6515 @echo "Packaging Proguard usage files."
Colin Cross330b1fe2021-04-06 18:04:06 -07006516 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6517 find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006518 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07006519
Bob Badour5acd4362022-04-12 18:31:35 -07006520$(call declare-1p-container,$(PROGUARD_USAGE_ZIP),)
6521ifeq (,$(TARGET_BUILD_UNBUNDLED))
6522$(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(INSTALLED_SYSTEMIMAGE_TARGET) \
6523 $(INSTALLED_RAMDISK_TARGET) \
6524 $(INSTALLED_BOOTIMAGE_TARGET) \
6525 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
6526 $(INSTALLED_USERDATAIMAGE_TARGET) \
6527 $(INSTALLED_VENDORIMAGE_TARGET) \
6528 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6529 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6530 $(INSTALLED_ODMIMAGE_TARGET) \
6531 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6532 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
6533 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
6534 $(updater_dep),$(PROGUARD_USAGE_ZIP):/)
6535endif
6536
Tao Bao48a2feb2019-06-28 11:00:05 -07006537ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6538
6539# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
6540# $(1): output file
6541define dump-super-image-info
6542 $(call dump-dynamic-partitions-info,$(1))
6543 $(if $(filter true,$(AB_OTA_UPDATER)), \
6544 echo "ab_update=true" >> $(1))
6545endef
6546
6547endif # PRODUCT_USE_DYNAMIC_PARTITIONS
6548
The Android Open Source Project88b60792009-03-03 19:28:42 -08006549# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07006550# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08006551
6552ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6553
6554# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
6555ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6556
6557ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07006558
6559# For real devices and for dist builds, build super image from target files to an intermediate directory.
6560INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
6561$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
6562$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
6563 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08006564 PATH=$(dir $(LPMAKE)):$$PATH \
6565 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07006566
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006567# Skip packing it in dist package because it is in update package.
6568ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07006569$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006570endif
Yifan Hongacd862a2019-04-16 15:44:30 -07006571
6572.PHONY: superimage_dist
6573superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07006574
6575endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07006576endif # BOARD_SUPER_PARTITION_SIZE != ""
6577endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08006578
Yifan Hongacd862a2019-04-16 15:44:30 -07006579# -----------------------------------------------------------------
6580# super partition image for development
6581
6582ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6583ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6584ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
6585
6586# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
6587# $(1): built image path
6588# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
6589define build-superimage-target
6590 mkdir -p $(dir $(2))
6591 rm -rf $(2)
6592 $(call dump-super-image-info,$(2))
6593 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
6594 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09006595 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
6596 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07006597 mkdir -p $(dir $(1))
6598 PATH=$(dir $(LPMAKE)):$$PATH \
6599 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
6600endef
6601
6602INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
6603INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
6604 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
6605
changho.shina8f9f112019-10-15 13:26:19 +09006606ifdef BUILDING_SYSTEM_OTHER_IMAGE
6607ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
6608INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
6609endif
6610endif
6611
Yifan Hongacd862a2019-04-16 15:44:30 -07006612$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6613 $(call pretty,"Target super fs image for debug: $@")
6614 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08006615 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006616
Yifan Hongacd862a2019-04-16 15:44:30 -07006617# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
6618.PHONY: superimage
6619superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08006620
Peter Collingbourne683c4932022-07-06 15:49:20 -07006621# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
6622# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
6623# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
6624# virtual devices.
6625ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
6626droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
6627
Isaac Chen52cc60c2019-08-14 18:52:13 +08006628$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006629endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
6630
6631# Build $(PRODUCT_OUT)/super.img without dependencies.
6632.PHONY: superimage-nodeps supernod
6633superimage-nodeps supernod: intermediates :=
6634superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6635 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
6636 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
6637 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
6638
6639endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
6640endif # BOARD_SUPER_PARTITION_SIZE != ""
6641endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
6642
6643# -----------------------------------------------------------------
6644# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00006645ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006646
Yifan Hong8b79d162018-11-29 12:32:00 -08006647INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
6648$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
6649$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
6650 $(call pretty,"Target empty super fs image: $@")
6651 mkdir -p $(intermediates)
6652 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07006653 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08006654 PATH=$(dir $(LPMAKE)):$$PATH \
6655 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08006656
6657$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6658
Bob Badourebdefc02022-02-12 15:39:22 -08006659$(call declare-0p-target,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6660
Yo Chiange86bab42021-03-25 10:12:28 +00006661endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006662
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006663
6664# -----------------------------------------------------------------
6665# The update package
6666
6667name := $(TARGET_PRODUCT)
6668ifeq ($(TARGET_BUILD_TYPE),debug)
6669 name := $(name)_debug
6670endif
6671name := $(name)-img-$(FILE_NAME_TAG)
6672
6673INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6674
Tao Bao57f8ed62019-08-14 23:08:18 -07006675$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
6676 $(call pretty,"Package: $@")
6677 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
6678 $(IMG_FROM_TARGET_FILES) \
6679 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
6680 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006681
Bob Badour5acd4362022-04-12 18:31:35 -07006682$(call declare-1p-container,$(INTERNAL_UPDATE_PACKAGE_TARGET),)
6683$(call declare-container-license-deps,$(INTERNAL_UPDATE_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES),$(PRODUCT_OUT)/:/)
6684
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006685.PHONY: updatepackage
6686updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07006687$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006688
6689
Yifan Hong2b891ac2018-11-29 12:06:31 -08006690# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006691# dalvik something
6692.PHONY: dalvikfiles
6693dalvikfiles: $(INTERNAL_DALVIK_MODULES)
6694
Bo Huf0d50bb2017-08-01 19:02:09 +00006695ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00006696MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08006697MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00006698SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08006699
6700ifdef INSTALLED_SYSTEMIMAGE_TARGET
6701INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08006702INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
6703$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
6704 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
6705 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08006706$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08006707 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
6708 @echo Create system-qemu.img now
6709 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08006710 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00006711
6712systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006713droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08006714endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006715ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00006716INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006717$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00006718 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006719 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00006720
6721vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006722droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
Bo Huf0d50bb2017-08-01 19:02:09 +00006723endif
bohu8fd437c2020-03-30 20:16:13 -07006724
6725ifdef INSTALLED_RAMDISK_TARGET
6726ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
6727ifdef INTERNAL_VENDOR_RAMDISK_TARGET
6728INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
6729$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
6730 @echo Create ramdisk-qemu.img
6731 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
6732
Bill Peckham315b98a2021-06-15 19:35:06 -07006733droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
bohu8fd437c2020-03-30 20:16:13 -07006734endif
6735endif
6736endif
6737
Anton Hansson32c76fe2018-12-13 14:34:18 +00006738ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006739INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006740$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006741 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006742 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006743
6744productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006745droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006746endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006747ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
6748INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
6749$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
6750 @echo Create system_ext-qemu.img
6751 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01006752
Justin Yun6151e3f2019-06-25 15:58:13 +09006753systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006754droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01006755endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006756ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006757INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
6758$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6759 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006760 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006761
6762odmimage: $(INSTALLED_QEMU_ODMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006763droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006764endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006765
Yifan Hongcfb917a2020-05-07 14:58:20 -07006766ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
6767INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
6768$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6769 @echo Create vendor_dlkm-qemu.img
6770 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
6771
6772vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006773droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07006774endif
6775
Yifan Hongf496f1b2020-07-15 16:52:59 -07006776ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
6777INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
6778$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6779 @echo Create odm_dlkm-qemu.img
6780 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
6781
6782odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006783droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07006784endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006785
Ramji Jiyani13a41372022-01-27 07:05:08 +00006786ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
6787INSTALLED_QEMU_SYSTEM_DLKMIMAGE := $(PRODUCT_OUT)/system_dlkm-qemu.img
6788$(INSTALLED_QEMU_SYSTEM_DLKMIMAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6789 @echo Create system_dlkm-qemu.img
6790 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET))
6791
6792system_dlkmimage: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6793droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6794endif
6795
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006796QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08006797$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
6798 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006799 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08006800 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
6801 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006802
6803systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
Bill Peckham315b98a2021-06-15 19:35:06 -07006804droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08006805
Bo Huf0d50bb2017-08-01 19:02:09 +00006806endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006807# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006808# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07006809ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006810INTERNAL_EMULATOR_PACKAGE_FILES += \
6811 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006812 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07006813 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6814 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006815
6816name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
6817
6818INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6819
Ying Wang5d887702015-11-04 10:06:25 -08006820$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006821 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07006822 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006823
Ying Wang7d8c5352012-07-26 10:15:21 -07006824endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08006825
The Android Open Source Project88b60792009-03-03 19:28:42 -08006826
6827# -----------------------------------------------------------------
6828# The SDK
6829
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006830ifneq ($(filter sdk,$(MAKECMDGOALS)),)
6831
The Android Open Source Project88b60792009-03-03 19:28:42 -08006832# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07006833sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006834
6835# Build a name that looks like:
6836#
6837# linux-x86 --> android-sdk_12345_linux-x86
6838# darwin-x86 --> android-sdk_12345_mac-x86
6839# windows-x86 --> android-sdk_12345_windows
6840#
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006841ifneq ($(HOST_OS),linux)
6842 $(error Building the monolithic SDK is only supported on Linux)
6843endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006844sdk_name := android-sdk_$(FILE_NAME_TAG)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006845INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH)
Joe Onorato03fbe402009-04-13 08:31:16 -07006846sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006847
6848sdk_dep_file := $(sdk_dir)/sdk_deps.mk
6849
6850ATREE_FILES :=
6851-include $(sdk_dep_file)
6852
6853# if we don't have a real list, then use "everything"
6854ifeq ($(strip $(ATREE_FILES)),)
6855ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006856 $(ALL_DOCS) \
6857 $(ALL_SDK_FILES)
6858endif
6859
6860atree_dir := development/build
6861
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01006862
Dan Willemsen53c98f72021-10-16 16:49:06 -07006863sdk_atree_files := $(atree_dir)/sdk.exclude.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08006864
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02006865# development/build/sdk-android-<abi>.atree is used to differentiate
6866# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
6867# files like the kernel image. We use TARGET_CPU_ABI because we don't
6868# have a better way to distinguish between CPU models.
6869ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
6870 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
6871endif
6872
Anton Hansson8dab0a62019-03-28 15:45:40 +00006873ifneq ($(PRODUCT_SDK_ATREE_FILES),)
6874sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08006875else
6876sdk_atree_files += $(atree_dir)/sdk.atree
6877endif
6878
The Android Open Source Project88b60792009-03-03 19:28:42 -08006879deps := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006880 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01006881 $(SDK_METADATA_FILES) \
Anton Hansson55a8f022022-05-12 08:45:29 +00006882 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006883 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08006884 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006885 $(HOST_OUT_EXECUTABLES)/atree \
Jerome Gaillardcf713d42019-10-23 11:43:26 +01006886 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08006887
Anton Hansson874dbe72022-10-26 15:00:55 +00006888# The name of the subdir within the platforms dir of the sdk. One of:
6889# - android-<SDK_INT> (stable base dessert SDKs)
6890# - android-<CODENAME> (stable extension SDKs)
6891# - android-<SDK_INT>-ext<EXT_INT> (codename SDKs)
6892sdk_platform_dir_name := $(strip \
6893 $(if $(filter REL,$(PLATFORM_VERSION_CODENAME)), \
6894 $(if $(filter $(PLATFORM_SDK_EXTENSION_VERSION),$(PLATFORM_BASE_SDK_EXTENSION_VERSION)), \
6895 android-$(PLATFORM_SDK_VERSION), \
6896 android-$(PLATFORM_SDK_VERSION)-ext$(PLATFORM_SDK_EXTENSION_VERSION) \
6897 ), \
6898 android-$(PLATFORM_VERSION_CODENAME) \
6899 ) \
6900)
6901
The Android Open Source Project88b60792009-03-03 19:28:42 -08006902INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
6903$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
6904$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
6905$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
6906$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
Anton Hansson874dbe72022-10-26 15:00:55 +00006907$(INTERNAL_SDK_TARGET): PRIVATE_PLATFORM_NAME := $(sdk_platform_dir_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006908# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
6909#
6910#SDK_GNU_ERROR := true
6911
Ying Wang5d887702015-11-04 10:06:25 -08006912$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006913 @echo "Package SDK: $@"
6914 $(hide) rm -rf $(PRIVATE_DIR) $@
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07006915 $(hide) for f in $(strip $(target_gnu_MODULES)); do \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006916 if [ -f $$f ]; then \
6917 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
6918 including GNU target $$f >&2; \
6919 FAIL=$(SDK_GNU_ERROR); \
6920 fi; \
6921 done; \
6922 if [ $$FAIL ]; then exit 1; fi
6923 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00006924 ATREE_STRIP="$(HOST_STRIP) -x" \
6925 $(HOST_OUT_EXECUTABLES)/atree \
6926 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
6927 -m $(PRIVATE_DEP_FILE) \
6928 -I . \
6929 -I $(PRODUCT_OUT) \
6930 -I $(HOST_OUT) \
6931 -I $(TARGET_COMMON_OUT_ROOT) \
Anton Hansson874dbe72022-10-26 15:00:55 +00006932 -v "PLATFORM_NAME=$(PRIVATE_PLATFORM_NAME)" \
Anton Hansson6d814982018-11-26 18:12:05 +00006933 -v "OUT_DIR=$(OUT_DIR)" \
6934 -v "HOST_OUT=$(HOST_OUT)" \
6935 -v "TARGET_ARCH=$(TARGET_ARCH)" \
6936 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
6937 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Anton Hansson6d814982018-11-26 18:12:05 +00006938 -o $(PRIVATE_DIR) && \
Anton Hansson6d814982018-11-26 18:12:05 +00006939 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
6940 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
6941 chmod -R ug+rwX $(PRIVATE_DIR) && \
6942 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006943 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
6944
Raphaelc4d47312011-02-15 16:09:36 -08006945MAIN_SDK_DIR := $(sdk_dir)
6946MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006947
6948endif # sdk in MAKECMDGOALS
Raphael3d224a02010-04-16 17:50:09 -07006949
The Android Open Source Project88b60792009-03-03 19:28:42 -08006950# -----------------------------------------------------------------
6951# Findbugs
6952INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
6953INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
6954$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
6955 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006956 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006957 > $@
6958$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
6959 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006960 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07006961 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08006962
6963# -----------------------------------------------------------------
6964# Findbugs
6965
6966# -----------------------------------------------------------------
6967# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07006968ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006969include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01006970-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07006971-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006972-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07006973# Also the project-specific tasks
6974-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
6975-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006976-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07006977# Also add test specifc tasks
6978include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07006979include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07006980endif
Raphaelc4d47312011-02-15 16:09:36 -08006981
Ying Wang67132ba2015-10-28 16:42:39 -07006982include $(BUILD_SYSTEM)/product-graph.mk
6983
Raphaelc4d47312011-02-15 16:09:36 -08006984# -----------------------------------------------------------------
6985# Create SDK repository packages. Must be done after tasks/* since
6986# we need the addon rules defined.
6987ifneq ($(sdk_repo_goal),)
6988include $(TOPDIR)development/build/tools/sdk_repo.mk
6989endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07006990
6991# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07006992# Soong generates the list of all shared libraries that are depended on by fuzz
6993# targets. It saves this list as a source:destination pair to
6994# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
6995# build of the unstripped shared library, and the destination is the
6996# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
6997# where fuzz target shared libraries are to be "reinstalled". The
6998# copy-many-files below generates the rules to copy the unstripped shared
6999# libraries to the device or host "reinstallation" directory. These rules are
7000# depended on by each module in soong_cc_prebuilt.mk, where the module will have
7001# a dependency on each shared library that it needs to be "reinstalled".
7002FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
7003
7004# -----------------------------------------------------------------
hamzeh5dfe7a22021-04-29 12:44:16 -07007005# The rule to build all fuzz targets for C++ and Rust, and package them.
Mitch Phillipsceefc442019-09-26 16:37:59 -07007006# Note: The packages are created in Soong, and in a perfect world,
7007# we'd be able to create the phony rule there. But, if we want to
7008# have dist goals for the fuzz target, we need to have the PHONY
7009# target defined in make. MakeVarsContext.DistForGoal doesn't take
7010# into account that a PHONY rule create by Soong won't be available
7011# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08007012# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07007013# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08007014.PHONY: haiku
7015haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
7016$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00007017$(call dist-for-goals,haiku,$(PRODUCT_OUT)/module-info.json)
hamzeh5dfe7a22021-04-29 12:44:16 -07007018
Muhammad Haseeb Ahmade3a89402022-10-13 21:19:06 +00007019.PHONY: haiku-java-device
7020haiku-java-device: $(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_DEVICE_TARGETS)
7021$(call dist-for-goals,haiku-java-device,$(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES))
7022$(call dist-for-goals,haiku-java-device,$(PRODUCT_OUT)/module-info.json)
7023
7024.PHONY: haiku-java-host
7025haiku-java-host: $(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_HOST_TARGETS)
7026$(call dist-for-goals,haiku-java-host,$(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES))
7027$(call dist-for-goals,haiku-java-host,$(PRODUCT_OUT)/module-info.json)
Muhammad Haseeb Ahmadcced1362022-01-13 03:17:39 +00007028
hamzeh5dfe7a22021-04-29 12:44:16 -07007029.PHONY: haiku-rust
7030haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
7031$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00007032$(call dist-for-goals,haiku-rust,$(PRODUCT_OUT)/module-info.json)
Jerome Gaillardcf713d42019-10-23 11:43:26 +01007033
7034# -----------------------------------------------------------------
7035# Extract platform fonts used in Layoutlib
7036include $(BUILD_SYSTEM)/layoutlib_fonts.mk
Bob Badourebdefc02022-02-12 15:39:22 -08007037
7038
7039# -----------------------------------------------------------------
7040# OS Licensing
7041
7042include $(BUILD_SYSTEM)/os_licensing.mk
7043
7044# When appending new code to this file, please insert above OS Licensing