blob: 93e06c63cf05043b65a8360c279c7842a5d3cf39 [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
Joe Onorato64d85d02009-04-09 19:31:12 -0700927# We just build this directly to the install location.
928INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900929$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
J. Avila3f6560e2020-05-11 20:20:03 +0000930$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800931 $(call pretty,"Target ramdisk: $@")
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900932 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
933ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
934 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
935endif
J. Avila3f6560e2020-05-11 20:20:03 +0000936 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800937
Bob Badourebdefc02022-02-12 15:39:22 -0800938$(call declare-1p-container,$(INSTALLED_RAMDISK_TARGET),)
939$(call declare-container-license-deps,$(INSTALLED_RAMDISK_TARGET),$(INTERNAL_RAMDISK_FILE),$(PRODUCT_OUT)/:/)
940
Justin Yundd15ec12022-09-23 10:47:21 +0900941UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -0800942
Ying Wangad7fd292013-08-08 16:34:29 -0700943.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000944ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700945 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000946 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800947
Dan Willemsen67495202019-01-16 12:42:05 -0800948endif # BUILDING_RAMDISK_IMAGE
949
The Android Open Source Project88b60792009-03-03 19:28:42 -0800950# -----------------------------------------------------------------
951# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700952
953# This is defined here since we may be building recovery as boot
954# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700955ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
956 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
957else
958 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
959endif
960
Yifan Hong0674a6e2020-10-22 14:37:01 -0700961INTERNAL_PREBUILT_BOOTIMAGE :=
962
963my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
964ifdef my_installed_prebuilt_gki_apex
965 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
966 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
967 endif # len(my_installed_prebuilt_gki_apex) > 1
968
969 ifdef BOARD_PREBUILT_BOOTIMAGE
970 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
971 endif # BOARD_PREBUILT_BOOTIMAGE defined
972
973 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
974 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
975 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
Bob Badoura60beee2022-09-07 15:34:12 -0700976 $(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 -0700977
978 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
979
980else # my_installed_prebuilt_gki_apex not defined
981
Steve Muckle04b6f052020-08-09 14:36:56 -0700982# $1: boot image target
983# returns the kernel used to make the bootimage
984define bootimage-to-kernel
985 $(if $(BOARD_KERNEL_BINARIES),\
986 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
987 $(INSTALLED_KERNEL_TARGET))
988endef
989
Steve Muckle903a1ca2020-05-07 17:32:10 -0700990ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
991 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
992endif
993
994# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800995# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700996define get-bootimage-partition-size
Peter Collingbourne730200e2022-02-16 13:32:53 -0800997$(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
998endef
999
1000# $1: partition size
1001define get-partition-size-argument
1002 $(if $(1),--partition_size $(1),--dynamic_partition_size)
Steve Muckle903a1ca2020-05-07 17:32:10 -07001003endef
Chris Grossa784ef12019-04-22 11:09:57 -07001004
celeste wange3d43202022-08-12 08:36:37 +00001005ifndef BOARD_PREBUILT_BOOTIMAGE
1006
Chris Grossa784ef12019-04-22 11:09:57 -07001007ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001008INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -07001009 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001010
Bowgo Tsai85578e02022-04-19 10:50:59 +08001011# TODO(b/229701033): clean up BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK.
1012ifneq ($(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08001013 ifneq ($(BUILDING_INIT_BOOT_IMAGE),true)
1014 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
Devin Moore380d9e42021-11-04 19:01:19 +00001015 endif
Rom Lemarchandf9c92662015-04-08 15:11:47 -07001016endif
1017
Steve Mucklee1b10862019-07-10 10:49:37 -07001018ifndef BUILDING_VENDOR_BOOT_IMAGE
1019ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1020 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1021endif
1022endif
1023
The Android Open Source Project88b60792009-03-03 19:28:42 -08001024INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
1025
Yifan Hong46aff092020-10-28 13:50:47 -07001026# kernel cmdline/base/pagesize in boot.
1027# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
1028# device-specific.
1029# - If not using GKI:
1030# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
1031# - Otherwise, put them in boot.
1032ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07001033 ifdef GENERIC_KERNEL_CMDLINE
1034 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1035 endif
Yifan Hong46aff092020-10-28 13:50:47 -07001036else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
1037 ifdef INTERNAL_KERNEL_CMDLINE
1038 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1039 endif
1040 ifdef BOARD_KERNEL_BASE
1041 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1042 endif
1043 ifdef BOARD_KERNEL_PAGESIZE
1044 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1045 endif
1046endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001047
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001048ifdef BOARD_GKI_SIGNING_KEY_PATH
1049 # GKI boot images will not set system version & SPL value in the header.
1050 # They can be set by the device manufacturer in the AVB properties instead.
1051 INTERNAL_MKBOOTIMG_VERSION_ARGS :=
1052else
1053 INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -07001054 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001055 --os_patch_level $(PLATFORM_SECURITY_PATCH)
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001056endif # BOARD_GKI_SIGNING_KEY_PATH
Sami Tolvanen3303d902016-03-15 16:49:30 +00001057
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001058# $(1): image target to certify
1059# $(2): out certificate target
1060# $(3): image name
1061# $(4): additional AVB arguments
1062define generate_generic_boot_image_certificate
1063 rm -rf "$(2)"
1064 mkdir -p "$(dir $(2))"
1065 $(GENERATE_GKI_CERTIFICATE) $(INTERNAL_GKI_CERTIFICATE_ARGS) \
1066 --additional_avb_args "$(4)" \
1067 --name "$(3)" --output "$(2)" "$(1)"
1068endef
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001069
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001070INTERNAL_GKI_CERTIFICATE_ARGS :=
1071INTERNAL_GKI_CERTIFICATE_DEPS :=
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001072ifdef BOARD_GKI_SIGNING_KEY_PATH
1073 ifndef BOARD_GKI_SIGNING_ALGORITHM
1074 $(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
1075 endif
1076
1077 INTERNAL_GKI_CERTIFICATE_ARGS := \
1078 --key "$(BOARD_GKI_SIGNING_KEY_PATH)" \
1079 --algorithm "$(BOARD_GKI_SIGNING_ALGORITHM)" \
1080 --avbtool "$(AVBTOOL)"
1081
1082 # Quote and pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string argument.
1083 ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
1084 INTERNAL_GKI_CERTIFICATE_ARGS += --additional_avb_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
1085 endif
1086
1087 INTERNAL_GKI_CERTIFICATE_DEPS := \
1088 $(GENERATE_GKI_CERTIFICATE) \
1089 $(BOARD_GKI_SIGNING_KEY_PATH) \
1090 $(AVBTOOL)
1091
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001092endif
1093
Chris Grossa784ef12019-04-22 11:09:57 -07001094# Define these only if we are building boot
1095ifdef BUILDING_BOOT_IMAGE
1096INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1097
The Android Open Source Project88b60792009-03-03 19:28:42 -08001098ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001099$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001100endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -04001101
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001102$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
1103
1104ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -04001105
Steve Muckle04b6f052020-08-09 14:36:56 -07001106# $1: boot image target
1107define build_boot_board_avb_enabled
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001108 $(eval kernel := $(call bootimage-to-kernel,$(1)))
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001109 $(MKBOOTIMG) --kernel $(kernel) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001110 $(if $(BOARD_GKI_SIGNING_KEY_PATH), \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001111 $(eval boot_signature := $(call intermediates-dir-for,PACKAGING,generic_boot)/$(notdir $(1)).boot_signature) \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001112 $(eval kernel_signature := $(call intermediates-dir-for,PACKAGING,generic_kernel)/$(notdir $(kernel)).boot_signature) \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001113 $(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 +08001114 $(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 +08001115 cat $(kernel_signature) >> $(boot_signature) $(newline) \
1116 $(call assert-max-image-size,$(boot_signature),16 << 10) $(newline) \
1117 truncate -s $$(( 16 << 10 )) $(boot_signature) $(newline) \
1118 cat "$(boot_signature)" >> $(1))
Yifan Hongebe65f82020-10-15 14:48:07 -07001119 $(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 -07001120 $(AVBTOOL) add_hash_footer \
1121 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001122 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) \
Steve Muckle04b6f052020-08-09 14:36:56 -07001123 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1124 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1125endef
1126
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001127$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001128 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001129 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -04001130
Bob Badoura60beee2022-09-07 15:34:12 -07001131$(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 -08001132$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES) $(INTERNAL_GKI_CERTIFICATE_DEPS),$(PRODUCT_OUT)/:/)
1133
Justin Yundd15ec12022-09-23 10:47:21 +09001134UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001135
David Zeuthen0eb10972016-09-28 17:55:27 -04001136.PHONY: bootimage-nodeps
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001137bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001138 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001139 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001140
hungweichenb2dd6832022-08-08 09:16:30 +00001141else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # BOARD_AVB_ENABLE != true
David Riley17be3d32015-03-03 08:54:11 -08001142
Steve Muckle04b6f052020-08-09 14:36:56 -07001143# $1: boot image target
1144define build_boot_supports_vboot
1145 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
1146 $(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 -07001147 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001148endef
1149
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001150$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001151 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001152 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -08001153
Bob Badoura60beee2022-09-07 15:34:12 -07001154$(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 -08001155$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1156
Justin Yundd15ec12022-09-23 10:47:21 +09001157UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001158
David Riley17be3d32015-03-03 08:54:11 -08001159.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001160bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001161 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001162 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -08001163
1164else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001165
Steve Muckle04b6f052020-08-09 14:36:56 -07001166# $1: boot image target
1167define build_boot_novboot
1168 $(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 -07001169 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001170endef
1171
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001172$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001173 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001174 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -07001175
Bob Badoura60beee2022-09-07 15:34:12 -07001176$(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 -08001177$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1178
Justin Yundd15ec12022-09-23 10:47:21 +09001179UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001180
Ying Wangad7fd292013-08-08 16:34:29 -07001181.PHONY: bootimage-nodeps
1182bootimage-nodeps: $(MKBOOTIMG)
1183 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001184 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -07001185
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001186endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -07001187endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001188
Tao Baob1a2e352018-08-14 16:17:12 -07001189else # TARGET_NO_KERNEL == "true"
celeste wange3d43202022-08-12 08:36:37 +00001190INSTALLED_BOOTIMAGE_TARGET :=
1191endif # TARGET_NO_KERNEL
1192
1193else # BOARD_PREBUILT_BOOTIMAGE defined
Yifan Hong0674a6e2020-10-22 14:37:01 -07001194INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +09001195INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001196
1197ifeq ($(BOARD_AVB_ENABLE),true)
1198$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
1199 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1200 $(AVBTOOL) add_hash_footer \
1201 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001202 $(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001203 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1204 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001205
Bob Badoura60beee2022-09-07 15:34:12 -07001206$(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 -08001207$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_BOOTIMAGE),$(PRODUCT_OUT)/:/)
1208
Justin Yundd15ec12022-09-23 10:47:21 +09001209UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001210else
1211$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
1212 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1213endif # BOARD_AVB_ENABLE
1214
Tao Baob1a2e352018-08-14 16:17:12 -07001215endif # BOARD_PREBUILT_BOOTIMAGE
celeste wange3d43202022-08-12 08:36:37 +00001216
Yifan Hong0674a6e2020-10-22 14:37:01 -07001217endif # my_installed_prebuilt_gki_apex not defined
1218
1219my_apex_extracted_boot_image :=
1220my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001221
1222# -----------------------------------------------------------------
Devin Moore380d9e42021-11-04 19:01:19 +00001223# init boot image
1224ifeq ($(BUILDING_INIT_BOOT_IMAGE),true)
1225
1226INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1227$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_RAMDISK_TARGET)
1228
Yi-Yo Chiang8b0776d2022-06-30 17:33:29 +08001229INTERNAL_INIT_BOOT_IMAGE_ARGS := --ramdisk $(INSTALLED_RAMDISK_TARGET)
1230
Devin Moore380d9e42021-11-04 19:01:19 +00001231ifdef BOARD_KERNEL_PAGESIZE
1232 INTERNAL_INIT_BOOT_IMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1233endif
1234
1235ifeq ($(BOARD_AVB_ENABLE),true)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08001236$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
Devin Moore380d9e42021-11-04 19:01:19 +00001237 $(call pretty,"Target init_boot image: $@")
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001238 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output "$@"
Devin Moore380d9e42021-11-04 19:01:19 +00001239 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
1240 $(AVBTOOL) add_hash_footer \
1241 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001242 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001243 --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1244 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001245
1246$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1247$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_GENERIC_RAMDISK_BOOT_SIGNATURE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001248else
1249$(INSTALLED_INIT_BOOT_IMAGE_TARGET):
1250 $(call pretty,"Target init_boot image: $@")
1251 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output $@
1252 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
Bob Badourebdefc02022-02-12 15:39:22 -08001253
1254$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001255endif
1256
Justin Yundd15ec12022-09-23 10:47:21 +09001257UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001258
Devin Moore380d9e42021-11-04 19:01:19 +00001259else # BUILDING_INIT_BOOT_IMAGE is not true
1260
1261ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
1262INTERNAL_PREBUILT_INIT_BOOT_IMAGE := $(BOARD_PREBUILT_INIT_BOOT_IMAGE)
1263INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1264
1265ifeq ($(BOARD_AVB_ENABLE),true)
1266$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
1267 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
1268 $(AVBTOOL) add_hash_footer \
1269 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001270 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001271 --partition_name boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1272 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001273
1274$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1275$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_PREBUILT_INIT_BOOT_IMAGE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001276else
1277$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE)
1278 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
Bob Badourebdefc02022-02-12 15:39:22 -08001279
1280$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001281endif # BOARD_AVB_ENABLE
1282
Justin Yundd15ec12022-09-23 10:47:21 +09001283UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001284
Devin Moore380d9e42021-11-04 19:01:19 +00001285else # BOARD_PREBUILT_INIT_BOOT_IMAGE not defined
1286INSTALLED_INIT_BOOT_IMAGE_TARGET :=
1287endif # BOARD_PREBUILT_INIT_BOOT_IMAGE
1288
1289endif # BUILDING_INIT_BOOT_IMAGE is not true
Ramji Jiyani10655232022-01-20 06:43:09 +00001290
1291# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001292# vendor boot image
Colin Cross79a76ec2022-03-21 15:06:11 -07001293INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Steve Mucklee1b10862019-07-10 10:49:37 -07001294ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1295
Steve Mucklee1b10862019-07-10 10:49:37 -07001296INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
Steve Mucklee1b10862019-07-10 10:49:37 -07001297 $(ALL_DEFAULT_INSTALLED_MODULES))
1298
Petri Gynther6a6d6212021-03-06 00:45:53 -08001299INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001300
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001301# Exclude recovery files in the default vendor ramdisk if including a standalone
1302# recovery ramdisk in vendor_boot.
Yifan Hong881df392020-10-09 14:29:39 -07001303ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001304ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
Yifan Hong881df392020-10-09 14:29:39 -07001305$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1306$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1307endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001308endif
Yifan Hong881df392020-10-09 14:29:39 -07001309
J. Avila3f6560e2020-05-11 20:20:03 +00001310$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001311 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001312
Petri Gynther828828b2021-03-04 11:04:03 -08001313INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1314$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08001315 @echo "Target vendor ramdisk: $@"
Petri Gynther828828b2021-03-04 11:04:03 -08001316 $(copy-file-to-target)
Petri Gynther828828b2021-03-04 11:04:03 -08001317
Bob Badourebdefc02022-02-12 15:39:22 -08001318$(call declare-1p-container,$(INSTALLED_VENDOR_RAMDISK_TARGET),)
1319$(call declare-container-license-deps,$(INSTALLED_VENDOR_RAMDISK_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
1320
1321VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_RAMDISK_TARGET)
1322
Petri Gynther6ff52012020-11-20 11:59:41 -08001323INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1324INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1325$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1326$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1327$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001328 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001329 mkdir -p $(dir $@)
1330 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001331 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1332 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001333
Bob Badourebdefc02022-02-12 15:39:22 -08001334$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07001335$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08001336
Steve Mucklee1b10862019-07-10 10:49:37 -07001337ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Lucas Weif57333f2022-02-24 10:30:15 +08001338 ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1339 # If we have vendor_kernel_boot partition, we migrate dtb image to that image
1340 # and allow dtb in vendor_boot to be empty.
1341 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1342 endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001343endif
1344ifdef BOARD_KERNEL_BASE
1345 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1346endif
1347ifdef BOARD_KERNEL_PAGESIZE
1348 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1349endif
1350ifdef INTERNAL_KERNEL_CMDLINE
1351 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1352endif
1353
Devin Moore50509012021-01-13 10:45:04 -08001354ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001355 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1356 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001357 rm -f $@
1358 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1359 printf "%s\n" $(param) >> $@;)
1360 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1361endif
1362
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001363# $(1): Build target name
1364# $(2): Staging dir to be compressed
1365# $(3): Build dependencies
1366define build-vendor-ramdisk-fragment-target
1367$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1368 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1369endef
1370
1371# $(1): Ramdisk name
1372define build-vendor-ramdisk-fragment
1373$(strip \
1374 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1375 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1376 $(build_target) \
1377)
1378endef
1379
1380# $(1): Ramdisk name
1381# $(2): Prebuilt file path
1382define build-prebuilt-vendor-ramdisk-fragment
1383$(strip \
1384 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1385 $(eval $(call copy-one-file,$(2),$(build_target))) \
1386 $(build_target) \
1387)
1388endef
1389
1390INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1391INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1392
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001393$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001394 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1395 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1396 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1397 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001398 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001399 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1400 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1401)
1402
Steve Mucklee1b10862019-07-10 10:49:37 -07001403INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1404$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001405$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001406ifeq ($(BOARD_AVB_ENABLE),true)
1407$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1408 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001409 $(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 -07001410 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1411 $(AVBTOOL) add_hash_footer \
1412 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001413 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Steve Mucklee1b10862019-07-10 10:49:37 -07001414 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1415 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1416else
1417$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1418 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001419 $(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 -07001420 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1421endif
Bob Badourebdefc02022-02-12 15:39:22 -08001422
1423$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
1424$(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)/:/)
1425VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001426endif # BUILDING_VENDOR_BOOT_IMAGE
1427
1428# -----------------------------------------------------------------
Lucas Weif57333f2022-02-24 10:30:15 +08001429# vendor kernel boot image
1430ifeq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1431
1432INTERNAL_VENDOR_KERNEL_RAMDISK_FILES := $(filter $(TARGET_VENDOR_KERNEL_RAMDISK_OUT)/%, \
Lucas Weif57333f2022-02-24 10:30:15 +08001433 $(ALL_DEFAULT_INSTALLED_MODULES))
1434
1435INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_kernel_boot)/vendor_kernel_ramdisk.cpio$(RAMDISK_EXT)
1436
1437$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
1438 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
1439
1440INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_kernel_ramdisk.img
1441$(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1442 @echo "Target vendor kernel ramdisk: $@"
1443 $(copy-file-to-target)
1444
1445INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-kernel-ramdisk.txt
1446INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK:.txt=.json)
1447$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK)
1448$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1449$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
1450 @echo Installed file list: $@
1451 mkdir -p $(dir $@)
1452 rm -f $@
1453 $(FILESLIST) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) > $(@:.txt=.json)
1454 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
1455
Bob Badour5acd4362022-04-12 18:31:35 -07001456$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK))
1457$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK))
1458
Lucas Weif57333f2022-02-24 10:30:15 +08001459INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS := --vendor_ramdisk $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1460INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_kernel_boot.img
1461$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1462
1463ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1464 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1465 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
1466endif
1467ifdef BOARD_KERNEL_PAGESIZE
1468 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1469endif
1470
1471
1472ifeq ($(BOARD_AVB_ENABLE),true)
1473$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_KERNEL_BOOTIMAGE_KEY_PATH)
1474 $(call pretty,"Target vendor_kernel_boot image: $@")
1475 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1476 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1477 $(AVBTOOL) add_hash_footer \
1478 --image $@ \
1479 $(call get-partition-size-argument,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)) \
1480 --partition_name vendor_kernel_boot $(INTERNAL_AVB_VENDOR_KERNEL_BOOT_SIGNING_ARGS) \
1481 $(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)
1482else
1483$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):
1484 $(call pretty,"Target vendor_kernel_boot image: $@")
1485 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1486 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1487endif
Bob Badour5acd4362022-04-12 18:31:35 -07001488$(call declare-1p-container,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
1489ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1490$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),\
1491 $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET),\
1492 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1493else
1494$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET),$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1495endif
Lucas Weif57333f2022-02-24 10:30:15 +08001496endif # BUILDING_VENDOR_KERNEL_BOOT_IMAGE
1497
1498# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001499# NOTICE files
1500#
Steve Blockd14d3b42012-03-01 11:34:41 +00001501# We are required to publish the licenses for all code under BSD, GPL and
1502# Apache licenses (and possibly other more exotic ones as well). We err on the
1503# side of caution, so the licenses for other third-party code are included here
1504# too.
1505#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001506# This needs to be before the systemimage rules, because it adds to
1507# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1508# go into the systemimage.
1509
Steve Block495e5852012-02-29 19:18:08 +00001510.PHONY: notice_files
1511
Bob Badourebdefc02022-02-12 15:39:22 -08001512# Convert license metadata into xml notice file.
1513# $(1) - Output target notice filename
1514# $(2) - Product name
1515# $(3) - File title
1516# $(4) - License metadata file roots
1517# $(5) - Prefixes to strip
1518#
1519define xml-notice-rule
1520$(1): PRIVATE_PRODUCT := $(2)
1521$(1): PRIVATE_MESSAGE := $(3)
Bob Badour5acd4362022-04-12 18:31:35 -07001522$(1): PRIVATE_DEPS := $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001523$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badour5acd4362022-04-12 18:31:35 -07001524 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 -08001525
1526notice_files: $(1)
1527endef
1528
1529# Convert license metadata into text notice file.
1530# $(1) - Output target notice filename
1531# $(2) - Product name
1532# $(3) - File title
1533# $(4) - License metadata file roots
1534# $(5) - Prefixes to strip
1535#
1536define text-notice-rule
1537$(1): PRIVATE_PRODUCT := $(2)
1538$(1): PRIVATE_MESSAGE := $(3)
1539$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001540 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 -08001541
1542notice_files: $(1)
1543endef
1544
1545# Conversion license metadata into html notice file.
1546# $(1) - Output target notice filename
1547# $(2) - Product name
1548# $(3) - File title
1549# $(4) - License metadata file roots
1550# $(5) - Prefixes to strip
1551#
1552define html-notice-rule
1553$(1): PRIVATE_PRODUCT := $(2)
1554$(1): PRIVATE_MESSAGE := $(3)
1555$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001556 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 -08001557
1558notice_files: $(1)
1559endef
1560
Bob Badour6259a092022-03-23 23:28:40 -07001561$(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 -08001562
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001563# Notice file logic isn't relevant for TARGET_BUILD_APPS
1564ifndef TARGET_BUILD_APPS
1565
The Android Open Source Project88b60792009-03-03 19:28:42 -08001566# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1567# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1568# the src subdirectory.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001569kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001570
Bob Badour4b25c902020-01-28 13:23:39 -08001571# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1572# reasons--not to be flashed onto any device. Targets under these directories
1573# need no associated notice file on the device UI.
1574exclude_target_dirs := apex
1575
Steven Morelandae69e572017-12-15 14:49:55 -08001576# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001577ifneq ($(PRODUCT_NOTICE_SPLIT),true)
Bob Badourebdefc02022-02-12 15:39:22 -08001578#target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001579target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1580installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Bob Badour879cfa82021-04-15 10:41:38 -07001581
1582$(call declare-0p-target,$(target_notice_file_html_gz))
1583$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001584else
Bob Badourebdefc02022-02-12 15:39:22 -08001585# target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001586target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001587installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1588
1589target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001590target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1591installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001592
1593target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
Dario Freniadc972d2018-07-09 18:38:38 +01001594target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1595installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001596
Justin Yun6151e3f2019-06-25 15:58:13 +09001597target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
Justin Yun6151e3f2019-06-25 15:58:13 +09001598target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1599installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001600
Chris Gross15d96552019-07-16 14:38:43 -07001601target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
Chris Gross15d96552019-07-16 14:38:43 -07001602target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1603installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1604
Yifan Hong3d3f0302020-05-11 18:35:11 -07001605target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
Yifan Hong3d3f0302020-05-11 18:35:11 -07001606target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1607installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1608
Yifan Hongc83f9e92020-07-15 16:57:47 -07001609target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
Yifan Hongc83f9e92020-07-15 16:57:47 -07001610target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1611installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1612
Ramji Jiyani13a41372022-01-27 07:05:08 +00001613target_system_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.txt
Ramji Jiyani13a41372022-01-27 07:05:08 +00001614target_system_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.xml.gz
1615installed_system_dlkm_notice_xml_gz := $(TARGET_OUT_SYSTEM_DLKM)/etc/NOTICE.xml.gz
1616
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001617# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1618# being built. A notice xml file must depend on all modules that could potentially
1619# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001620license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001621# Only files copied to a system image need system image notices.
1622license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001623# Phonys/fakes don't have notice files (though their deps might)
1624license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001625# testcases are not relevant to the system image.
1626license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001627# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001628license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001629# system_other is relevant to system partition.
1630license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001631license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1632license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001633license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001634license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001635license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001636license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001637license_modules_odm_dlkm := $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001638license_modules_agg := $(license_modules_system) \
1639 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001640 $(license_modules_product) \
1641 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001642 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001643 $(license_modules_vendor_dlkm) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001644 $(license_modules_odm_dlkm) \
1645 $(license_modules_system_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001646# targets used for debug symbols only and do not get copied to the device
1647license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1648
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001649license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001650license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1651
1652# Identify the other targets we expect to have notices for:
1653# targets copied to the device but are not readable by the UI (e.g. must boot
1654# into a different partition to read or don't have an associated /etc
1655# directory) must have their notices built somewhere readable.
1656license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1657license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1658license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1659license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1660license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1661license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001662license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001663license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1664license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1665license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1666license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1667license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1668license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1669
1670# after removing targets in system images, targets reported in system images, and
1671# targets used for debug symbols that do not need notices, nothing must remain.
1672license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1673$(call maybe-print-list-and-error, $(license_modules_rest), \
1674 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001675
Chris Grossaad39b32019-06-13 09:43:26 -07001676# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1677# update its notice file, so include those notices in the system partition instead
1678ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001679license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001680system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1681system_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 -07001682else
Bob Badour4b25c902020-01-28 13:23:39 -08001683license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001684system_xml_directories := xml_system
1685system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001686endif
1687
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001688endif # PRODUCT_NOTICE_SPLIT
1689
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001690ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001691
Bob Badour56e0de52022-08-02 17:46:48 +00001692need_vendor_notice:=false
1693ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1694 need_vendor_notice:=true
1695endif
1696
1697ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
1698 need_vendor_notice:=true
1699endif
1700
1701ifdef BUILDING_VENDOR_IMAGE
1702 need_vendor_notice:=true
1703endif
1704
1705ifeq (true,$(need_vendor_notice))
1706ifneq (,$(installed_vendor_notice_xml_gz))
1707ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1708endif
1709endif
1710
1711need_vendor_notice:=
1712
1713ifdef BUILDING_ODM_IMAGE
1714ifneq (,$(installed_odm_notice_xml_gz))
1715ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
1716endif
1717endif
1718
1719ifdef BUILDING_PRODUCT_IMAGE
1720ifneq (,$(installed_product_notice_xml_gz))
1721ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1722endif
1723endif
1724
1725ifdef BUILDING_SYSTEM_EXT_IMAGE
1726ifneq (,$(installed_system_ext_notice_xml_gz))
1727ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1728endif
1729endif
1730
1731ifdef BUILDING_VENDOR_DLKM_IMAGE
1732ifneq (,$(installed_vendor_dlkm_notice_xml_gz)
1733ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
1734endif
1735endif
1736
1737ifdef BUILDING_ODM_DLKM_IMAGE
1738ifneq (,$(installed_odm_dlkm_notice_xml_gz))
1739ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
1740endif
1741endif
1742
1743ifdef BUILDING_SYSTEM_DLKM_IMAGE
1744ifneq (,$(installed_system_dlkm_notice_xml_gz))
1745ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_dlkm_notice_xml_gz)
1746endif
1747endif
1748
Ying Wang62c81f82013-08-22 20:02:03 -07001749endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001750
Bob Badoura60beee2022-09-07 15:34:12 -07001751# Presently none of the prebuilts etc. comply with policy to have a license text. Fake one here.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001752$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001753
Bob Badoura60beee2022-09-07 15:34:12 -07001754ifneq (,$(strip $(INSTALLED_KERNEL_TARGET)))
1755$(call declare-license-metadata,$(INSTALLED_KERNEL_TARGET),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
1756endif
Bob Badourebdefc02022-02-12 15:39:22 -08001757
Bob Badoura60beee2022-09-07 15:34:12 -07001758# No matter where it gets copied from, a copied linux kernel is licensed under "GPL 2.0 only"
1759$(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 -08001760
Doug Zongker8678df42009-06-15 14:30:14 -07001761
The Android Open Source Project88b60792009-03-03 19:28:42 -08001762# #################################################################
1763# Targets for user images
1764# #################################################################
1765
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001766# These options tell the recovery updater/installer how to mount the partitions writebale.
1767# <fstype>=<fstype_opts>[|<fstype_opts>]...
1768# fstype_opts := <opt>[,<opt>]...
1769# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001770# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1771DEFAULT_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 -07001772
Tao Baodba635a2019-06-24 10:39:54 -07001773INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001774 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001775 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001776 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001777
Bob Badour2f66fd12022-03-09 17:30:24 -08001778$(call declare-1p-target,$(MKE2FS_CONF),system/extras)
1779
Tao Baodba635a2019-06-24 10:39:54 -07001780ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1781INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001782endif
1783
Yifan Hongcfb917a2020-05-07 14:58:20 -07001784ifneq ($(filter \
1785 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1786 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1787 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1788 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1789 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1790 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001791 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001792 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001793 ,erofs),)
David Anderson94ad5bb2022-03-04 10:57:58 -08001794INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
David Andersonf54665f2022-03-04 14:42:18 -08001795ifeq ($(BOARD_EROFS_USE_LEGACY_COMPRESSION),true)
1796BOARD_EROFS_COMPRESSOR ?= "lz4"
1797else
Kelvin Zhang37d49292021-12-01 14:21:24 -08001798BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
Gao Xiang961041a2020-06-17 13:59:16 +08001799endif
David Andersonf54665f2022-03-04 14:42:18 -08001800endif
Gao Xiang961041a2020-06-17 13:59:16 +08001801
1802ifneq ($(filter \
1803 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1804 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1805 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1806 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1807 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1808 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1809 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001810 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001811 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001812INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1813endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001814
Tao Baodba635a2019-06-24 10:39:54 -07001815ifeq ($(BOARD_AVB_ENABLE),true)
1816INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1817endif
1818
1819# Get a colon-separated list of search paths.
1820INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1821
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001822# Collects file_contexts files from modules to be installed
1823$(call merge-fc-files, \
1824 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1825 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1826
Alex Klyubin092c9022017-03-13 13:28:34 -07001827SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001828
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001829INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1830
David Anderson707e6f52021-09-21 22:24:43 -07001831# $(1) the partition name (eg system)
1832# $(2) the image prop file
1833define add-common-flags-to-image-props
1834$(eval _var := $(call to-upper,$(1)))
1835$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
1836$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
1837endef
1838
1839# $(1) the partition name (eg system)
1840# $(2) the image prop file
1841define add-common-ro-flags-to-image-props
1842$(eval _var := $(call to-upper,$(1)))
David Anderson64b351b2021-10-13 00:20:43 -07001843$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001844$(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 -07001845$(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 -07001846$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
1847$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
1848$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
1849$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
1850$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
1851$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
1852$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
1853$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
1854$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
1855$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
1856$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
1857$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
1858$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
1859$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
1860$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
1861$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
David Anderson5f4aa6c2021-09-23 17:03:14 -07001862$(if $(or $(_size), $(_reserved), $(_headroom)),,
1863 $(hide) echo "$(1)_disable_sparse=true" >> $(2))
David Anderson707e6f52021-09-21 22:24:43 -07001864$(call add-common-flags-to-image-props,$(1),$(2))
David Anderson9e95a022021-08-31 21:32:45 -07001865endef
1866
Ying Wangbd93d422011-10-28 17:02:30 -07001867# $(1): the path of the output dictionary file
Ramji Jiyani13a41372022-01-27 07:05:08 +00001868# $(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 -07001869# $(3): additional "key=value" pairs to append to the dictionary file.
1870define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001871$(if $(filter $(2),system),\
Bowgo Tsai867ab662019-01-29 13:30:18 +08001872 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001873 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001874 $(call add-common-ro-flags-to-image-props,system,$(1))
Chris Gross203191b2020-05-30 02:39:12 +00001875)
1876$(if $(filter $(2),system_other),\
1877 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
David Anderson9e95a022021-08-31 21:32:45 -07001878 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
1879 $(hide) echo "system_other_disable_sparse=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001880)
Yifan Hong760d3c02018-05-30 11:16:46 -07001881$(if $(filter $(2),userdata),\
1882 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1883 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001884 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1885 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kim55c16dd2020-10-12 19:50:05 -07001886 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001887 $(call add-common-flags-to-image-props,userdata,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001888)
Yifan Hong760d3c02018-05-30 11:16:46 -07001889$(if $(filter $(2),cache),\
1890 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1891 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001892 $(call add-common-flags-to-image-props,cache,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001893)
1894$(if $(filter $(2),vendor),\
David Anderson707e6f52021-09-21 22:24:43 -07001895 $(call add-common-ro-flags-to-image-props,vendor,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001896)
1897$(if $(filter $(2),product),\
David Anderson707e6f52021-09-21 22:24:43 -07001898 $(call add-common-ro-flags-to-image-props,product,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001899)
Justin Yun6151e3f2019-06-25 15:58:13 +09001900$(if $(filter $(2),system_ext),\
David Anderson707e6f52021-09-21 22:24:43 -07001901 $(call add-common-ro-flags-to-image-props,system_ext,$(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001902)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001903$(if $(filter $(2),odm),\
David Anderson707e6f52021-09-21 22:24:43 -07001904 $(call add-common-ro-flags-to-image-props,odm,$(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001905)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001906$(if $(filter $(2),vendor_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001907 $(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001908)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001909$(if $(filter $(2),odm_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001910 $(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001911)
Ramji Jiyani13a41372022-01-27 07:05:08 +00001912$(if $(filter $(2),system_dlkm),\
1913 $(call add-common-ro-flags-to-image-props,system_dlkm,$(1))
1914)
Yifan Hong760d3c02018-05-30 11:16:46 -07001915$(if $(filter $(2),oem),\
1916 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1917 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1918 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1919 $(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 -07001920 $(call add-common-flags-to-image-props,oem,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001921)
Tao Bao3602eca2018-07-10 10:53:55 -07001922$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001923
Cole Faust8fc7bef2022-06-15 16:10:49 -07001924$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT2)),$(hide) echo "fs_type=ext2" >> $(1),
1925 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT3)),$(hide) echo "fs_type=ext3" >> $(1),
1926 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT4)),$(hide) echo "fs_type=ext4" >> $(1))))
1927
1928$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)),,$(hide) echo "extfs_sparse_flag=-s" >> $(1))
1929$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED)),,$(hide) echo "erofs_sparse_flag=-s" >> $(1))
1930$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)),,$(hide) echo "squashfs_sparse_flag=-s" >> $(1))
1931$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)),,$(hide) echo "f2fs_sparse_flag=-S" >> $(1))
David Anderson40a821f2021-09-22 18:02:01 -07001932$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001933$(if $(BOARD_EROFS_COMPRESS_HINTS),$(hide) echo "erofs_default_compress_hints=$(BOARD_EROFS_COMPRESS_HINTS)" >> $(1))
David Anderson64b351b2021-10-13 00:20:43 -07001934$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
1935$(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 -08001936$(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 -07001937$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1938$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1939$(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 +08001940$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001941$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1942$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1943$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001944$(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 -07001945$(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 -07001946$(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 +00001947$(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 +00001948$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1949$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1950$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1951$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1952$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001953$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001954$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1955$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1956$(if $(BOARD_AVB_ENABLE),\
1957 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1958 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1959 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1960 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001961$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1962$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1963$(if $(BOARD_AVB_ENABLE),\
1964 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1965 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001966 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001967$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1968$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1969$(if $(BOARD_AVB_ENABLE),\
1970 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1971 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1972 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1973 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001974$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1975$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1976$(if $(BOARD_AVB_ENABLE),\
1977 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1978 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1979 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1980 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001981$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001982$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001983 $(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 +01001984$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001985 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1986 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1987 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1988 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001989$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1990$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1991$(if $(BOARD_AVB_ENABLE),\
1992 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1993 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1994 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1995 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001996$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1997$(if $(BOARD_AVB_ENABLE),\
1998 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1999$(if $(BOARD_AVB_ENABLE),\
2000 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
2001 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
2002 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
2003 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07002004$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2005$(if $(BOARD_AVB_ENABLE),\
2006 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2007$(if $(BOARD_AVB_ENABLE),\
2008 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
2009 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
2010 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
2011 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Ramji Jiyani13a41372022-01-27 07:05:08 +00002012$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
2013$(if $(BOARD_AVB_ENABLE),\
2014 $(hide) echo "avb_system_dlkm_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
2015$(if $(BOARD_AVB_ENABLE),\
2016 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
2017 $(hide) echo "avb_system_dlkm_key_path=$(BOARD_AVB_SYSTEM_DLKM_KEY_PATH)" >> $(1)
2018 $(hide) echo "avb_system_dlkm_algorithm=$(BOARD_AVB_SYSTEM_DLKM_ALGORITHM)" >> $(1)
2019 $(hide) echo "avb_system_dlkm_rollback_index_location=$(BOARD_SYSTEM_SYSTEM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002020$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
2021 $(hide) echo "recovery_as_boot=true" >> $(1))
Bowgo Tsai85578e02022-04-19 10:50:59 +08002022$(if $(filter true,$(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK)),\
2023 $(hide) echo "gki_boot_image_without_ramdisk=true" >> $(1))
Tom Cherryd14b8952018-08-09 14:26:00 -07002024$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01002025$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
2026 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07002027$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
2028endef
2029
2030# $(1): the path of the output dictionary file
2031# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07002032PROP_DICTIONARY_IMAGES := oem
2033ifdef BUILDING_CACHE_IMAGE
2034 PROP_DICTIONARY_IMAGES += cache
2035endif
2036ifdef BUILDING_SYSTEM_IMAGE
2037 PROP_DICTIONARY_IMAGES += system
2038endif
Chris Gross203191b2020-05-30 02:39:12 +00002039ifdef BUILDING_SYSTEM_OTHER_IMAGE
2040 PROP_DICTIONARY_IMAGES += system_other
2041endif
Daniel Norman72c626f2019-05-13 15:58:14 -07002042ifdef BUILDING_USERDATA_IMAGE
2043 PROP_DICTIONARY_IMAGES += userdata
2044endif
2045ifdef BUILDING_VENDOR_IMAGE
2046 PROP_DICTIONARY_IMAGES += vendor
2047endif
2048ifdef BUILDING_PRODUCT_IMAGE
2049 PROP_DICTIONARY_IMAGES += product
2050endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002051ifdef BUILDING_SYSTEM_EXT_IMAGE
2052 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07002053endif
2054ifdef BUILDING_ODM_IMAGE
2055 PROP_DICTIONARY_IMAGES += odm
2056endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002057ifdef BUILDING_VENDOR_DLKM_IMAGE
2058 PROP_DICTIONARY_IMAGES += vendor_dlkm
2059endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07002060ifdef BUILDING_ODM_DLKM_IMAGE
2061 PROP_DICTIONARY_IMAGES += odm_dlkm
2062endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00002063ifdef BUILDING_SYSTEM_DLKM_IMAGE
2064 PROP_DICTIONARY_IMAGES += system_dlkm
2065endif
Yifan Hong760d3c02018-05-30 11:16:46 -07002066define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07002067 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07002068endef
2069
Yifan Hongbbcba1e2018-06-18 16:32:35 -07002070# $(1): the path of the input dictionary file, where each line has the format key=value
2071# $(2): the key to look up
2072define read-image-prop-dictionary
2073$$(grep '$(2)=' $(1) | cut -f2- -d'=')
2074endef
2075
The Android Open Source Project88b60792009-03-03 19:28:42 -08002076# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07002077# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07002078
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002079# Recovery image exists if we are building recovery, or building recovery as boot.
Colin Cross79a76ec2022-03-21 15:06:11 -07002080INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RECOVERY_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Chris Grossa784ef12019-04-22 11:09:57 -07002081ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002082
Ying Wang37526142015-03-10 12:02:57 -07002083INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
2084 $(ALL_DEFAULT_INSTALLED_MODULES))
2085
Tao Bao10fc9492018-08-14 12:17:48 -07002086INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
2087INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
2088
Colin Cross359f4212020-12-02 15:14:04 -08002089ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2090INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
2091endif
2092
Tao Bao10fc9492018-08-14 12:17:48 -07002093# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
2094# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
2095# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
2096# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08002097$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07002098
2099$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002100$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07002101 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002102 mkdir -p $(dir $@)
2103 rm -f $@
2104 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
2105 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07002106
Bob Badour5acd4362022-04-12 18:31:35 -07002107$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RECOVERY)))
2108$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RECOVERY)))
2109
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002110recovery_sepolicy := \
2111 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07002112 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002113 $(TARGET_RECOVERY_ROOT_OUT)/plat_service_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002114 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002115 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002116 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_service_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002117 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
2118 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002119 $(TARGET_RECOVERY_ROOT_OUT)/vendor_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002120 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08002121 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002122 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
2123 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002124 $(TARGET_RECOVERY_ROOT_OUT)/product_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002125 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08002126
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002127# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
2128# SELinux files
2129IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
2130
Steve Muckle04b6f052020-08-09 14:36:56 -07002131# if building multiple boot images from multiple kernels, use the first kernel listed
2132# for the recovery image
2133recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002134recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07002135recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08002136
Anton Hansson45a40da2019-01-18 14:06:34 +00002137# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
2138# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
2139# which get remapped to a bucket.
2140recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07002141ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
2142recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00002143# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07002144# ------160------240------320----------480------------640------
2145# mdpi hdpi xhdpi xxhdpi xxxhdpi
2146recovery_density := $(strip \
2147 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
2148 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
2149 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
2150 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07002151endif
2152
2153ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
2154recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
2155else
Doug Zongker25d55f82014-04-04 13:51:15 -07002156recovery_resources_common := $(recovery_resources_common)-xhdpi
2157endif
2158
Tao Baoe1e829e2018-08-29 20:36:00 -07002159# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
2160# Note that the font selected here can be overridden for a particular device by putting a font.png
2161# in its private recovery resources.
2162ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07002163recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08002164else
Dan Willemsen97672232020-05-27 00:09:16 -07002165recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08002166endif
2167
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002168
2169# We will only generate the recovery background text images if the variable
2170# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
2171# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
2172# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
2173# BoardConfig in order to use this feature.
2174ifeq ($(recovery_density),xxxhdpi)
2175TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
2176else ifeq ($(recovery_density),xxhdpi)
2177TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
2178endif
2179
2180ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
2181# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
2182ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
2183 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
2184else
2185 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
2186endif
2187
2188
Dan Willemsen97672232020-05-27 00:09:16 -07002189RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002190RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
2191RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
2192RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
2193RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
2194
xunchangcc57d312018-12-07 12:12:17 -08002195RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
2196RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
2197RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
2198RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
2199RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
2200
2201generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002202 $(RECOVERY_INSTALLING_TEXT_FILE) \
2203 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
2204 $(RECOVERY_ERASING_TEXT_FILE) \
2205 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08002206 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
2207 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
2208 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
2209 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
2210 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
2211 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002212
Dan Willemsen97672232020-05-27 00:09:16 -07002213resource_dir := bootable/recovery/tools/recovery_l10n/res/
2214resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002215image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08002216zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002217$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07002218$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002219$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
2220$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08002221$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002222$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08002223$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002224 recovery_installing \
2225 recovery_installing_security \
2226 recovery_erasing \
2227 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08002228 recovery_no_command
2229$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002230 recovery_cancel_wipe_data \
2231 recovery_factory_data_reset \
2232 recovery_try_again \
2233 recovery_wipe_data_menu_header \
2234 recovery_wipe_data_confirmation
2235$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07002236$(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 -08002237 # Prepares the font directory.
2238 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
2239 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08002240 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002241 @rm -rf $(dir $@)
2242 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08002243 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08002244 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08002245 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002246 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
2247 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
2248 --text_name $(text_name) \
2249 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2250 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002251 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002252 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002253else
2254RECOVERY_INSTALLING_TEXT_FILE :=
2255RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2256RECOVERY_ERASING_TEXT_FILE :=
2257RECOVERY_ERROR_TEXT_FILE :=
2258RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002259RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2260RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2261RECOVERY_TRY_AGAIN_TEXT_FILE :=
2262RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2263RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002264endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2265
Ying Wang9a175682015-08-06 11:47:47 -07002266ifndef TARGET_PRIVATE_RES_DIRS
2267TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2268endif
Doug Zongker4647f122009-07-02 09:00:54 -07002269recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002270 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002271recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002272
2273
Andrew Boiefa61ff02012-09-28 09:33:45 -07002274ifdef TARGET_RECOVERY_FSTAB
2275recovery_fstab := $(TARGET_RECOVERY_FSTAB)
Cole Faust64c2ddb2022-01-07 12:44:31 -08002276else ifdef TARGET_RECOVERY_FSTAB_GENRULE
2277# Specifies a soong genrule module that generates an fstab.
2278recovery_fstab := $(call intermediates-dir-for,ETC,$(TARGET_RECOVERY_FSTAB_GENRULE))/$(TARGET_RECOVERY_FSTAB_GENRULE)
Andrew Boiefa61ff02012-09-28 09:33:45 -07002279else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002280recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002281endif
Tao Baoc3c17532016-06-10 10:11:54 -07002282ifdef TARGET_RECOVERY_WIPE
2283recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002284else
Tao Baoc3c17532016-06-10 10:11:54 -07002285recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002286endif
Tao Bao8beab692015-07-22 12:33:18 -07002287
Tao Bao6d5d6232018-03-09 17:04:42 -08002288# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002289# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002290# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2291# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002292#
2293# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002294# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002295# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002296# b) We build a single image that contains boot and recovery both - no recovery image to install
2297# (BOARD_USES_RECOVERY_AS_BOOT = true);
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002298# c) We include the recovery DTBO image within recovery - not needing the resource file as we
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002299# do bsdiff because boot and recovery will contain different number of entries
2300# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002301# d) We include the recovery ACPIO image within recovery - not needing the resource file as we
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002302# do bsdiff because boot and recovery will contain different number of entries
2303# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002304# e) We build a single image that contains vendor_boot and recovery both - no recovery image to
Yifan Hongef7a9712020-10-20 13:17:42 -07002305# install
2306# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002307
Tom Cherry2929cad2018-09-20 11:04:37 -07002308ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002309 $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002310 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002311# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002312RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2313ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002314else
Tao Bao8beab692015-07-22 12:33:18 -07002315RECOVERY_RESOURCE_ZIP :=
2316endif
Doug Zongker4647f122009-07-02 09:00:54 -07002317
Tao Bao139c7272018-07-31 13:26:54 -07002318INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2319
2320$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002321 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2322 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2323 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2324 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2325 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2326 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2327 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2328 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2329
2330# Parses the given list of build variables and writes their values as build properties if defined.
2331# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2332# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2333# $(1): Map from the build variable names to property names
2334# $(2): Output file
2335define append-recovery-ui-properties
2336echo "#" >> $(2)
2337echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2338echo "#" >> $(2)
2339$(foreach prop,$(1), \
2340 $(eval _varname := $(call word-colon,1,$(prop))) \
2341 $(eval _propname := $(call word-colon,2,$(prop))) \
2342 $(eval _value := $($(_varname))) \
2343 $(if $(_value), \
2344 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2345endef
2346
2347$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002348 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002349 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2350 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2351 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002352 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002353 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002354 $(hide) mkdir -p $(dir $@)
2355 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002356 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002357 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002358 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002359 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002360 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002361 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2362
Bob Badour5acd4362022-04-12 18:31:35 -07002363$(call declare-1p-target,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),build)
2364$(call declare-license-deps,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),\
2365 $(INSTALLED_BUILD_PROP_TARGET) $(INSTALLED_VENDOR_BUILD_PROP_TARGET) $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2366 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET))
2367
Yifan Hong33fd5d42020-09-24 18:18:26 -07002368# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2369# On device with dedicated recovery partition, the file should come from the boot
2370# ramdisk.
2371ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2372INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2373$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2374 $(copy-file-to-target)
Bob Badour5acd4362022-04-12 18:31:35 -07002375
2376$(call declare-1p-target,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),build)
2377$(call declare-license-deps,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),$(INSTALLED_RAMDISK_BUILD_PROP_TARGET))
Yifan Hong33fd5d42020-09-24 18:18:26 -07002378endif
2379
Yifan Hongc56931c2020-10-28 16:35:19 -07002380INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002381
Yifan Hong78860162020-10-28 14:15:21 -07002382ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002383INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002384# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002385ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002386ifdef INTERNAL_KERNEL_CMDLINE
2387 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002388endif # INTERNAL_KERNEL_CMDLINE != ""
2389endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002390ifdef BOARD_KERNEL_BASE
2391 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2392endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002393ifdef BOARD_KERNEL_PAGESIZE
2394 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2395endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002396ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002397ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2398 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2399else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002400 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2401endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002402endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002403ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2404 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2405endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002406ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2407 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2408endif
Yifan Hong3941a872020-10-28 16:33:06 -07002409endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002410ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2411 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2412endif
Doug Zongker4647f122009-07-02 09:00:54 -07002413
Yifan Hong881df392020-10-09 14:29:39 -07002414$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002415 $(INTERNAL_ROOT_FILES) \
2416 $(INSTALLED_RAMDISK_TARGET) \
2417 $(INTERNAL_RECOVERYIMAGE_FILES) \
2418 $(recovery_sepolicy) \
2419 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2420 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002421 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002422 $(recovery_resource_deps) \
2423 $(recovery_fstab)
2424 # Making recovery image
2425 mkdir -p $(TARGET_RECOVERY_OUT)
2426 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2427 # Copying baseline ramdisk...
2428 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2429 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2430 # Modifying ramdisk contents...
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002431 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init
Steve Muckleb3dda772020-03-11 16:03:07 -07002432 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2433 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2434 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2435 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2436 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2437 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2438 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2439 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2440 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2441 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2442 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2443 $(foreach item,$(recovery_fstab), \
2444 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2445 $(if $(strip $(recovery_wipe)), \
2446 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2447 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2448 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002449 $(hide) touch $@
2450
2451$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002452 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002453
Ying Wang747b9f12015-01-30 14:05:22 -08002454# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002455# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002456define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002457 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002458 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002459 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002460 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002461 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002462 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002463 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002464 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2465 $(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 +08002466 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002467 $(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 -07002468 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002469 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2470 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002471 $(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),\
2472 $(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 -08002473endef
2474
Dan Willemsend120ac62020-06-12 02:39:34 +00002475recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002476ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002477 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002478endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002479ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002480 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002481endif
Tao Baof4866c72018-08-22 14:35:09 -07002482ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002483 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2484 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2485 else
2486 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2487 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002488endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002489ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002490 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002491endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002492ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002493 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002494endif
Tao Baof4866c72018-08-22 14:35:09 -07002495
Dan Willemsend120ac62020-06-12 02:39:34 +00002496ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002497$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002498$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002499 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002500 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Bob Badourebdefc02022-02-12 15:39:22 -08002501
Bob Badoura60beee2022-09-07 15:34:12 -07002502$(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 -08002503$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2504
Justin Yundd15ec12022-09-23 10:47:21 +09002505UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BOOTIMAGE_TARGET)
Tao Baof4866c72018-08-22 14:35:09 -07002506endif # BOARD_USES_RECOVERY_AS_BOOT
2507
Dan Willemsend120ac62020-06-12 02:39:34 +00002508$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002509 $(call build-recoveryimage-target, $@, \
2510 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002511
Tao Bao4594d0e2015-12-22 09:47:46 -08002512ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002513$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002514 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002515 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2516 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002517endif
Doug Zongker56588872012-08-20 15:38:58 -07002518
Bob Badourebdefc02022-02-12 15:39:22 -08002519
2520$(call declare-1p-container,$(INSTALLED_RECOVERYIMAGE_TARGET),)
2521$(call declare-container-license-deps,$(INSTALLED_RECOVERYIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2522
Justin Yundd15ec12022-09-23 10:47:21 +09002523UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_RECOVERYIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002524
Ying Wang747b9f12015-01-30 14:05:22 -08002525.PHONY: recoveryimage-nodeps
2526recoveryimage-nodeps:
2527 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002528 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2529 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002530
Chris Grossa784ef12019-04-22 11:09:57 -07002531else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002532RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002533endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002534
2535.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002536recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002537
Jiyong Park03eb0612017-10-04 21:22:41 +09002538ifneq ($(BOARD_NAND_PAGE_SIZE),)
2539$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002540endif
2541
Jiyong Park03eb0612017-10-04 21:22:41 +09002542ifneq ($(BOARD_NAND_SPARE_SIZE),)
2543$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002544endif
2545
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002546
Doug Zongker4647f122009-07-02 09:00:54 -07002547# -----------------------------------------------------------------
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002548# Build debug ramdisk and debug boot image.
Colin Cross79a76ec2022-03-21 15:06:11 -07002549INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002550ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
2551
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002552INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002553 $(ALL_DEFAULT_INSTALLED_MODULES))
2554
2555# Directories to be picked into the debug ramdisk.
2556# As these directories are all merged into one single cpio archive, the order
2557# matters. If there are multiple files with the same pathname, then the last one
2558# wins.
2559#
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002560# ramdisk-debug.img will merge the content from either ramdisk.img or
2561# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
2562# is set or not.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002563ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002564 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT)
2565 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002566else # BOARD_USES_RECOVERY_AS_BOOT == true
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002567 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT)
2568 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002569endif # BOARD_USES_RECOVERY_AS_BOOT != true
2570
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002571INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT)
2572INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES)
2573
2574# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
2575INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2576INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2577$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2578$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS)
2579$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2580 @echo "Installed file list: $@"
2581 $(hide) rm -f $@
2582 $(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT)
2583 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
2584 $(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2585 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2586
Bob Badourebdefc02022-02-12 15:39:22 -08002587$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_DEBUG_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07002588$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_DEBUG_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08002589
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002590ifdef BUILDING_DEBUG_BOOT_IMAGE
2591
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002592# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002593# the debug ramdisk, which is the original ramdisk plus additional
2594# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2595# When /force_debuggable is present, /init will load userdebug sepolicy
2596# and property files to allow adb root, if the device is unlocked.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002597INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
Bowgo Tsai0013f552019-03-20 17:59:52 +08002598
Bowgo Tsai610286a2021-04-23 11:31:32 +08002599$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002600$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2601 @echo "Target debug ramdisk: $@"
2602 $(hide) rm -f $@
2603 $(hide) mkdir -p $(dir $@)
2604 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002605
Bob Badourebdefc02022-02-12 15:39:22 -08002606$(call declare-1p-container,$(INSTALLED_DEBUG_RAMDISK_TARGET),)
2607$(call declare-container-license-deps,$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2608
Justin Yundd15ec12022-09-23 10:47:21 +09002609UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002610
Bowgo Tsai0013f552019-03-20 17:59:52 +08002611.PHONY: ramdisk_debug-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002612ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002613 @echo "make $@: ignoring dependencies"
2614 $(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET)
2615 $(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS)
2616 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002617
2618# -----------------------------------------------------------------
2619# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2620#
2621# Note: it's intentional to skip signing for boot-debug.img, because it
2622# can only be used if the device is unlocked with verification error.
Steve Muckleb3dda772020-03-11 16:03:07 -07002623ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002624 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002625 $(PRODUCT_OUT)/$(k).img)
2626else
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002627 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
Steve Muckleb3dda772020-03-11 16:03:07 -07002628endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002629
2630# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002631$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002632ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002633 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 +08002634else
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002635 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 +08002636endif
2637
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002638# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2639# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2640# Using a test key to sign boot-debug.img to continue booting with the mismatched
2641# public key, if the device is unlocked.
2642ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002643$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002644endif
2645
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002646BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2647INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2648# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002649# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002650define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002651$(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 +08002652$(AVBTOOL) add_hash_footer \
2653 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002654 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),$(2)))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002655 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2656 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002657$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002658endef
2659
Steve Muckleb3dda772020-03-11 16:03:07 -07002660# $(1): output file
2661define build-debug-bootimage-target
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002662 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002663 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002664 $(BOARD_MKBOOTIMG_ARGS) --output $1
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002665 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
Steve Muckleb3dda772020-03-11 16:03:07 -07002666endef
2667
Bowgo Tsai0013f552019-03-20 17:59:52 +08002668# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002669$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002670 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002671 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002672
Bob Badoura60beee2022-09-07 15:34:12 -07002673$(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 -08002674$(call declare-container-license-deps,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(INSTALLED_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2675
Justin Yundd15ec12022-09-23 10:47:21 +09002676UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002677
Bowgo Tsai0013f552019-03-20 17:59:52 +08002678.PHONY: bootimage_debug-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002679bootimage_debug-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002680 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002681 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002682
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002683endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002684
Bowgo Tsai6a683672020-02-14 19:00:15 +08002685# -----------------------------------------------------------------
2686# vendor debug ramdisk
2687# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Colin Cross79a76ec2022-03-21 15:06:11 -07002688INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002689ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2690
Bowgo Tsai610286a2021-04-23 11:31:32 +08002691INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
Bowgo Tsai610286a2021-04-23 11:31:32 +08002692 $(ALL_DEFAULT_INSTALLED_MODULES))
2693
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002694# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk.
2695INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT)
2696INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002697
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002698# Exclude recovery files in the default vendor ramdisk if including a standalone
2699# recovery ramdisk in vendor_boot.
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002700ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002701 ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2702 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT)
2703 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
2704 endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true
2705endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002706
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002707INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT)
2708INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
2709
2710# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created.
2711INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2712INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2713$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2714$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS)
2715$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2716 @echo "Installed file list: $@"
2717 $(hide) rm -f $@
2718 $(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2719 $(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2720 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2721
Bob Badour5acd4362022-04-12 18:31:35 -07002722$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK))
2723$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK))
Bob Badourebdefc02022-02-12 15:39:22 -08002724
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002725INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
2726
Bowgo Tsai610286a2021-04-23 11:31:32 +08002727$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002728$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2729 $(hide) rm -f $@
2730 $(hide) mkdir -p $(dir $@)
2731 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002732
Petri Gyntherd7946d12021-03-10 12:38:15 -08002733INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2734$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002735 @echo "Target debug vendor ramdisk: $@"
Petri Gyntherd7946d12021-03-10 12:38:15 -08002736 $(copy-file-to-target)
Petri Gyntherd7946d12021-03-10 12:38:15 -08002737
Bob Badourebdefc02022-02-12 15:39:22 -08002738$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),)
2739$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2740
2741VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2742
Bowgo Tsai6a683672020-02-14 19:00:15 +08002743# -----------------------------------------------------------------
2744# vendor_boot-debug.img.
2745INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2746
2747# The util to sign vendor_boot-debug.img with a test key.
2748BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2749INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2750# $(1): the vendor bootimage to sign
2751define test-key-sign-vendor-bootimage
2752$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2753$(AVBTOOL) add_hash_footer \
2754 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002755 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsai6a683672020-02-14 19:00:15 +08002756 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2757 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2758$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2759endef
2760
2761ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2762$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2763endif
2764
2765# 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 +08002766$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002767$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002768 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002769 $(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 +08002770 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2771 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2772
Bob Badourebdefc02022-02-12 15:39:22 -08002773$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),)
2774$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2775
2776VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
2777
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002778endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai6a683672020-02-14 19:00:15 +08002779
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002780# Appends a few test harness specific properties into the adb_debug.prop.
2781ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2782ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2783
2784INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES)))
2785INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2786$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET)
2787 $(hide) rm -f $@
2788 $(hide) mkdir -p $(dir $@)
2789ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET
2790 $(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@
2791endif
2792 $(hide) echo "" >> $@
2793 $(hide) echo "#" >> $@
2794 $(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@
2795 $(hide) echo "#" >> $@
2796 $(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \
2797 echo "$(line)" >> $@;)
2798
Bob Badour2f66fd12022-03-09 17:30:24 -08002799$(call declare-1p-target,$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET))
2800
Colin Cross79a76ec2022-03-21 15:06:11 -07002801INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002802INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
2803 $(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002804 $(ALL_DEFAULT_INSTALLED_MODULES))
2805
2806# The order is important here. The test harness ramdisk staging directory has to
2807# come last so that it can override the adb_debug.prop in the debug ramdisk
2808# staging directory.
2809INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2810INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
2811
2812ifdef BUILDING_DEBUG_BOOT_IMAGE
2813
Bowgo Tsai0013f552019-03-20 17:59:52 +08002814# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002815# The test harness ramdisk, which is based off debug_ramdisk, plus a
2816# few additional test-harness-specific properties in adb_debug.prop.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002817INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002818
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002819$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS)
2820$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2821 @echo "Target test harness ramdisk: $@"
2822 $(hide) rm -f $@
2823 $(hide) mkdir -p $(dir $@)
2824 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002825
Bob Badourebdefc02022-02-12 15:39:22 -08002826$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),)
2827$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS),$(PRODUCT_OUT)/:/)
2828
Justin Yundd15ec12022-09-23 10:47:21 +09002829UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002830
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002831.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002832ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002833 @echo "make $@: ignoring dependencies"
2834 $(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2835 $(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS)
2836 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002837
2838# -----------------------------------------------------------------
2839# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2840#
2841# Note: it's intentional to skip signing for boot-test-harness.img, because it
2842# can only be used if the device is unlocked with verification error.
Steve Muckle4866bd62020-04-02 11:31:08 -07002843ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2844 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2845 $(PRODUCT_OUT)/$(k).img)
2846else
2847 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2848endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002849
2850# 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 +08002851$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002852INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2853
2854# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2855# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2856# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2857# public key, if the device is unlocked.
2858ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2859$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2860endif
2861
Steve Muckle4866bd62020-04-02 11:31:08 -07002862# $(1): output file
2863define build-boot-test-harness-target
2864 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002865 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002866 $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002867 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002868endef
2869
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002870# 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 +08002871$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002872 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002873 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002874
Bob Badourebdefc02022-02-12 15:39:22 -08002875$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),)
2876$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2877
Justin Yundd15ec12022-09-23 10:47:21 +09002878UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002879
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002880.PHONY: bootimage_test_harness-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002881bootimage_test_harness-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002882 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002883 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002884
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002885endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002886
Bowgo Tsai87f60012021-07-29 23:35:33 +08002887# -----------------------------------------------------------------
2888# vendor test harness ramdisk, which is a vendor ramdisk combined with
2889# a test harness ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002890ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai87f60012021-07-29 23:35:33 +08002891
2892INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
2893
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002894# The order is important here. The test harness ramdisk staging directory has to
2895# come last so that it can override the adb_debug.prop in the debug ramdisk
2896# staging directory.
2897INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2898INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002899
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002900$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002901$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002902 $(hide) rm -f $@
2903 $(hide) mkdir -p $(dir $@)
2904 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai87f60012021-07-29 23:35:33 +08002905
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002906INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
2907$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2908 @echo "Target test harness vendor ramdisk: $@"
2909 $(copy-file-to-target)
2910
Bob Badourebdefc02022-02-12 15:39:22 -08002911$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),)
2912$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2913
2914VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2915
Bowgo Tsai87f60012021-07-29 23:35:33 +08002916# -----------------------------------------------------------------
2917# vendor_boot-test-harness.img.
2918INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
2919
2920ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2921$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2922endif
2923
2924# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
2925$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
2926$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2927$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
2928 $(call pretty,"Target vendor_boot test harness image: $@")
2929 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
2930 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2931 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2932
Bob Badourebdefc02022-02-12 15:39:22 -08002933$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),)
2934$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2935
2936VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
2937
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002938endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2939
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002940endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2941
Bowgo Tsai87f60012021-07-29 23:35:33 +08002942
Colin Crossbd382142020-08-26 15:08:57 -07002943# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2944# $1: from location (e.g $(TARGET_OUT)/vendor)
2945# $2: destination location (e.g. /vendor)
2946# $3: partition image name (e.g. vendor.img)
2947define create-partition-compat-symlink
2948$(eval \
2949$1:
2950 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2951 mkdir -p $(dir $1)
2952 if [ -d $1 ] && [ ! -h $1 ]; then \
2953 echo 'Non-symlink $1 detected!' 1>&2; \
2954 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2955 exit 1; \
2956 fi
2957 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002958$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002959)
2960$1
2961endef
2962
2963
Inseob Kim135c1f12022-01-06 17:22:07 +09002964# FSVerity metadata generation
2965# Generate fsverity metadata files (.fsv_meta) and build manifest
Victor Hsieh89415a82022-09-09 14:16:33 -07002966# (<partition>/etc/security/fsverity/BuildManifest<suffix>.apk) BEFORE filtering systemimage,
2967# vendorimage, odmimage, productimage files below.
2968ifeq ($(PRODUCT_FSVERITY_GENERATE_METADATA),true)
Inseob Kim135c1f12022-01-06 17:22:07 +09002969
Victor Hsieh89415a82022-09-09 14:16:33 -07002970fsverity-metadata-targets-patterns := \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08002971 $(TARGET_OUT)/framework/% \
Inseob Kim135c1f12022-01-06 17:22:07 +09002972 $(TARGET_OUT)/etc/boot-image.prof \
2973 $(TARGET_OUT)/etc/dirty-image-objects \
Nicolas Geoffray13f28212022-03-18 17:28:14 +00002974 $(TARGET_OUT)/etc/preloaded-classes \
Victor Hsieh89415a82022-09-09 14:16:33 -07002975 $(TARGET_OUT)/etc/classpaths/%.pb \
2976
2977ifdef BUILDING_SYSTEM_EXT_IMAGE
2978fsverity-metadata-targets-patterns += $(TARGET_OUT_SYSTEM_EXT)/framework/%
2979endif
Victor Hsieh89415a82022-09-09 14:16:33 -07002980
2981# Generate fsv_meta
2982fsverity-metadata-targets := $(sort $(filter \
2983 $(fsverity-metadata-targets-patterns), \
Colin Crossa1de5df2022-03-21 14:31:31 -07002984 $(ALL_DEFAULT_INSTALLED_MODULES)))
Inseob Kim135c1f12022-01-06 17:22:07 +09002985
2986define fsverity-generate-metadata
Bob Badour2cd35362022-12-01 17:58:57 -08002987$(call declare-0p-target,$(1).fsv_meta)
2988
Inseob Kim135c1f12022-01-06 17:22:07 +09002989$(1).fsv_meta: PRIVATE_SRC := $(1)
2990$(1).fsv_meta: PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2991$(1).fsv_meta: $(HOST_OUT_EXECUTABLES)/fsverity_metadata_generator $(HOST_OUT_EXECUTABLES)/fsverity $(1)
2992 $$< --fsverity-path $$(PRIVATE_FSVERITY) --signature none \
2993 --hash-alg sha256 --output $$@ $$(PRIVATE_SRC)
2994endef
2995
2996$(foreach f,$(fsverity-metadata-targets),$(eval $(call fsverity-generate-metadata,$(f))))
2997ALL_DEFAULT_INSTALLED_MODULES += $(addsuffix .fsv_meta,$(fsverity-metadata-targets))
2998
Inseob Kim135c1f12022-01-06 17:22:07 +09002999FSVERITY_APK_KEY_PATH := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Victor Hsieh89415a82022-09-09 14:16:33 -07003000FSVERITY_APK_MANIFEST_TEMPLATE_PATH := system/security/fsverity/AndroidManifest.xml
3001
3002# Generate and install BuildManifest<suffix>.apk for the given partition
3003# $(1): path of the output APK
3004# $(2): partition name
3005define fsverity-generate-and-install-manifest-apk
3006fsverity-metadata-targets-$(2) := $(filter $(PRODUCT_OUT)/$(2)/%,\
3007 $(fsverity-metadata-targets))
3008$(1): PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
3009$(1): PRIVATE_AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
3010$(1): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
3011$(1): PRIVATE_VERSION_CODE := $(PLATFORM_SDK_VERSION)
3012$(1): PRIVATE_VERSION_NAME := $(APPS_DEFAULT_VERSION_NAME)
3013$(1): PRIVATE_APKSIGNER := $(HOST_OUT_EXECUTABLES)/apksigner
3014$(1): PRIVATE_MANIFEST := $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH)
3015$(1): PRIVATE_FRAMEWORK_RES := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
3016$(1): PRIVATE_KEY := $(FSVERITY_APK_KEY_PATH)
3017$(1): PRIVATE_INPUTS := $$(fsverity-metadata-targets-$(2))
3018$(1): PRIVATE_ASSETS := $(call intermediates-dir-for,ETC,build_manifest-$(2))/assets
3019$(1): $(HOST_OUT_EXECUTABLES)/fsverity_manifest_generator \
Inseob Kim135c1f12022-01-06 17:22:07 +09003020 $(HOST_OUT_EXECUTABLES)/fsverity $(HOST_OUT_EXECUTABLES)/aapt2 \
Victor Hsieh89415a82022-09-09 14:16:33 -07003021 $(HOST_OUT_EXECUTABLES)/apksigner $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH) \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08003022 $(FSVERITY_APK_KEY_PATH).x509.pem $(FSVERITY_APK_KEY_PATH).pk8 \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09003023 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk \
Victor Hsieh89415a82022-09-09 14:16:33 -07003024 $$(fsverity-metadata-targets-$(2))
3025 rm -rf $$(PRIVATE_ASSETS)
3026 mkdir -p $$(PRIVATE_ASSETS)
Victor Hsieh89415a82022-09-09 14:16:33 -07003027 $$< --fsverity-path $$(PRIVATE_FSVERITY) \
3028 --base-dir $$(PRODUCT_OUT) \
3029 --output $$(PRIVATE_ASSETS)/build_manifest.pb \
3030 $$(PRIVATE_INPUTS)
Victor Hsieh89415a82022-09-09 14:16:33 -07003031 $$(PRIVATE_AAPT2) link -o $$@ \
3032 -A $$(PRIVATE_ASSETS) \
3033 -I $$(PRIVATE_FRAMEWORK_RES) \
3034 --min-sdk-version $$(PRIVATE_MIN_SDK_VERSION) \
3035 --version-code $$(PRIVATE_VERSION_CODE) \
3036 --version-name $$(PRIVATE_VERSION_NAME) \
3037 --manifest $$(PRIVATE_MANIFEST) \
3038 --rename-manifest-package com.android.security.fsverity_metadata.$(2)
3039 $$(PRIVATE_APKSIGNER) sign --in $$@ \
3040 --cert $$(PRIVATE_KEY).x509.pem \
3041 --key $$(PRIVATE_KEY).pk8
Inseob Kim135c1f12022-01-06 17:22:07 +09003042
Victor Hsieh89415a82022-09-09 14:16:33 -07003043ALL_DEFAULT_INSTALLED_MODULES += $(1)
Inseob Kim135c1f12022-01-06 17:22:07 +09003044
Victor Hsieh89415a82022-09-09 14:16:33 -07003045endef # fsverity-generate-and-install-manifest-apk
3046
3047$(eval $(call fsverity-generate-and-install-manifest-apk, \
3048 $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk,system))
3049ifdef BUILDING_SYSTEM_EXT_IMAGE
3050 $(eval $(call fsverity-generate-and-install-manifest-apk, \
3051 $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk,system_ext))
3052endif
Victor Hsieh89415a82022-09-09 14:16:33 -07003053
3054endif # PRODUCT_FSVERITY_GENERATE_METADATA
3055
3056
3057# -----------------------------------------------------------------
3058# system image
Inseob Kim135c1f12022-01-06 17:22:07 +09003059
Colin Cross79a76ec2022-03-21 15:06:11 -07003060INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen37a19862018-10-31 16:31:46 -07003061INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Dan Willemsena3f66322020-05-28 15:46:33 -07003062 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07003063
Colin Crossbd382142020-08-26 15:08:57 -07003064# Create symlink /system/vendor to /vendor if necessary.
3065ifdef BOARD_USES_VENDORIMAGE
3066 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
3067endif
3068
3069# Create symlink /system/product to /product if necessary.
3070ifdef BOARD_USES_PRODUCTIMAGE
3071 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
3072endif
3073
3074# Create symlink /system/system_ext to /system_ext if necessary.
3075ifdef BOARD_USES_SYSTEM_EXTIMAGE
3076 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
3077endif
3078
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003079# -----------------------------------------------------------------
3080# system_dlkm partition image
3081
3082# Create symlinks for system_dlkm on devices with a system_dlkm partition:
3083# /system/lib/modules -> /system_dlkm/lib/modules
3084#
3085# On devices with a system_dlkm partition,
3086# - /system/lib/modules is a symlink to a directory that stores system DLKMs.
3087# - The system_dlkm partition is mounted at /system_dlkm at runtime.
Ramji Jiyani13a41372022-01-27 07:05:08 +00003088ifdef BOARD_USES_SYSTEM_DLKMIMAGE
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003089 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/lib/modules,/system_dlkm/lib/modules,system_dlkm.img)
3090endif
3091
Ying Wang82cceba2012-08-13 15:03:00 -07003092FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003093
3094# ASAN libraries in the system image - add dependency.
3095ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07003096ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07003097 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
3098 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
3099 endif
3100endif
3101
Tom Cherryd14b8952018-08-09 14:26:00 -07003102FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07003103
Ying Wange5e8c5f2011-09-09 16:35:53 -07003104# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08003105ifdef BUILDING_SYSTEM_IMAGE
3106
Kiyoung Kim36481e02020-11-16 10:50:05 +09003107# Install system linker configuration
3108# Collect all available stub libraries installed in system and install with predefined linker configuration
Kiyoung Kim0c079592022-12-01 10:15:10 +09003109# Also append LLNDK libraries in the APEX as required libs
Kiyoung Kim36481e02020-11-16 10:50:05 +09003110SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
Colin Crossd4a054f2022-03-15 15:07:07 -07003111SYSTEM_LINKER_CONFIG_SOURCE := $(call intermediates-dir-for,ETC,system_linker_config)/system_linker_config
3112$(SYSTEM_LINKER_CONFIG): PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE := $(SYSTEM_LINKER_CONFIG_SOURCE)
3113$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE) | conv_linker_config
3114 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE) \
Kiyoung Kim36481e02020-11-16 10:50:05 +09003115 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
Kiyoung Kim0c079592022-12-01 10:15:10 +09003116 $(HOST_OUT_EXECUTABLES)/conv_linker_config append --source $@ --output $@ --key requireLibs \
3117 --value "$(foreach lib,$(LLNDK_MOVED_TO_APEX_LIBRARIES), $(lib).so)"
Kiyoung Kim36481e02020-11-16 10:50:05 +09003118
Bob Badour2f66fd12022-03-09 17:30:24 -08003119$(call declare-1p-target,$(SYSTEM_LINKER_CONFIG),)
Colin Crossd4a054f2022-03-15 15:07:07 -07003120$(call declare-license-deps,$(SYSTEM_LINKER_CONFIG),$(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE))
Bob Badour2f66fd12022-03-09 17:30:24 -08003121
Kiyoung Kim36481e02020-11-16 10:50:05 +09003122FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
3123
Ying Wange5e8c5f2011-09-09 16:35:53 -07003124# installed file list
3125# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
3126# We put installed-files.txt ahead of image itself in the dependency graph
3127# so that we can get the size stat even if the build fails due to too large
3128# system image.
3129INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07003130INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
3131$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003132$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003133 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003134 mkdir -p $(dir $@)
3135 rm -f $@
3136 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
3137 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07003138
Bob Badourebdefc02022-02-12 15:39:22 -08003139$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE)))
Bob Badour5acd4362022-04-12 18:31:35 -07003140$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON)))
Bob Badourebdefc02022-02-12 15:39:22 -08003141
Ying Wange5e8c5f2011-09-09 16:35:53 -07003142.PHONY: installed-file-list
3143installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08003144
Ying Wange5e8c5f2011-09-09 16:35:53 -07003145systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003146 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003147BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
3148
The Android Open Source Project88b60792009-03-03 19:28:42 -08003149# $(1): output file
3150define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07003151 @echo "Target system fs image: $(1)"
3152 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003153 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07003154 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003155 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003156 $(BUILD_IMAGE) \
3157 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
3158 || ( mkdir -p $${DIST_DIR}; \
3159 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
3160 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08003161endef
3162
Dan Willemsen6b72c732019-06-12 21:33:38 +00003163ifeq ($(BOARD_AVB_ENABLE),true)
3164$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
3165endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07003166$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003167 $(call build-systemimage-target,$@)
3168
Bob Badour879cfa82021-04-15 10:41:38 -07003169$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
Bob Badourebdefc02022-02-12 15:39:22 -08003170$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:/)
Bob Badour879cfa82021-04-15 10:41:38 -07003171
Tao Baoe9d61b02018-08-20 21:09:07 -07003172INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07003173SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003174
Tao Baoe9d61b02018-08-20 21:09:07 -07003175# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
3176# compatibility, in case device-specific Makefiles still refer to the old name.
3177INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
3178
Doug Zongker73ef8252009-07-23 15:12:53 -07003179# The system partition needs room for the recovery image as well. We
3180# now store the recovery image as a binary patch using the boot image
3181# as the source (since they are very similar). Generate the patch so
3182# we can see how big it's going to be, and include that in the system
3183# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07003184ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07003185ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07003186ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08003187ifneq (,$(filter true,$(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08003188diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
3189else
3190diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
3191endif
Doug Zongker73ef8252009-07-23 15:12:53 -07003192intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
3193RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08003194$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
3195$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00003196 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07003197 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003198 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07003199 @echo "Construct recovery from boot"
3200 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07003201 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07003202else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
3203RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07003204endif # BOARD_USES_FULL_RECOVERY_IMAGE
3205endif # INSTALLED_RECOVERYIMAGE_TARGET
3206endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07003207
Yifan Hong9a3cad92020-04-27 19:06:59 -07003208$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003209 @echo "Install system fs image: $@"
3210 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003211 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003212
Bob Badour879cfa82021-04-15 10:41:38 -07003213$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
3214$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
3215
Tao Baoe9d61b02018-08-20 21:09:07 -07003216systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003217
Bob Badourebdefc02022-02-12 15:39:22 -08003218SYSTEM_NOTICE_DEPS += $(INSTALLED_SYSTEMIMAGE_TARGET)
Bob Badour879cfa82021-04-15 10:41:38 -07003219
The Android Open Source Project88b60792009-03-03 19:28:42 -08003220.PHONY: systemimage-nodeps snod
3221systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07003222 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003223 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07003224 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00003225 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08003226ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00003227 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08003228endif
3229
Dan Willemsen67495202019-01-16 12:42:05 -08003230endif # BUILDING_SYSTEM_IMAGE
3231
Anton Hansson30e061b2018-11-12 13:36:46 +00003232.PHONY: sync syncsys
3233sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07003234
Ying Wang3a61eeb2016-03-11 10:32:01 -08003235# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07003236# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07003237.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07003238platform:
3239 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07003240
3241.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07003242platform-java:
3243 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07003244
Ying Wang3a61eeb2016-03-11 10:32:01 -08003245# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003246# data partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003247INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_DATA)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003248INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003249 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003250
Dan Willemsen67495202019-01-16 12:42:05 -08003251ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07003252userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003253 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07003254BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
3255
Ying Wangbd93d422011-10-28 17:02:30 -07003256define build-userdataimage-target
3257 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
3258 @mkdir -p $(TARGET_OUT_DATA)
3259 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003260 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003261 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003262 $(BUILD_IMAGE) \
3263 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
3264 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
3265 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07003266endef
3267
Joe Onorato64d85d02009-04-09 19:31:12 -07003268# We just build this directly to the install location.
3269INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003270INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
3271 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003272 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003273$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003274 $(build-userdataimage-target)
3275
Bob Badourebdefc02022-02-12 15:39:22 -08003276$(call declare-1p-container,$(INSTALLED_USERDATAIMAGE_TARGET),)
3277$(call declare-container-license-deps,$(INSTALLED_USERDATAIMAGE_TARGET),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS),$(PRODUCT_OUT)/:/)
3278
Justin Yundd15ec12022-09-23 10:47:21 +09003279UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_USERDATAIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003280
The Android Open Source Project88b60792009-03-03 19:28:42 -08003281.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07003282userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003283 $(build-userdataimage-target)
3284
Dan Willemsen67495202019-01-16 12:42:05 -08003285endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07003286
Andreas Gampe039b5c72017-03-24 16:06:31 -07003287# ASAN libraries in the system image - build rule.
3288ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
3289 $(TARGET_OUT_SHARED_LIBRARIES) \
3290 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
3291 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
3292 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07003293# Extra options: Enforce the system user for the files to avoid having to change ownership.
3294ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07003295# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
3296# enough space.
3297$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07003298 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 -07003299
The Android Open Source Project88b60792009-03-03 19:28:42 -08003300# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04003301# partition table image
3302ifdef BOARD_BPT_INPUT_FILES
3303
3304BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003305BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04003306
3307INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
3308 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003309 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04003310 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
3311
3312ifdef BOARD_BPT_DISK_SIZE
3313INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
3314endif
3315
3316define build-bptimage-target
3317 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
3318 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
3319endef
3320
3321INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003322$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
3323 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
3324
David Zeuthen25328622016-04-08 15:08:03 -04003325$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
3326 $(build-bptimage-target)
3327
Bob Badourebdefc02022-02-12 15:39:22 -08003328$(call declare-1p-container,$(INSTALLED_BPTIMAGE_TARGET),)
3329$(call declare-container-license-deps,$(INSTALLED_BPTIMAGE_TARGET),$(BOARD_BPT_INPUT_FILES),$(PRODUCT_OUT)/:/)
3330
Justin Yundd15ec12022-09-23 10:47:21 +09003331UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BPTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003332
David Zeuthen25328622016-04-08 15:08:03 -04003333.PHONY: bptimage-nodeps
3334bptimage-nodeps:
3335 $(build-bptimage-target)
3336
3337endif # BOARD_BPT_INPUT_FILES
3338
3339# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07003340# cache partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003341INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_CACHE)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003342ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003343INTERNAL_CACHEIMAGE_FILES := \
3344 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
3345
3346cacheimage_intermediates := \
3347 $(call intermediates-dir-for,PACKAGING,cache)
3348BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
3349
3350define build-cacheimage-target
3351 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
3352 @mkdir -p $(TARGET_OUT_CACHE)
3353 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003354 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003355 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003356 $(BUILD_IMAGE) \
3357 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
3358 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
3359 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07003360endef
3361
3362# We just build this directly to the install location.
3363INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003364$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07003365 $(build-cacheimage-target)
3366
Bob Badourebdefc02022-02-12 15:39:22 -08003367$(call declare-1p-container,$(INSTALLED_CACHEIMAGE_TARGET),)
3368$(call declare-container-license-deps,$(INSTALLED_CACHEIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES),$(PRODUCT_OUT)/:/)
3369
Justin Yundd15ec12022-09-23 10:47:21 +09003370UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_CACHEIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003371
Ying Wang9f8e8db2011-11-04 11:37:01 -07003372.PHONY: cacheimage-nodeps
3373cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3374 $(build-cacheimage-target)
3375
Dan Willemsen67495202019-01-16 12:42:05 -08003376else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07003377# we need to ignore the broken cache link when doing the rsync
3378IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08003379endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003380
David Zeuthen0eb10972016-09-28 17:55:27 -04003381# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07003382# system_other partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003383INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_OTHER)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003384ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003385ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07003386# Marker file to identify that odex files are installed
3387INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
3388ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
3389$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
3390 $(hide) touch $@
Bob Badour2f66fd12022-03-09 17:30:24 -08003391
3392$(call declare-0p-target,$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER))
Alex Light4e358ab2016-06-16 14:47:10 -07003393endif
3394
Alex Light4e358ab2016-06-16 14:47:10 -07003395INTERNAL_SYSTEMOTHERIMAGE_FILES := \
3396 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003397 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07003398
Colin Cross6db5b0e2018-11-16 21:26:33 -08003399# system_other dex files are installed as a side-effect of installing system image files
3400INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
3401
Alex Light4e358ab2016-06-16 14:47:10 -07003402INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07003403INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
3404$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003405$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07003406 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003407 mkdir -p $(dir $@)
3408 rm -f $@
3409 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
3410 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07003411
Bob Badourebdefc02022-02-12 15:39:22 -08003412$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEMOTHER)))
Bob Badour5acd4362022-04-12 18:31:35 -07003413$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEMOTHER)))
Bob Badourebdefc02022-02-12 15:39:22 -08003414
Bowgo Tsai867ab662019-01-29 13:30:18 +08003415# Determines partition size for system_other.img.
3416ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
3417ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
3418INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
3419endif
3420endif
3421
3422ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
3423INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
3424endif
3425
Alex Light4e358ab2016-06-16 14:47:10 -07003426systemotherimage_intermediates := \
3427 $(call intermediates-dir-for,PACKAGING,system_other)
3428BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
3429
3430# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
3431define build-systemotherimage-target
3432 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
3433 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
3434 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003435 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003436 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003437 $(BUILD_IMAGE) \
3438 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
3439 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
3440 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07003441endef
3442
3443# We just build this directly to the install location.
3444INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003445ifneq (true,$(SANITIZE_LITE))
3446# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07003447$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
3448 $(build-systemotherimage-target)
Bob Badourebdefc02022-02-12 15:39:22 -08003449
3450$(call declare-1p-container,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),)
3451$(call declare-container-license-deps,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES),$(PRODUCT_OUT)/:/)
3452
3453UNMOUNTED_NOTICE_DEPS += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003454endif
Alex Light4e358ab2016-06-16 14:47:10 -07003455
3456.PHONY: systemotherimage-nodeps
3457systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3458 $(build-systemotherimage-target)
3459
Dan Willemsen67495202019-01-16 12:42:05 -08003460endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003461
3462
3463# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07003464# vendor partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003465INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003466ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07003467INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07003468 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003469 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07003470
Ying Wang8da19e32015-09-15 14:22:12 -07003471
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003472# Create symlink /vendor/odm to /odm if necessary.
3473ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003474 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003475endif
3476
Yifan Honge51dff22020-06-23 17:26:57 -07003477# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
3478# /vendor/lib/modules -> /vendor_dlkm/lib/modules
3479#
3480# On devices with a vendor_dlkm partition,
3481# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
3482# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
3483# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3484# are hidden.
3485# On devices without a vendor_dlkm partition,
3486# - /vendor/lib/modules stores vendor DLKMs directly.
3487# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
3488# See system/core/rootdir/Android.mk for a list of created symlinks.
3489# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
3490# are not guaranteed to exist on all devices.
3491ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003492 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 -07003493endif
3494
Colin Crossbd382142020-08-26 15:08:57 -07003495INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
3496INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3497$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
3498$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3499 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003500 mkdir -p $(dir $@)
3501 rm -f $@
3502 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
3503 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07003504
Bob Badour5acd4362022-04-12 18:31:35 -07003505$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR))
3506$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR))
Bob Badourebdefc02022-02-12 15:39:22 -08003507
Ying Wanga0febe52013-03-20 11:02:05 -07003508vendorimage_intermediates := \
3509 $(call intermediates-dir-for,PACKAGING,vendor)
3510BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003511define build-vendorimage-target
3512 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3513 @mkdir -p $(TARGET_OUT_VENDOR)
3514 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003515 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003516 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003517 $(BUILD_IMAGE) \
3518 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3519 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003520 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003521endef
3522
3523# We just build this directly to the install location.
3524INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003525$(INSTALLED_VENDORIMAGE_TARGET): \
3526 $(INTERNAL_USERIMAGES_DEPS) \
3527 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003528 $(INSTALLED_FILES_FILE_VENDOR) \
3529 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003530 $(build-vendorimage-target)
3531
Bob Badourebdefc02022-02-12 15:39:22 -08003532VENDOR_NOTICE_DEPS += $(INSTALLED_VENDORIMAGE_TARGET)
3533
Bob Badour5acd4362022-04-12 18:31:35 -07003534$(call declare-container-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08003535$(call declare-container-license-deps,$(INSTALLED_VENDORIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(RECOVERY_FROM_BOOT_PATH),$(PRODUCT_OUT)/:/)
3536
Steven Morelanda2e734d2017-03-07 12:10:09 -08003537.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003538vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003539 $(build-vendorimage-target)
3540
Colin Cross91a52272017-06-20 16:57:52 -07003541sync: $(INTERNAL_VENDORIMAGE_FILES)
3542
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003543else ifdef BOARD_PREBUILT_VENDORIMAGE
3544INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3545$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
Bob Badour5acd4362022-04-12 18:31:35 -07003546$(if $(strip $(ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC)),,\
3547 $(if $(strip $(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
Bob Badourba337242022-05-27 19:40:41 -07003548 $(call declare-copy-target-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_PREBUILT_VENDORIMAGE)),\
Bob Badour5acd4362022-04-12 18:31:35 -07003549 $(call declare-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)))
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003550endif
Ying Wanga0febe52013-03-20 11:02:05 -07003551
Ying Wang9f8e8db2011-11-04 11:37:01 -07003552# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003553# product partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003554INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_PRODUCT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003555ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003556INTERNAL_PRODUCTIMAGE_FILES := \
3557 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003558 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003559
3560INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003561INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3562$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003563$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003564 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003565 mkdir -p $(dir $@)
3566 rm -f $@
3567 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3568 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003569
Bob Badour5acd4362022-04-12 18:31:35 -07003570$(call declare-0p-target,$(INSTALLED_FILES_FILE_PRODUCT))
3571$(call declare-0p-target,$(INSTALLED_FILES_JSON_PRODUCT))
Bob Badourebdefc02022-02-12 15:39:22 -08003572
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003573productimage_intermediates := \
3574 $(call intermediates-dir-for,PACKAGING,product)
3575BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3576define build-productimage-target
3577 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3578 @mkdir -p $(TARGET_OUT_PRODUCT)
3579 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003580 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003581 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003582 $(BUILD_IMAGE) \
3583 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3584 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3585 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003586endef
3587
3588# We just build this directly to the install location.
3589INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003590$(INSTALLED_PRODUCTIMAGE_TARGET): \
3591 $(INTERNAL_USERIMAGES_DEPS) \
3592 $(INTERNAL_PRODUCTIMAGE_FILES) \
3593 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003594 $(build-productimage-target)
3595
Bob Badourebdefc02022-02-12 15:39:22 -08003596PRODUCT_NOTICE_DEPS += $(INSTALLED_PRODUCTIMAGE_TARGET)
3597
3598$(call declare-1p-container,$(INSTALLED_PRODUCTIMAGE_TARGET),)
3599$(call declare-container-license-deps,$(INSTALLED_PRODUCTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT),$(PRODUCT_OUT)/:/)
3600
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003601.PHONY: productimage-nodeps pnod
3602productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3603 $(build-productimage-target)
3604
3605sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3606
3607else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3608INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3609$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3610endif
3611
3612# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003613# system_ext partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003614INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_EXT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Justin Yun6151e3f2019-06-25 15:58:13 +09003615ifdef BUILDING_SYSTEM_EXT_IMAGE
3616INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3617 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003618 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003619
Justin Yun6151e3f2019-06-25 15:58:13 +09003620INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3621INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3622$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3623$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003624 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003625 mkdir -p $(dir $@)
3626 rm -f $@
3627 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3628 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003629
Bob Badour5acd4362022-04-12 18:31:35 -07003630$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_EXT))
3631$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_EXT))
Bob Badourebdefc02022-02-12 15:39:22 -08003632
Justin Yun6151e3f2019-06-25 15:58:13 +09003633system_extimage_intermediates := \
3634 $(call intermediates-dir-for,PACKAGING,system_ext)
3635BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3636define build-system_extimage-target
3637 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3638 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3639 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3640 $(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 -07003641 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003642 $(BUILD_IMAGE) \
3643 $(TARGET_OUT_SYSTEM_EXT) \
3644 $(system_extimage_intermediates)/system_ext_image_info.txt \
3645 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3646 $(TARGET_OUT)
3647 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003648endef
3649
3650# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003651INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003652$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3653 $(INTERNAL_USERIMAGES_DEPS) \
3654 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3655 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003656 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003657
Bob Badourebdefc02022-02-12 15:39:22 -08003658SYSTEM_EXT_NOTICE_DEPS += $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
3659
3660$(call declare-1p-container,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),)
3661$(call declare-container-license-deps,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_EXT),$(PRODUCT_OUT)/:/)
3662
Justin Yun6151e3f2019-06-25 15:58:13 +09003663.PHONY: systemextimage-nodeps senod
3664systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3665 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003666
Justin Yun6151e3f2019-06-25 15:58:13 +09003667sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003668
Justin Yun6151e3f2019-06-25 15:58:13 +09003669else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3670INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3671$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003672endif
3673
3674# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003675# odm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003676INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003677ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003678INTERNAL_ODMIMAGE_FILES := \
3679 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003680 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003681
Colin Crossbd382142020-08-26 15:08:57 -07003682# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3683# /odm/lib/modules -> /odm_dlkm/lib/modules
3684#
3685# On devices with a odm_dlkm partition,
3686# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3687# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3688# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3689# are hidden.
3690# On devices without a odm_dlkm partition,
3691# - /odm/lib/modules stores odm DLKMs directly.
3692# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3693# See system/core/rootdir/Android.mk for a list of created symlinks.
3694# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3695# are not guaranteed to exist on all devices.
3696ifdef BOARD_USES_ODM_DLKMIMAGE
3697 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3698endif
3699
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003700INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3701INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3702$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003703$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003704 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003705 mkdir -p $(dir $@)
3706 rm -f $@
3707 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3708 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003709
Bob Badour5acd4362022-04-12 18:31:35 -07003710$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM))
3711$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM))
Bob Badourebdefc02022-02-12 15:39:22 -08003712
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003713odmimage_intermediates := \
3714 $(call intermediates-dir-for,PACKAGING,odm)
3715BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3716define build-odmimage-target
3717 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3718 @mkdir -p $(TARGET_OUT_ODM)
3719 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003720 $(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
3721 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003722 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003723 $(BUILD_IMAGE) \
3724 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3725 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3726 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003727endef
3728
3729# We just build this directly to the install location.
3730INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003731$(INSTALLED_ODMIMAGE_TARGET): \
3732 $(INTERNAL_USERIMAGES_DEPS) \
3733 $(INTERNAL_ODMIMAGE_FILES) \
3734 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003735 $(build-odmimage-target)
3736
Bob Badourebdefc02022-02-12 15:39:22 -08003737ODM_NOTICE_DEPS += $(INSTALLED_ODMIMAGE_TARGET)
3738
3739$(call declare-1p-container,$(INSTALLED_ODMIMAGE_TARGET),)
3740$(call declare-container-license-deps,$(INSTALLED_ODMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM),$(PRODUCT_OUT)/:/)
3741
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003742.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003743odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003744 $(build-odmimage-target)
3745
3746sync: $(INTERNAL_ODMIMAGE_FILES)
3747
3748else ifdef BOARD_PREBUILT_ODMIMAGE
3749INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3750$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3751endif
3752
3753# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003754# vendor_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003755INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003756ifdef BUILDING_VENDOR_DLKM_IMAGE
3757INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3758 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003759 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003760
3761INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3762INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3763$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3764$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3765 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003766 mkdir -p $(dir $@)
3767 rm -f $@
3768 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3769 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003770
Bob Badour5acd4362022-04-12 18:31:35 -07003771$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DLKM))
3772$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003773
Yifan Hongcfb917a2020-05-07 14:58:20 -07003774vendor_dlkmimage_intermediates := \
3775 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3776BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3777define build-vendor_dlkmimage-target
3778 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3779 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3780 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003781 $(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
3782 vendor_dlkm, skip_fsck=true)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003783 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3784 $(BUILD_IMAGE) \
3785 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3786 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3787 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3788endef
3789
3790# We just build this directly to the install location.
3791INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3792$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3793 $(INTERNAL_USERIMAGES_DEPS) \
3794 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3795 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3796 $(build-vendor_dlkmimage-target)
3797
Bob Badourebdefc02022-02-12 15:39:22 -08003798VENDOR_DLKM_NOTICE_DEPS += $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
3799
3800$(call declare-1p-container,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),)
3801$(call declare-container-license-deps,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR_DLKM),$(PRODUCT_OUT)/:/)
3802
Yifan Hongcfb917a2020-05-07 14:58:20 -07003803.PHONY: vendor_dlkmimage-nodeps vdnod
3804vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3805 $(build-vendor_dlkmimage-target)
3806
3807sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3808
3809else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3810INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3811$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3812endif
3813
3814# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003815# odm_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003816INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003817ifdef BUILDING_ODM_DLKM_IMAGE
3818INTERNAL_ODM_DLKMIMAGE_FILES := \
3819 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003820 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003821
3822INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3823INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3824$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3825$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3826 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003827 mkdir -p $(dir $@)
3828 rm -f $@
3829 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3830 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003831
Bob Badour5acd4362022-04-12 18:31:35 -07003832$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM_DLKM))
3833$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003834
Yifan Hongf496f1b2020-07-15 16:52:59 -07003835odm_dlkmimage_intermediates := \
3836 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3837BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3838define build-odm_dlkmimage-target
3839 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3840 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3841 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003842 $(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
3843 odm_dlkm, skip_fsck=true)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003844 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3845 $(BUILD_IMAGE) \
3846 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3847 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3848 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3849endef
3850
3851# We just build this directly to the install location.
3852INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3853$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3854 $(INTERNAL_USERIMAGES_DEPS) \
3855 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3856 $(INSTALLED_FILES_FILE_ODM_DLKM)
3857 $(build-odm_dlkmimage-target)
3858
Bob Badourebdefc02022-02-12 15:39:22 -08003859ODM_DLKM_NOTICE_DEPS += $(INSTALLED_ODM_DLKMIMAGE_TARGET)
3860
3861$(call declare-1p-container,$(INSTALLED_ODM_DLKMIMAGE_TARGET),)
3862$(call declare-container-license-deps,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM_DLKM),$(PRODUCT_OUT)/:/)
3863
Yifan Hongf496f1b2020-07-15 16:52:59 -07003864.PHONY: odm_dlkmimage-nodeps odnod
3865odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3866 $(build-odm_dlkmimage-target)
3867
3868sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3869
3870else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3871INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3872$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3873endif
3874
Ramji Jiyani13a41372022-01-27 07:05:08 +00003875# -----------------------------------------------------------------
3876# system_dlkm partition image
3877
Colin Cross79a76ec2022-03-21 15:06:11 -07003878INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Ramji Jiyani13a41372022-01-27 07:05:08 +00003879ifdef BUILDING_SYSTEM_DLKM_IMAGE
3880
3881INTERNAL_SYSTEM_DLKMIMAGE_FILES := \
3882 $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,\
3883 $(ALL_DEFAULT_INSTALLED_MODULES))
3884
3885INSTALLED_FILES_FILE_SYSTEM_DLKM := $(PRODUCT_OUT)/installed-files-system_dlkm.txt
3886INSTALLED_FILES_JSON_SYSTEM_DLKM := $(INSTALLED_FILES_FILE_SYSTEM_DLKM:.txt=.json)
3887$(INSTALLED_FILES_FILE_SYSTEM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_DLKM)
3888$(INSTALLED_FILES_FILE_SYSTEM_DLKM): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3889 @echo Installed file list: $@
3890 mkdir -p $(dir $@)
Ramji Jiyani13a41372022-01-27 07:05:08 +00003891 rm -f $@
3892 $(FILESLIST) $(TARGET_OUT_SYSTEM_DLKM) > $(@:.txt=.json)
3893 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3894
Bob Badour5acd4362022-04-12 18:31:35 -07003895$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_DLKM))
3896$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003897
Ramji Jiyani13a41372022-01-27 07:05:08 +00003898system_dlkmimage_intermediates := \
3899 $(call intermediates-dir-for,PACKAGING,system_dlkm)
3900BUILT_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3901define build-system_dlkmimage-target
3902 $(call pretty,"Target system_dlkm fs image: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)")
3903 @mkdir -p $(TARGET_OUT_SYSTEM_DLKM)
3904 @mkdir -p $(system_dlkmimage_intermediates) && rm -rf $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt
3905 $(call generate-image-prop-dictionary, $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt, \
3906 system_dlkm, skip_fsck=true)
3907 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3908 $(BUILD_IMAGE) \
3909 $(TARGET_OUT_SYSTEM_DLKM) $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt \
3910 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3911 $(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
3912endef
3913
3914# We just build this directly to the install location.
3915INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
3916$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): \
3917 $(INTERNAL_USERIMAGES_DEPS) \
3918 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
3919 $(INSTALLED_FILES_FILE_SYSTEM_DLKM)
3920 $(build-system_dlkmimage-target)
3921
Bob Badour56e0de52022-08-02 17:46:48 +00003922SYSTEM_DLKM_NOTICE_DEPS += $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
3923
3924$(call declare-1p-container,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),)
3925$(call declare-container-license-deps,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_DLKM),$(PRODUCT_OUT)/:/)
3926
Ramji Jiyani13a41372022-01-27 07:05:08 +00003927.PHONY: system_dlkmimage-nodeps sdnod
3928system_dlkmimage-nodeps sdnod: | $(INTERNAL_USERIMAGES_DEPS)
3929 $(build-system_dlkmimage-target)
3930
3931sync: $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
3932
3933else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
3934INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3935$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_DLKMIMAGE),$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)))
3936endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07003937
3938# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003939# dtbo image
3940ifdef BOARD_PREBUILT_DTBOIMAGE
3941INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3942
3943ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003944$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003945 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3946 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003947 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003948 $(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003949 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3950 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08003951
3952$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_TARGET),)
3953$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_TARGET),$(BOARD_PREBUILT_DTBOIMAGE),$(PRODUCT_OUT)/:/)
3954
Justin Yundd15ec12022-09-23 10:47:21 +09003955UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003956else
3957$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3958 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3959endif
3960
Tao Bao0da43472018-08-22 22:53:41 -07003961endif # BOARD_PREBUILT_DTBOIMAGE
3962
Andrew Scull9b103e42020-11-29 14:04:28 +00003963# -----------------------------------------------------------------
3964# Protected VM firmware image
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003965ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Pierre-Clément Tosiadbf4da2022-09-09 15:57:58 +01003966
3967.PHONY: pvmfwimage
3968pvmfwimage: $(INSTALLED_PVMFWIMAGE_TARGET)
3969
Andrew Scull9b103e42020-11-29 14:04:28 +00003970INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00003971INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01003972INSTALLED_PVMFW_BINARY_TARGET := $(call module-installed-files,pvmfw_bin)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003973INTERNAL_PVMFWIMAGE_FILES := $(call module-target-built-files,pvmfw_img)
Pierre-Clément Tosi615f0812022-10-26 16:05:16 +01003974INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,pvmfw_embedded_key)
Jiyong Parke219f002022-12-16 14:30:03 +09003975INTERNAL_PVMFW_SYMBOL := $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/pvmfw
Bob Badourebdefc02022-02-12 15:39:22 -08003976
3977$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003978$(call declare-container-license-deps,$(INSTALLED_PVMFWIMAGE_TARGET),$(INTERNAL_PVMFWIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badourebdefc02022-02-12 15:39:22 -08003979
Justin Yundd15ec12022-09-23 10:47:21 +09003980UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_PVMFWIMAGE_TARGET)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003981
Jiyong Parke219f002022-12-16 14:30:03 +09003982# Place the unstripped pvmfw image to the symbols directory
3983$(INTERNAL_PVMFWIMAGE_FILES): |$(INTERNAL_PVMFW_SYMBOL)
3984
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003985$(eval $(call copy-one-file,$(INTERNAL_PVMFWIMAGE_FILES),$(INSTALLED_PVMFWIMAGE_TARGET)))
Andrew Scull9b103e42020-11-29 14:04:28 +00003986
Andrew Scullbbc930b2022-02-17 22:34:27 +00003987$(INSTALLED_PVMFWIMAGE_TARGET): $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)
3988
3989$(eval $(call copy-one-file,$(INTERNAL_PVMFW_EMBEDDED_AVBKEY),$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)))
3990
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003991endif # BOARD_USES_PVMFWIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00003992
Tao Bao0da43472018-08-22 22:53:41 -07003993# Returns a list of image targets corresponding to the given list of partitions. For example, it
3994# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3995# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003996# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003997define images-for-partitions
Bowgo Tsai4f62aa02022-01-04 14:21:39 +08003998$(strip $(foreach item,$(1),\
3999 $(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
4000 $(if $(filter $(item),init_boot),$(INSTALLED_INIT_BOOT_IMAGE_TARGET),\
Ramji Jiyani13a41372022-01-27 07:05:08 +00004001 $(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))))
Tao Bao0da43472018-08-22 22:53:41 -07004002endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07004003
4004# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07004005# custom images
4006INSTALLED_CUSTOMIMAGES_TARGET :=
4007
4008ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4009INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
4010
4011# Sign custom image.
4012# $(1): the prebuilt custom image.
4013# $(2): the mount point of the prebuilt custom image.
4014# $(3): the signed custom image target.
4015define sign_custom_image
4016$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
4017 @echo Target custom image: $(3)
4018 mkdir -p $(dir $(3))
4019 cp $(1) $(3)
4020ifeq ($(BOARD_AVB_ENABLE),true)
4021 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
4022 $(AVBTOOL) add_hashtree_footer \
4023 --image $(3) \
4024 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
4025 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08004026 $(call get-partition-size-argument,$(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE)) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004027 --partition_name $(2) \
4028 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
4029 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
4030endif
4031INSTALLED_CUSTOMIMAGES_TARGET += $(3)
4032endef
4033
4034$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4035 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
4036 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
4037endif
4038
4039# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004040# vbmeta image
4041ifeq ($(BOARD_AVB_ENABLE),true)
4042
4043BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004044AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004045
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004046ifdef BOARD_AVB_KEY_PATH
4047$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
4048else
4049# If key path isn't specified, use the 4096-bit test key.
4050BOARD_AVB_ALGORITHM := SHA256_RSA4096
4051BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
4052endif
4053
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004054# AVB signing for system_other.img.
4055ifdef BUILDING_SYSTEM_OTHER_IMAGE
4056ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
4057$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
4058else
4059# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
4060BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
4061BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
4062endif
4063
Bowgo Tsaie4544b12019-02-27 10:15:51 +08004064$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
4065 @echo Extracting system_other avb key: $@
4066 @rm -f $@
4067 @mkdir -p $(dir $@)
4068 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08004069
Bob Badourebdefc02022-02-12 15:39:22 -08004070$(eval $(call declare-0p-target,$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET),))
4071
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004072ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
4073BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
4074endif
4075
4076BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
4077endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
4078
Tao Bao744c4c72018-08-20 21:09:07 -07004079INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07004080 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07004081 $(BOARD_AVB_VBMETA_VENDOR)
4082
4083# Not allowing the same partition to appear in multiple groups.
4084ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07004085 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07004086endif
4087
cfig1aeef722019-09-20 22:45:06 +08004088# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
4089# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
4090# details.
Yifan Hong65afc072020-04-17 10:08:10 -07004091ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08004092ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4093$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07004094 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08004095 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
4096endif
4097endif
4098
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004099# Appends os version as a AVB property descriptor.
4100SYSTEM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4101BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
4102 --prop com.android.build.system.os_version:$(SYSTEM_OS_VERSION)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004103
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004104PRODUCT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4105BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
4106 --prop com.android.build.product.os_version:$(PRODUCT_OS_VERSION)
4107
4108SYSTEM_EXT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4109BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
4110 --prop com.android.build.system_ext.os_version:$(SYSTEM_EXT_OS_VERSION)
4111
4112INIT_BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4113BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4114 --prop com.android.build.init_boot.os_version:$(INIT_BOOT_OS_VERSION)
4115
4116BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4117BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4118 --prop com.android.build.boot.os_version:$(BOOT_OS_VERSION)
4119
4120VENDOR_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4121BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4122 --prop com.android.build.vendor.os_version:$(VENDOR_OS_VERSION)
4123
4124ODM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4125BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4126 --prop com.android.build.odm.os_version:$(ODM_OS_VERSION)
4127
4128VENDOR_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4129BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4130 --prop com.android.build.vendor_dlkm.os_version:$(VENDOR_DLKM_OS_VERSION)
4131
4132ODM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4133BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4134 --prop com.android.build.odm_dlkm.os_version:$(ODM_DLKM_OS_VERSION)
4135
4136SYSTEM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4137BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4138 --prop com.android.build.system_dlkm.os_version:$(SYSTEM_DLKM_OS_VERSION)
4139
4140# Appends fingerprint and security patch level as a AVB property descriptor.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004141BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004142 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004143 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
4144
4145BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004146 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004147 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
4148
Justin Yun6151e3f2019-06-25 15:58:13 +09004149BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004150 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004151 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004152
Bowgo Tsai9b548012019-05-14 16:57:03 +08004153BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsai8c7f8202022-02-22 14:47:45 +08004154 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004155
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004156BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004157 --prop com.android.build.init_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004158
Tao Bao19b02fe2019-10-09 00:04:28 -07004159BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
4160 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4161
Lucas Weif57333f2022-02-24 10:30:15 +08004162BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS += \
4163 --prop com.android.build.vendor_kernel_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4164
Tao Bao19b02fe2019-10-09 00:04:28 -07004165BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
4166 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4167
Bowgo Tsai9b548012019-05-14 16:57:03 +08004168BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004169 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004170
4171BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004172 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004173
Yifan Hongcfb917a2020-05-07 14:58:20 -07004174BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004175 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004176
Yifan Hongf496f1b2020-07-15 16:52:59 -07004177BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004178 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004179
Ramji Jiyani13a41372022-01-27 07:05:08 +00004180BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004181 --prop com.android.build.system_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004182
Tao Bao19b02fe2019-10-09 00:04:28 -07004183BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
4184 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4185
Andrew Scull9b103e42020-11-29 14:04:28 +00004186BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4187 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4188
Bowgo Tsai9b548012019-05-14 16:57:03 +08004189# The following vendor- and odm-specific images needs explicit SPL set per board.
Devin Moore380d9e42021-11-04 19:01:19 +00004190# TODO(b/210875415) Is this security_patch property used? Should it be removed from
4191# boot.img when there is no platform ramdisk included in it?
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004192ifdef BOOT_SECURITY_PATCH
4193BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4194 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004195endif
4196
4197ifdef INIT_BOOT_SECURITY_PATCH
4198BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4199 --prop com.android.build.init_boot.security_patch:$(INIT_BOOT_SECURITY_PATCH)
4200else ifdef BOOT_SECURITY_PATCH
Devin Moore380d9e42021-11-04 19:01:19 +00004201BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4202 --prop com.android.build.init_boot.security_patch:$(BOOT_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004203endif
4204
4205ifdef VENDOR_SECURITY_PATCH
4206BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4207 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
4208endif
4209
4210ifdef ODM_SECURITY_PATCH
4211BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4212 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
4213endif
4214
Yifan Hongcfb917a2020-05-07 14:58:20 -07004215ifdef VENDOR_DLKM_SECURITY_PATCH
4216BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4217 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
4218endif
4219
Yifan Hongf496f1b2020-07-15 16:52:59 -07004220ifdef ODM_DLKM_SECURITY_PATCH
4221BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4222 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
4223endif
4224
Ramji Jiyani13a41372022-01-27 07:05:08 +00004225ifdef SYSTEM_DLKM_SECURITY_PATCH
4226BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4227 --prop com.android.build.system_dlkm.security_patch:$(SYSTEM_DLKM_SECURITY_PATCH)
4228endif
4229
Andrew Scull9b103e42020-11-29 14:04:28 +00004230ifdef PVMFW_SECURITY_PATCH
4231BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4232 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
4233endif
4234
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004235BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Devin Moore380d9e42021-11-04 19:01:19 +00004236INIT_BOOT_FOOTER_ARGS := BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07004237VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Lucas Weif57333f2022-02-24 10:30:15 +08004238VENDOR_KERNEL_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004239DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00004240PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004241SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
4242VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05004243RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004244PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09004245SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004246ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07004247VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07004248ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Ramji Jiyani13a41372022-01-27 07:05:08 +00004249SYSTEM_DLKM_FOOTER_ARGS := BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004250
Tao Bao0da43472018-08-22 22:53:41 -07004251# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004252# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07004253define _check-and-set-avb-chain-args
4254$(eval part := $(1))
4255$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004256
4257$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
4258$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
4259$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
4260$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4261$(if $($(_key_path)),,$(error $(_key_path) is not defined))
4262$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
4263$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
4264$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4265
4266# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
4267$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
4268$(eval $(_signing_args) := \
4269 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
4270
cfig1aeef722019-09-20 22:45:06 +08004271# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
4272# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07004273$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08004274 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4275 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004276
Tao Bao744c4c72018-08-20 21:09:07 -07004277# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07004278# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07004279$(if $(filter $(part),$(part:vbmeta_%=%)),\
4280 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
4281 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004282endef
4283
Tao Bao0da43472018-08-22 22:53:41 -07004284# Checks and sets the required build variables for an AVB partition. The partition will be
4285# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07004286# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
4287# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004288# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
4289# but vbmeta would capture the image descriptor of only the first boot
4290# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07004291# $(1): Partition name, e.g. boot or system.
4292define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07004293$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07004294$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07004295 $(if $(_in_chained_vbmeta),\
4296 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07004297 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07004298 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004299 $(if $(filter boot,$(1)),\
4300 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4301 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
4302 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4303 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07004304endef
4305
Hongguang Chenf23364d2020-04-27 18:36:36 -07004306# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
4307# $(1): the custom partition to enable AVB chain.
4308define check-and-set-custom-avb-chain-args
4309$(eval part := $(1))
4310$(eval PART=$(call to-upper,$(part)))
4311$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4312$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4313
4314INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4315 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
4316endef
4317
Tao Baob1a2e352018-08-14 16:17:12 -07004318ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004319$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07004320endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004321
Devin Moore380d9e42021-11-04 19:01:19 +00004322ifdef INSTALLED_INIT_BOOT_IMAGE_TARGET
4323$(eval $(call check-and-set-avb-args,init_boot))
4324endif
4325
Steve Mucklee1b10862019-07-10 10:49:37 -07004326ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4327$(eval $(call check-and-set-avb-args,vendor_boot))
4328endif
4329
Lucas Weif57333f2022-02-24 10:30:15 +08004330ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
4331$(eval $(call check-and-set-avb-args,vendor_kernel_boot))
4332endif
4333
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004334ifdef INSTALLED_SYSTEMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004335$(eval $(call check-and-set-avb-args,system))
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004336endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004337
4338ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004339$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004340endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004341
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004342ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004343$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004344endif
4345
Justin Yun6151e3f2019-06-25 15:58:13 +09004346ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4347$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07004348endif
4349
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004350ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004351$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004352endif
4353
Yifan Hongcfb917a2020-05-07 14:58:20 -07004354ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
4355$(eval $(call check-and-set-avb-args,vendor_dlkm))
4356endif
4357
Yifan Hongf496f1b2020-07-15 16:52:59 -07004358ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
4359$(eval $(call check-and-set-avb-args,odm_dlkm))
4360endif
4361
Ramji Jiyani13a41372022-01-27 07:05:08 +00004362ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
4363$(eval $(call check-and-set-avb-args,system_dlkm))
4364endif
4365
Yueyao Zhu211c9012017-04-27 00:34:50 -07004366ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004367$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004368endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07004369
Andrew Scull9b103e42020-11-29 14:04:28 +00004370ifdef INSTALLED_PVMFWIMAGE_TARGET
4371$(eval $(call check-and-set-avb-args,pvmfw))
4372endif
4373
David Zeuthen8fecb282017-12-01 16:24:01 -05004374ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004375$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05004376endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08004377
David Anderson7709ab22018-10-15 14:41:34 -07004378# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
4379ifdef BOARD_AVB_VBMETA_SYSTEM
4380$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07004381endif
4382
4383ifdef BOARD_AVB_VBMETA_VENDOR
4384$(eval $(call check-and-set-avb-args,vbmeta_vendor))
4385endif
4386
Hongguang Chenf23364d2020-04-27 18:36:36 -07004387ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4388$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4389 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
4390endif
4391
Tao Bao0da43472018-08-22 22:53:41 -07004392BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07004393BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07004394BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
4395
4396ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07004397# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07004398BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07004399endif
Tao Bao0da43472018-08-22 22:53:41 -07004400
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004401ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004402BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004403endif
4404
David Anderson7709ab22018-10-15 14:41:34 -07004405ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
4406BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
4407 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07004408endif
4409
4410ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
4411BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
4412 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07004413endif
4414
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004415# $(1): the directory to extract public keys to
4416define extract-avb-chain-public-keys
4417 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
4418 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
4419 --output $(1)/boot.avbpubkey)
Devin Moore380d9e42021-11-04 19:01:19 +00004420 $(if $(BOARD_AVB_INIT_BOOT_KEY_PATH),\
4421 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_INIT_BOOT_KEY_PATH) \
4422 --output $(1)/init_boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07004423 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
4424 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
4425 --output $(1)/vendor_boot.avbpubkey)
Lucas Weif57333f2022-02-24 10:30:15 +08004426 $(if $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH),\
4427 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH) \
4428 --output $(1)/vendor_kernel_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004429 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
4430 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
4431 --output $(1)/system.avbpubkey)
4432 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
4433 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
4434 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004435 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
4436 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
4437 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09004438 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
4439 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
4440 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004441 $(if $(BOARD_AVB_ODM_KEY_PATH),\
4442 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
4443 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004444 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
4445 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
4446 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004447 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
4448 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
4449 --output $(1)/odm_dlkm.avbpubkey)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004450 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
4451 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH) \
4452 --output $(1)/system_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004453 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
4454 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
4455 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00004456 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
4457 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
4458 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05004459 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
4460 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
4461 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07004462 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
4463 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4464 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07004465 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
4466 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4467 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07004468 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
4469 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4470 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
4471 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004472endef
4473
Tao Bao744c4c72018-08-20 21:09:07 -07004474# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
4475# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07004476# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09004477# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
4478# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07004479# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004480# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07004481# $(2): Output filename.
4482define build-chained-vbmeta-image
4483 $(call pretty,"Target chained vbmeta image: $@")
4484 $(hide) $(AVBTOOL) make_vbmeta_image \
4485 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
4486 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
4487 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
4488 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
4489 --output $@
4490endef
4491
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004492ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07004493ifdef BOARD_AVB_VBMETA_SYSTEM
4494INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
4495$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004496 $(AVBTOOL) \
4497 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
4498 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07004499 $(call build-chained-vbmeta-image,vbmeta_system)
Bob Badourebdefc02022-02-12 15:39:22 -08004500
4501$(call declare-1p-container,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET),)
4502
4503SYSTEM_NOTICE_DEPS += $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004504endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004505endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07004506
4507ifdef BOARD_AVB_VBMETA_VENDOR
4508INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
4509$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004510 $(AVBTOOL) \
4511 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
4512 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07004513 $(call build-chained-vbmeta-image,vbmeta_vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08004514
4515$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
4516
Justin Yundd15ec12022-09-23 10:47:21 +09004517UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004518endif
4519
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004520define build-vbmetaimage-target
4521 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004522 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
4523 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004524 $(hide) $(AVBTOOL) make_vbmeta_image \
4525 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07004526 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004527 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
4528 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004529 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004530endef
4531
Paul Trautrim4e143232019-08-13 16:30:57 +09004532ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004533INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07004534$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4535 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
4536
David Zeuthen8fecb282017-12-01 16:24:01 -05004537$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004538 $(AVBTOOL) \
4539 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00004540 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004541 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Lucas Weif57333f2022-02-24 10:30:15 +08004542 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004543 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4544 $(INSTALLED_VENDORIMAGE_TARGET) \
4545 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004546 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004547 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004548 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004549 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004550 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004551 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004552 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004553 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004554 $(INSTALLED_RECOVERYIMAGE_TARGET) \
4555 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
4556 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
4557 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4558 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4559 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004560 $(build-vbmetaimage-target)
4561
Bob Badourebdefc02022-02-12 15:39:22 -08004562$(call declare-1p-container,$(INSTALLED_VBMETAIMAGE_TARGET),)
4563
4564UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETAIMAGE_TARGET)
4565
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004566.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08004567vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4568 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004569vbmetaimage-nodeps:
4570 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09004571endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004572
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004573endif # BOARD_AVB_ENABLE
4574
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004575# List of files from all images
4576INTERNAL_ALLIMAGES_FILES := \
4577 $(FULL_SYSTEMIMAGE_DEPS) \
4578 $(INTERNAL_RAMDISK_FILES) \
4579 $(INTERNAL_USERDATAIMAGE_FILES) \
4580 $(INTERNAL_VENDORIMAGE_FILES) \
4581 $(INTERNAL_PRODUCTIMAGE_FILES) \
4582 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4583 $(INTERNAL_ODMIMAGE_FILES) \
4584 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4585 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004586 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
Jiyong Parke219f002022-12-16 14:30:03 +09004587 $(INTERNAL_PVMFWIMAGE_FILES) \
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004588
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004589# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004590# Check VINTF of build
4591
Ramji Jiyani13a41372022-01-27 07:05:08 +00004592# Note: vendor_dlkm, odm_dlkm, and system_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004593ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07004594
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004595intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
4596check_vintf_all_deps :=
4597
Rob Seymour3f1c9572022-07-28 21:56:28 +00004598APEX_OUT := $(PRODUCT_OUT)/apex
4599# -----------------------------------------------------------------
4600# Create apex-info-file.xsd
4601
4602APEX_DIRS := \
4603 $(TARGET_OUT)/apex/% \
4604 $(TARGET_OUT_SYSTEM_EXT)/apex/% \
4605 $(TARGET_OUT_VENDOR)/apex/% \
4606 $(TARGET_OUT_ODM)/apex/% \
4607 $(TARGET_OUT_PRODUCT)/apex/% \
4608
4609apex_vintf_files := $(sort $(filter $(APEX_DIRS), $(INTERNAL_ALLIMAGES_FILES)))
4610APEX_INFO_FILE := $(APEX_OUT)/apex-info-list.xml
4611
4612$(APEX_INFO_FILE): $(HOST_OUT_EXECUTABLES)/dump_apex_info $(apex_vintf_files)
4613 @echo "Creating apex-info-file in $(PRODUCT_OUT) "
Jooyung Han8af44a92022-11-24 18:36:47 +09004614 $< --root_dir $(PRODUCT_OUT)
Rob Seymour3f1c9572022-07-28 21:56:28 +00004615
4616apex_vintf_files :=
4617
Yifan Hongaf9b0702020-01-21 12:46:57 -08004618# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
4619# because they are only used for prebuilt images.
4620check_vintf_common_srcs_patterns := \
4621 $(TARGET_OUT)/etc/vintf/% \
4622 $(TARGET_OUT_VENDOR)/etc/vintf/% \
4623 $(TARGET_OUT_ODM)/etc/vintf/% \
4624 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
4625 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
4626
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004627check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Rob Seymour3f1c9572022-07-28 21:56:28 +00004628check_vintf_common_srcs += $(APEX_INFO_FILE)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004629check_vintf_common_srcs_patterns :=
4630
4631check_vintf_has_system :=
4632check_vintf_has_vendor :=
4633
Yifan Hong28ffd732020-03-13 13:11:10 -07004634ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
4635$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
4636endif
4637ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
4638$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
4639endif
4640
Yifan Hong605ea042020-01-14 21:36:00 +00004641# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08004642check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
4643ifneq ($(check_vintf_system_deps),)
4644check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00004645
Yifan Hongfd150d32021-03-09 12:19:11 -08004646check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00004647check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004648$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00004649 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
Bob Badour5acd4362022-04-12 18:31:35 -07004650$(call declare-0p-target,$(check_vintf_system_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004651check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00004652
Devin Moore62d0a732022-10-13 16:50:50 +00004653# -- Check framework manifest against frozen manifests for GSI targets. They need to be compatible.
4654ifneq (true, $(BUILDING_VENDOR_IMAGE))
4655 vintffm_log := $(intermediates)/vintffm.log
4656endif
Yifan Hong7a157b02020-10-20 17:08:11 +00004657check_vintf_all_deps += $(vintffm_log)
4658$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
4659 @( $< --check --dirmap /system:$(TARGET_OUT) \
4660 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
4661
Bob Badour5acd4362022-04-12 18:31:35 -07004662$(call declare-0p-target,$(vintffm_log))
4663
Yifan Hongaf9b0702020-01-21 12:46:57 -08004664endif # check_vintf_system_deps
4665check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004666
4667# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004668check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
4669ifneq ($(check_vintf_vendor_deps),)
4670check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08004671check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00004672check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07004673# Check vendor SKU=(empty) case when:
4674# - DEVICE_MANIFEST_FILE is not empty; OR
4675# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004676$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004677 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4678 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004679 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004680$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07004681 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4682 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4683 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4684 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Bob Badour5acd4362022-04-12 18:31:35 -07004685$(call declare-0p-target,$(check_vintf_vendor_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004686check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08004687endif # check_vintf_vendor_deps
4688check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004689
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004690# -- Kernel version and configurations.
4691ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
4692
Yifan Hong605ea042020-01-14 21:36:00 +00004693BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
4694BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
4695
4696my_board_extracted_kernel :=
4697
4698# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
4699# from INSTALLED_KERNEL_TARGET.
4700ifdef BOARD_KERNEL_CONFIG_FILE
4701ifdef BOARD_KERNEL_VERSION
4702$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
4703 cp $< $@
4704$(BUILT_KERNEL_VERSION_FILE):
4705 echo $(BOARD_KERNEL_VERSION) > $@
4706
Bob Badour5acd4362022-04-12 18:31:35 -07004707$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4708$(call declare-0p-target,$(BUILT_KERNEL_VERSION_FILE))
4709
Yifan Hong605ea042020-01-14 21:36:00 +00004710my_board_extracted_kernel := true
4711endif # BOARD_KERNEL_VERSION
4712endif # BOARD_KERNEL_CONFIG_FILE
4713
4714ifneq ($(my_board_extracted_kernel),true)
Yifan Hong605ea042020-01-14 21:36:00 +00004715# Tools for decompression that is not in PATH.
4716# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
4717# Algorithms that are in the script but not in this list will be found in PATH.
4718my_decompress_tools := \
4719 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
4720
Yifan Hongb1627772021-07-14 15:01:50 -07004721endif # my_board_extracted_kernel
4722
4723ifneq ($(my_board_extracted_kernel),true)
4724ifdef INSTALLED_KERNEL_TARGET
Yifan Hong605ea042020-01-14 21:36:00 +00004725$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4726$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4727$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07004728$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
4729 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00004730 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08004731 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00004732
Bob Badour5acd4362022-04-12 18:31:35 -07004733$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4734
Yifan Hongb1627772021-07-14 15:01:50 -07004735my_board_extracted_kernel := true
Yifan Hong605ea042020-01-14 21:36:00 +00004736endif # INSTALLED_KERNEL_TARGET
Yifan Hongb1627772021-07-14 15:01:50 -07004737endif # my_board_extracted_kernel
4738
4739ifneq ($(my_board_extracted_kernel),true)
4740ifdef INSTALLED_BOOTIMAGE_TARGET
4741$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4742$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4743$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
4744$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
4745$(BUILT_KERNEL_CONFIGS_FILE): \
4746 $(HOST_OUT_EXECUTABLES)/unpack_bootimg \
4747 $(EXTRACT_KERNEL) \
4748 $(INSTALLED_BOOTIMAGE_TARGET)
4749 $(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
4750 $(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
4751 --output-configs $@ \
4752 --output-release $(BUILT_KERNEL_VERSION_FILE)
4753
Bob Badour5acd4362022-04-12 18:31:35 -07004754$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4755
Yifan Hongb1627772021-07-14 15:01:50 -07004756my_board_extracted_kernel := true
4757endif # INSTALLED_BOOTIMAGE_TARGET
4758endif # my_board_extracted_kernel
4759
4760ifneq ($(my_board_extracted_kernel),true)
4761$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
4762 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
4763 cannot be built into OTA update package. You can fix this by: \
4764 (1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
4765 so that kernel information will be extracted from the built kernel; or \
4766 (2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
4767 (3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
4768 BOARD_KERNEL_VERSION manually; or \
4769 (4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
4770# Clear their values to indicate that these two files does not exist.
4771BUILT_KERNEL_CONFIGS_FILE :=
4772BUILT_KERNEL_VERSION_FILE :=
4773endif
4774
4775my_decompress_tools :=
4776my_board_extracted_kernel :=
Yifan Hong605ea042020-01-14 21:36:00 +00004777
Yifan Hongc0f904e2021-03-17 11:25:31 -07004778endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4779
4780# -- Check VINTF compatibility of build.
4781# Skip partial builds; only check full builds. Only check if:
4782# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
4783# - system / vendor VINTF metadata exists
4784# - Building product / system_ext / odm images if board has product / system_ext / odm images
4785ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4786ifeq ($(check_vintf_has_system),true)
4787ifeq ($(check_vintf_has_vendor),true)
4788ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
4789ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
4790ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
4791
4792check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
4793check_vintf_all_deps += $(check_vintf_compatible_log)
4794
4795check_vintf_compatible_args :=
4796check_vintf_compatible_deps := $(check_vintf_common_srcs)
4797
4798ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004799ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004800check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004801check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004802endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004803endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4804
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004805check_vintf_compatible_args += \
4806 --dirmap /system:$(TARGET_OUT) \
4807 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4808 --dirmap /odm:$(TARGET_OUT_ODM) \
4809 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4810 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
Rob Seymour3f1c9572022-07-28 21:56:28 +00004811 --dirmap /apex:$(APEX_OUT) \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004812
4813ifdef PRODUCT_SHIPPING_API_LEVEL
4814check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4815endif # PRODUCT_SHIPPING_API_LEVEL
4816
4817$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4818$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004819# Check ODM SKU=(empty) case when:
4820# - ODM_MANIFEST_FILES is not empty; OR
4821# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004822$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004823 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
4824 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004825 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07004826# Check vendor SKU=(empty) case when:
4827# - DEVICE_MANIFEST_FILE is not empty; OR
4828# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004829$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004830 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4831 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004832 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004833$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08004834 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
4835 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004836 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
4837 @echo -n -e 'Args: \n ' >> $@
4838 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07004839 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4840 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004841 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004842 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
4843 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4844 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004845
Bob Badour5acd4362022-04-12 18:31:35 -07004846$(call declare-0p-target,$(check_vintf_compatible_log))
4847
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004848check_vintf_compatible_log :=
4849check_vintf_compatible_args :=
4850check_vintf_compatible_deps :=
4851
4852endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4853endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4854endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004855endif # check_vintf_has_vendor
4856endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004857endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4858
4859# Add all logs of VINTF checks to dist builds
4860droid_targets: $(check_vintf_all_deps)
4861$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4862
4863# Helper alias to check all VINTF of current build.
4864.PHONY: check-vintf-all
4865check-vintf-all: $(check_vintf_all_deps)
4866 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4867
Yifan Hongaf9b0702020-01-21 12:46:57 -08004868check_vintf_has_vendor :=
4869check_vintf_has_system :=
4870check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004871check_vintf_all_deps :=
4872intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004873endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004874
4875# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004876# Check image sizes <= size of super partition
4877
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004878ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004879
4880ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004881
Tianjie16bcac12021-05-13 15:44:43 -07004882PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
4883
4884# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
4885ifdef BUILDING_SYSTEM_OTHER_IMAGE
4886PARTITIONS_AND_OTHER_IN_SUPER += system_other
4887endif # BUILDING_SYSTEM_OTHER_IMAGE
4888
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004889# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004890# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004891define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004892 mkdir -p $(dir $(1))
4893 rm -f $(1)
4894 $(call dump-super-image-info, $(1))
Tianjie16bcac12021-05-13 15:44:43 -07004895 $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004896 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004897 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004898endef
4899
Yifan Hongd11953c2021-03-11 14:47:48 -08004900check_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 -07004901droid_targets: $(check_all_partition_sizes_log)
4902$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004903
Yifan Hong30910932019-10-25 20:36:55 -07004904$(check_all_partition_sizes_log): \
4905 $(CHECK_PARTITION_SIZES) \
Tianjie16bcac12021-05-13 15:44:43 -07004906 $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
Yifan Hong30910932019-10-25 20:36:55 -07004907 $(call check-all-partition-sizes-target, \
4908 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4909 $@)
4910
Bob Badour5acd4362022-04-12 18:31:35 -07004911$(call declare-0p-target,$(check_all_partition_sizes_log))
4912
Yifan Hong30910932019-10-25 20:36:55 -07004913.PHONY: check-all-partition-sizes
4914check-all-partition-sizes: $(check_all_partition_sizes_log)
4915
4916.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004917check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004918 $(call check-all-partition-sizes-target, \
4919 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004920
Yifan Hong2dae5722018-07-31 12:47:27 -07004921endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004922
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004923endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004924
4925# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004926# bring in the installer image generation defines if necessary
4927ifeq ($(TARGET_USE_DISKINSTALLER),true)
4928include bootable/diskinstaller/config.mk
4929endif
4930
4931# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004932# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004933
Ying Wangbd2d0242015-09-22 11:17:52 -07004934ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004935 build_ota_package := false
4936 build_otatools_package := false
4937else
Tao Bao9be20c72019-04-08 21:11:59 -07004938 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004939 build_ota_package := true
4940 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4941 build_ota_package := false
4942 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004943 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004944 build_ota_package := false
4945 endif
4946 ifeq ($(TARGET_PRODUCT),sdk)
4947 build_ota_package := false
4948 endif
Yifan Hongf32f65c2021-07-14 14:19:12 -07004949 # A target without a kernel may be one of the following:
Yifan Hong8c1e5262021-07-19 16:35:05 +00004950 # - A generic target. In this case, the OTA package usually isn't built.
4951 # PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
4952 # generation.
4953 # - A real device target, with TARGET_NO_KERNEL set to true and
4954 # BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
4955 # an OTA package.
Tao Bao9be20c72019-04-08 21:11:59 -07004956 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4957 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4958 build_ota_package := false
4959 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004960 ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4961 ifeq ($(TARGET_NO_KERNEL),true)
4962 build_ota_package := false
4963 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004964 endif # INSTALLED_BOOTIMAGE_TARGET == ""
Yifan Hongbf777872021-07-19 16:28:49 +00004965 ifeq ($(recovery_fstab),)
4966 build_ota_package := false
4967 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004968 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004969
Tao Bao9be20c72019-04-08 21:11:59 -07004970 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004971 build_otatools_package := true
4972 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4973 build_otatools_package := false
4974 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004975endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004976
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004977ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004978
4979INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004980 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004981 add_img_to_target_files \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004982 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004983 append2simg \
4984 avbtool \
4985 blk_alloc_to_base_fs \
4986 boot_signer \
4987 brillo_update_payload \
4988 brotli \
4989 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004990 build_image \
4991 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004992 build_verity_metadata \
4993 build_verity_tree \
4994 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004995 check_ota_package_signature \
4996 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004997 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004998 checkvintf \
4999 delta_generator \
5000 e2fsck \
5001 e2fsdroid \
5002 fc_sort \
5003 fec \
Woody Line4164192022-03-21 18:29:41 +08005004 fsck.erofs \
Jaegeuk Kim01da65f2021-06-08 18:24:46 -07005005 fsck.f2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07005006 fs_config \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08005007 generate_gki_certificate \
Tao Bao96daeeb2019-05-01 21:17:13 -07005008 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08005009 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07005010 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07005011 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005012 imgdiff \
5013 libconscrypt_openjdk_jni \
5014 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08005015 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07005016 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07005017 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07005018 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07005019 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005020 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08005021 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07005022 mkbootfs \
5023 mkbootimg \
5024 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08005025 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08005026 mkfs.erofs \
Cole Faustb0002082022-09-05 18:34:56 -07005027 mkf2fsuserimg \
Tao Bao96daeeb2019-05-01 21:17:13 -07005028 mksquashfs \
Cole Faustb0002082022-09-05 18:34:56 -07005029 mksquashfsimage \
Tao Bao96daeeb2019-05-01 21:17:13 -07005030 mkuserimg_mke2fs \
Kelvin Zhang83eb9f72022-03-15 11:12:50 -07005031 ota_extractor \
Tao Bao8821d642019-08-05 12:05:45 -07005032 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08005033 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08005034 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07005035 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08005036 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07005037 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07005038 sign_apex \
5039 sign_target_files_apks \
Jooyung Han8caba5e2021-10-27 03:58:09 +09005040 sign_virt_apex \
Tao Bao96daeeb2019-05-01 21:17:13 -07005041 signapk \
5042 simg2img \
5043 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07005044 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07005045 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08005046 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07005047 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07005048 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005049 verity_signer \
5050 verity_verifier \
5051 zipalign \
Kelvin Zhangb673bbf2021-08-20 10:09:20 -07005052 zucchini \
Tao Bao5e04c382017-02-22 16:38:19 -08005053
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005054# Additional tools to unpack and repack the apex file.
5055INTERNAL_OTATOOLS_MODULES += \
5056 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00005057 apex_compression_tool \
Dennis Shen888539c2022-11-07 18:53:10 +00005058 blkid \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005059 deapexer \
5060 debugfs_static \
Baligh Uddin67ab6892022-10-17 17:17:42 +00005061 dump_apex_info \
Dennis Shen888539c2022-11-07 18:53:10 +00005062 fsck.erofs \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005063 merge_zips \
5064 resize2fs \
5065 soong_zip \
5066
Anton Hansson8dab0a62019-03-28 15:45:40 +00005067ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005068INTERNAL_OTATOOLS_MODULES += \
5069 futility \
5070 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08005071endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08005072
Tao Bao96daeeb2019-05-01 21:17:13 -07005073INTERNAL_OTATOOLS_FILES := \
5074 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005075
Ying Wang06898662010-06-17 17:52:18 -07005076.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07005077otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07005078
Tao Bao96daeeb2019-05-01 21:17:13 -07005079# For each module, recursively resolve its host shared library dependencies. Then we have a full
5080# list of modules whose installed files need to be packed.
5081INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
5082 $(sort $(INTERNAL_OTATOOLS_MODULES) \
5083 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005084
Tao Bao96daeeb2019-05-01 21:17:13 -07005085INTERNAL_OTATOOLS_PACKAGE_FILES := \
5086 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
5087
5088INTERNAL_OTATOOLS_PACKAGE_FILES += \
5089 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
hungweichenf1f5dd32022-08-17 08:01:50 +00005090 -name "*.pk8"))
Tao Bao93ab8442018-10-12 11:03:04 -07005091
Hongguang07babe02022-10-31 17:21:22 -07005092ifneq (,$(wildcard packages/modules))
Hongguang547812d2022-10-31 10:20:14 -07005093INTERNAL_OTATOOLS_PACKAGE_FILES += \
5094 $(sort $(shell find packages/modules -type f -name "*.x509.pem" -o -name "*.pk8" -o -name \
5095 "key.pem"))
Hongguang07babe02022-10-31 17:21:22 -07005096endif
Hongguang547812d2022-10-31 10:20:14 -07005097
Tao Bao93ab8442018-10-12 11:03:04 -07005098ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07005099INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07005100 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07005101 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07005102endif
5103ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07005104INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07005105 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
5106 -name "atx_metadata.bin"))
5107endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005108ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005109INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00005110 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07005111endif
5112
Tao Bao96daeeb2019-05-01 21:17:13 -07005113INTERNAL_OTATOOLS_RELEASETOOLS := \
Kelvin Zhanged714e02022-09-22 12:42:24 -07005114 $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
5115 \( -type f -o -type l \) -print | sort)
Tao Bao96daeeb2019-05-01 21:17:13 -07005116
5117BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
5118$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
5119$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
5120$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
5121$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07005122$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005123 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07005124 rm -rf $@ $(PRIVATE_ZIP_ROOT)
5125 mkdir -p $(dir $@)
5126 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
5127 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08005128 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07005129 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005130
Bob Badour5acd4362022-04-12 18:31:35 -07005131$(call declare-1p-container,$(BUILT_OTATOOLS_PACKAGE),build)
5132$(call declare-container-license-deps,$(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS),$(BUILT_OTATOOLS_PACKAGE):)
5133
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005134.PHONY: otatools-package
5135otatools-package: $(BUILT_OTATOOLS_PACKAGE)
5136
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005137endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005138
The Android Open Source Project88b60792009-03-03 19:28:42 -08005139# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07005140# misc_info.txt
5141
5142INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
5143
5144ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
5145# default to common dir for device vendor
5146tool_extensions := $(TARGET_DEVICE_DIR)/../common
5147else
5148tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
5149endif
5150.KATI_READONLY := tool_extensions
5151
Steve Muckle903a1ca2020-05-07 17:32:10 -07005152# $1: boot image file name
5153define misc_boot_size
5154$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
5155endef
5156
Daniel Normane1e48082019-06-27 13:55:23 -07005157$(INSTALLED_MISC_INFO_TARGET):
5158 rm -f $@
5159 $(call pretty,"Target misc_info.txt: $@")
5160 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
5161 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
5162ifdef BOARD_FLASH_BLOCK_SIZE
5163 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
5164endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07005165ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
5166 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
5167 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07005168endif
5169ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
5170 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07005171else
5172 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005173endif
Devin Moore380d9e42021-11-04 19:01:19 +00005174ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
5175 $(hide) echo "init_boot=true" >> $@
5176 $(hide) echo "init_boot_size=$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)" >> $@
5177endif
J. Avila98cd4cc2020-06-10 20:09:10 +00005178ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
5179 echo "lz4_ramdisks=true" >> $@
5180endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005181ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5182 echo "vendor_boot=true" >> $@
5183 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
5184endif
Lucas Weif57333f2022-02-24 10:30:15 +08005185ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
5186 echo "vendor_kernel_boot=true" >> $@
5187 echo "vendor_kernel_boot_size=$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)" >> $@
5188endif
Daniel Normane1e48082019-06-27 13:55:23 -07005189ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5190 $(hide) echo "no_recovery=true" >> $@
5191endif
5192ifdef BOARD_INCLUDE_RECOVERY_DTBO
5193 $(hide) echo "include_recovery_dtbo=true" >> $@
5194endif
5195ifdef BOARD_INCLUDE_RECOVERY_ACPIO
5196 $(hide) echo "include_recovery_acpio=true" >> $@
5197endif
5198ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
5199 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
5200endif
5201ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
5202 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
5203 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5204else
5205 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5206endif
5207 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
5208 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
Jacky Liubeb0b692021-12-29 16:29:05 +08005209ifdef PRODUCT_EXTRA_OTA_KEYS
5210 $(hide) echo "extra_ota_keys=$(PRODUCT_EXTRA_OTA_KEYS)" >> $@
5211endif
Daniel Normane1e48082019-06-27 13:55:23 -07005212ifdef PRODUCT_EXTRA_RECOVERY_KEYS
5213 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
5214endif
5215 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07005216 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005217 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Devin Moore380d9e42021-11-04 19:01:19 +00005218 $(hide) echo 'mkbootimg_init_args=$(BOARD_MKBOOTIMG_INIT_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005219ifdef BOARD_GKI_SIGNING_KEY_PATH
5220 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
5221 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005222 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
5223endif
Daniel Normane1e48082019-06-27 13:55:23 -07005224 $(hide) echo "multistage_support=1" >> $@
5225 $(hide) echo "blockimgdiff_versions=3,4" >> $@
5226ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
5227 $(hide) echo "build_generic_ota_package=true" >> $@
5228endif
5229ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
5230 # OTA scripts are only interested in fingerprint related properties
5231 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
5232endif
5233ifneq (,$(filter address, $(SANITIZE_TARGET)))
5234 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
5235 $(hide) echo "userdata_img_with_data=true" >> $@
5236endif
5237ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
5238 $(hide) echo "full_recovery_image=true" >> $@
5239endif
Bill Peckhame868aec2019-09-17 17:06:47 -07005240ifdef BOARD_USES_VENDORIMAGE
5241 $(hide) echo "board_uses_vendorimage=true" >> $@
5242endif
Daniel Normane1e48082019-06-27 13:55:23 -07005243ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08005244ifeq ($(BUILDING_VBMETA_IMAGE),true)
5245 $(hide) echo "avb_building_vbmeta_image=true" >> $@
5246endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005247 $(hide) echo "avb_enable=true" >> $@
5248 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
5249 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
5250 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
5251 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5252ifdef BOARD_AVB_BOOT_KEY_PATH
5253 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
5254 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
5255 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5256endif # BOARD_AVB_BOOT_KEY_PATH
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08005257 $(hide) echo "avb_init_boot_add_hash_footer_args=$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5258ifdef BOARD_AVB_INIT_BOOT_KEY_PATH
5259 $(hide) echo "avb_init_boot_key_path=$(BOARD_AVB_INIT_BOOT_KEY_PATH)" >> $@
5260 $(hide) echo "avb_init_boot_algorithm=$(BOARD_AVB_INIT_BOOT_ALGORITHM)" >> $@
5261 $(hide) echo "avb_init_boot_rollback_index_location=$(BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5262endif # BOARD_AVB_INIT_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07005263 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5264ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
5265 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
5266 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
5267 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5268endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Lucas Weif57333f2022-02-24 10:30:15 +08005269 echo "avb_vendor_kernel_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5270ifdef BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
5271 echo "avb_vendor_kernel_boot_key_path=$(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH)" >> $@
5272 echo "avb_vendor_kernel_boot_algorithm=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ALGORITHM)" >> $@
5273 echo "avb_vendor_kernel_boot_rollback_index_location=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5274endif # BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07005275 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
5276ifdef BOARD_AVB_RECOVERY_KEY_PATH
5277 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
5278 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
5279 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
5280endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07005281ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
5282 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
5283 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5284 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
5285 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
5286 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
5287 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
5288 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
5289 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
5290endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07005291ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
5292 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
5293 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
5294 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
5295 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
5296 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
5297endif # BOARD_AVB_VBMETA_SYSTEM
5298ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
5299 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
Bowgo Tsaic85a2012022-06-07 11:36:35 +08005300 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS)" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005301 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
5302 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
5303 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
5304endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
5305endif # BOARD_AVB_ENABLE
5306ifdef BOARD_BPT_INPUT_FILES
5307 $(hide) echo "board_bpt_enable=true" >> $@
5308 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
5309 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
5310endif
5311ifdef BOARD_BPT_DISK_SIZE
5312 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
5313endif
5314 $(call generate-userimage-prop-dictionary, $@)
5315ifeq ($(AB_OTA_UPDATER),true)
5316 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
5317 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
5318 $(hide) echo "ab_update=true" >> $@
5319endif
Yifan Hong65afc072020-04-17 10:08:10 -07005320ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
5321 $(hide) echo "allow_non_ab=true" >> $@
5322endif
Daniel Normane1e48082019-06-27 13:55:23 -07005323ifdef BOARD_PREBUILT_DTBOIMAGE
5324 $(hide) echo "has_dtbo=true" >> $@
5325ifeq ($(BOARD_AVB_ENABLE),true)
5326 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
5327 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
5328ifdef BOARD_AVB_DTBO_KEY_PATH
5329 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
5330 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
5331 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
5332endif # BOARD_AVB_DTBO_KEY_PATH
5333endif # BOARD_AVB_ENABLE
5334endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005335ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005336 $(hide) echo "has_pvmfw=true" >> $@
5337ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi592a3ca2021-10-04 11:34:11 +02005338 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@
Andrew Scull9b103e42020-11-29 14:04:28 +00005339 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
5340ifdef BOARD_AVB_PVMFW_KEY_PATH
5341 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
5342 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
5343 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
5344endif # BOARD_AVB_PVMFW_KEY_PATH
5345endif # BOARD_AVB_ENABLE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005346endif # BOARD_USES_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005347 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07005348 @# VINTF checks
5349ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
5350 $(hide) echo "vintf_enforce=true" >> $@
5351endif
5352ifdef ODM_MANIFEST_SKUS
5353 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
5354endif
Yifan Hong28ffd732020-03-13 13:11:10 -07005355ifdef ODM_MANIFEST_FILES
5356 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
5357endif
5358ifdef DEVICE_MANIFEST_SKUS
5359 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
5360endif
5361ifdef DEVICE_MANIFEST_FILE
5362 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
5363endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005364ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
5365 $(hide) echo "bootloader_in_update_package=true" >> $@
5366endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07005367ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
5368 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
5369endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05005370ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5371 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
5372endif
Jose Galmes9c8f6eb2021-07-21 09:34:08 -07005373ifeq ($(BUILDING_WITH_VSDK),true)
5374 $(hide) echo "building_with_vsdk=true" >> $@
5375endif
5376ifeq ($(TARGET_FLATTEN_APEX),false)
5377 $(hide) echo "target_flatten_apex=false" >> $@
5378endif
Daniel Normane1e48082019-06-27 13:55:23 -07005379
Bob Badourebdefc02022-02-12 15:39:22 -08005380$(call declare-0p-target,$(INSTALLED_MISC_INFO_TARGET))
5381
Daniel Normane1e48082019-06-27 13:55:23 -07005382.PHONY: misc_info
5383misc_info: $(INSTALLED_MISC_INFO_TARGET)
5384
Bill Peckham315b98a2021-06-15 19:35:06 -07005385droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
Daniel Normane1e48082019-06-27 13:55:23 -07005386
5387# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005388# A zip of the directories that map to the target filesystem.
5389# This zip can be used to create an OTA package or filesystem image
5390# as a post-build step.
5391#
5392name := $(TARGET_PRODUCT)
5393ifeq ($(TARGET_BUILD_TYPE),debug)
5394 name := $(name)_debug
5395endif
5396name := $(name)-target_files-$(FILE_NAME_TAG)
5397
5398intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
5399BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
5400$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
5401$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005402 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005403
5404# $(1): Directory to copy
5405# $(2): Location to copy it to
5406# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
5407define package_files-copy-root
5408 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
5409 mkdir -p $(2) && \
5410 $(ACP) -rd $(strip $(1))/* $(2); \
5411 fi
5412endef
5413
Tao Baoa04fca32015-11-30 12:22:24 -08005414built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07005415
5416# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08005417ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07005418built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07005419 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07005420endif
5421
The Android Open Source Project88b60792009-03-03 19:28:42 -08005422$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
5423
Dan Willemsen653bea92017-03-21 15:47:37 -07005424tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07005425$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07005426
HÃ¥kan Kvist8cabc712022-05-02 07:43:34 +02005427updater_dep :=
Sen Jiang4438fd92016-03-07 16:51:01 -08005428ifeq ($(AB_OTA_UPDATER),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005429updater_dep += system/update_engine/update_engine.conf
Bob Badour5acd4362022-04-12 18:31:35 -07005430$(call declare-1p-target,system/update_engine/update_engine.conf,system/update_engine)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005431updater_dep += external/zucchini/version_info.h
Bob Badour5acd4362022-04-12 18:31:35 -07005432$(call declare-license-metadata,external/zucchini/version_info.h,legacy_notice,notice,external/zucchini/LICENSE,external/zucchini)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005433updater_dep += $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so
Yifan Hong65afc072020-04-17 10:08:10 -07005434endif
5435
5436# Build OTA tools if non-A/B is allowed
5437ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005438updater_dep += $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07005439endif
Yifan Hong65afc072020-04-17 10:08:10 -07005440
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09005441$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07005442
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005443# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07005444# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005445ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5446$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07005447else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
5448$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005449else
5450$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
5451endif
5452
Dan Willemsen653bea92017-03-21 15:47:37 -07005453ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07005454 ifdef OSRELEASED_DIRECTORY
5455 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
5456 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
5457 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
5458 endif
Tao Baoa835f382019-07-18 15:55:30 -07005459
5460 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
5461 # additionally include radio or bootloader partitions).
5462 ifeq ($(AB_OTA_PARTITIONS),)
5463 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
5464 endif
5465endif
5466
5467ifneq ($(AB_OTA_PARTITIONS),)
5468 ifneq ($(AB_OTA_UPDATER),true)
5469 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
5470 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07005471endif
5472
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005473# Run fs_config while creating the target files package
5474# $1: root directory
5475# $2: add prefix
5476define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08005477(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 -08005478endef
5479
Yifan Hong60bfcc42019-11-01 11:39:45 -07005480define filter-out-missing-vendor
5481$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
5482endef
Petri Gynther09865a42021-03-10 18:23:39 -08005483define filter-out-missing-vendor_dlkm
5484$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
5485endef
5486define filter-out-missing-odm
5487$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
5488endef
5489define filter-out-missing-odm_dlkm
5490$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
5491endef
Ramji Jiyani13a41372022-01-27 07:05:08 +00005492define filter-out-missing-system_dlkm
5493$(if $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(1),$(filter-out system_dlkm,$(1)))
5494endef
5495# Filter out vendor,vendor_dlkm,odm,odm_dlkm,system_dlkm from the list for AOSP targets.
Petri Gynther09865a42021-03-10 18:23:39 -08005496# $(1): list
5497define filter-out-missing-partitions
5498$(call filter-out-missing-vendor,\
5499 $(call filter-out-missing-vendor_dlkm,\
5500 $(call filter-out-missing-odm,\
Ramji Jiyani13a41372022-01-27 07:05:08 +00005501 $(call filter-out-missing-odm_dlkm,\
5502 $(call filter-out-missing-system_dlkm,$(1))))))
Petri Gynther09865a42021-03-10 18:23:39 -08005503endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07005504
5505# Information related to dynamic partitions and virtual A/B. This information
5506# is needed for building the super image (see dump-super-image-info) and
5507# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08005508# $(1): file
5509define dump-dynamic-partitions-info
5510 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
5511 echo "use_dynamic_partitions=true" >> $(1))
5512 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
5513 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08005514 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
5515 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
5516 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00005517 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
5518 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08005519 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
5520 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005521 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
5522 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5523 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
5524 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5525 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
5526 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005527 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005528 $(if $(BOARD_SUPER_PARTITION_GROUPS),
5529 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
5530 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
5531 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
5532 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005533 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 -07005534 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
5535 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07005536 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
5537 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005538 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
5539 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005540 $(if $(BOARD_SUPER_PARTITION_SIZE), \
5541 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
5542 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
5543 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
5544 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
5545 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
5546 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
5547 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005548 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
5549 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05005550 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
5551 echo "virtual_ab_compression=true" >> $(1))
Kelvin Zhangfa91e982022-02-09 11:19:16 -08005552# This value controls the compression algorithm used for VABC
5553# valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
5554# e.g. "none", "gz", "brotli"
5555 $(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD), \
5556 echo "virtual_ab_compression_method=$(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005557 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
5558 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005559endef
5560
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005561# By conditionally including the dependency of the target files package on the
5562# full system image deps, we speed up builds that do not build the system
5563# image.
5564ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005565 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005566else
5567 # releasetools may need the system build.prop even when building a
5568 # system-image-less product.
5569 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BUILD_PROP_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005570endif
5571
5572ifdef BUILDING_USERDATA_IMAGE
5573 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
5574endif
5575
5576ifdef BUILDING_SYSTEM_OTHER_IMAGE
5577 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
5578endif
5579
5580ifdef BUILDING_VENDOR_BOOT_IMAGE
5581 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005582 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Devin Moore55af5062021-06-09 10:44:44 -07005583 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Colin Crosse6431202021-02-24 11:44:55 -08005584 # The vendor ramdisk may be built from the recovery ramdisk.
5585 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
5586 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
5587 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07005588endif
5589
5590ifdef BUILDING_RECOVERY_IMAGE
5591 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08005592 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07005593 # commands in build-recoveryimage-target, which would touch the files under
5594 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
5595 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5596 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5597 else
5598 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
5599 endif
5600 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
5601endif
5602
5603# Conditionally depend on the image files if the image is being built so the
5604# target-files.zip rule doesn't wait on the image creation rule, or the image
5605# if it is coming from a prebuilt.
5606
5607ifdef BUILDING_VENDOR_IMAGE
5608 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
5609else ifdef BOARD_PREBUILT_VENDORIMAGE
5610 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
5611endif
5612
5613ifdef BUILDING_PRODUCT_IMAGE
5614 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
5615else ifdef BOARD_PREBUILT_PRODUCTIMAGE
5616 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
5617endif
5618
5619ifdef BUILDING_SYSTEM_EXT_IMAGE
5620 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
5621else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
5622 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
5623endif
5624
Devin Moore380d9e42021-11-04 19:01:19 +00005625ifneq (,$(BUILDING_BOOT_IMAGE)$(BUILDING_INIT_BOOT_IMAGE))
Colin Cross43f2eb22020-08-26 18:41:29 -07005626 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Devin Moore380d9e42021-11-04 19:01:19 +00005627endif # BUILDING_BOOT_IMAGE != "" || BUILDING_INIT_BOOT_IMAGE != ""
5628
Yifan Hong49968aa2020-11-09 11:52:52 -08005629ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07005630 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5631endif
5632
5633ifdef BUILDING_ODM_IMAGE
5634 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
5635else ifdef BOARD_PREBUILT_ODMIMAGE
5636 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
5637endif
5638
5639ifdef BUILDING_VENDOR_DLKM_IMAGE
5640 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005641else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005642 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
5643endif
5644
5645ifdef BUILDING_ODM_DLKM_IMAGE
5646 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005647else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005648 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005649endif
5650
Ramji Jiyani13a41372022-01-27 07:05:08 +00005651ifdef BUILDING_SYSTEM_DLKM_IMAGE
5652 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
5653else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5654 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
5655endif
5656
Isaac Chen9e09d472019-07-05 17:30:41 +08005657ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07005658 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
5659 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08005660endif
5661
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005662ifdef BOARD_PREBUILT_BOOTLOADER
5663$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005664droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005665endif
5666
The Android Open Source Project88b60792009-03-03 19:28:42 -08005667# Depending on the various images guarantees that the underlying
5668# directories are up-to-date.
5669$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005670 $(INSTALLED_RADIOIMAGE_TARGET) \
5671 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005672 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005673 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00005674 $(INSTALLED_PVMFWIMAGE_TARGET) \
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01005675 $(INSTALLED_PVMFW_BINARY_TARGET) \
Andrew Scullbbc930b2022-02-17 22:34:27 +00005676 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07005677 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005678 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
5679 $(INSTALLED_KERNEL_TARGET) \
Enrico Granatab582e0f2020-10-14 15:17:20 -06005680 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005681 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005682 $(INSTALLED_2NDBOOTLOADER_TARGET) \
5683 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08005684 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005685 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005686 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5687 $(PRODUCT_VENDOR_BASE_FS_PATH) \
5688 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09005689 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005690 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07005691 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07005692 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00005693 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00005694 $(LPMAKE) \
5695 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07005696 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005697 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005698 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005699 $(SOONG_ZIP) \
5700 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07005701 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07005702 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005703 $(BUILT_KERNEL_CONFIGS_FILE) \
5704 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005705 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005706 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005707 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005708 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07005709ifneq (,$(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 -08005710 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005711 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005712# Exclude recovery files in the default vendor ramdisk if including a standalone
5713# recovery ramdisk in vendor_boot.
5714ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005715 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005716 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005717endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005718ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005719ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07005720 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07005721else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07005722 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
5723endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005724endif
Yifan Hong78860162020-10-28 14:15:21 -07005725ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005726ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005727 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005728endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005729ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08005730ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07005731 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08005732else
Steve Mucklee1b10862019-07-10 10:49:37 -07005733 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005734endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005735endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005736ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07005737 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005738endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005739ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005740 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005741endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005742ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07005743ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07005744 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07005745endif # INTERNAL_KERNEL_CMDLINE != ""
5746endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07005747ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005748 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005749endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005750ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005751 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005752endif
Yifan Hong3941a872020-10-28 16:33:06 -07005753endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005754endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08005755 @# Components of the boot image
5756 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07005757 $(hide) mkdir -p $(zip_root)/ROOT
5758 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005759 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08005760 @# If we are using recovery as boot, this is already done when processing recovery.
5761ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005762 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005763 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005764ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005765 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08005766endif
Yifan Hong46aff092020-10-28 13:50:47 -07005767ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07005768 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07005769else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07005770 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08005771ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005772 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005773endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005774ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005775 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005776endif
Doug Zongker38a649f2009-06-17 09:07:09 -07005777ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005778 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005779endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005780ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005781 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005782endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005783endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07005784endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07005785 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
5786 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07005787 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07005788ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5789 mkdir -p $(zip_root)/VENDOR_BOOT
5790 $(call package_files-copy-root, \
5791 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
5792ifdef INSTALLED_DTBIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005793ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
Steve Mucklee1b10862019-07-10 10:49:37 -07005794 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
5795endif
Lucas Weif57333f2022-02-24 10:30:15 +08005796endif # end of INSTALLED_DTBIMAGE_TARGET
Devin Moore50509012021-01-13 10:45:04 -08005797ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
5798 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
5799endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005800ifdef BOARD_KERNEL_BASE
5801 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
5802endif
5803ifdef BOARD_KERNEL_PAGESIZE
5804 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
5805endif
5806 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005807ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
5808 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
5809 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005810 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
5811 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
5812 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
5813 $(if $(prebuilt_ramdisk), \
5814 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
5815 $(call package_files-copy-root, \
5816 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
5817 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
5818 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005819endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07005820endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005821ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
5822 mkdir -p $(zip_root)/VENDOR_KERNEL_BOOT
5823 $(call package_files-copy-root, \
5824 $(TARGET_VENDOR_KERNEL_RAMDISK_OUT),$(zip_root)/VENDOR_KERNEL_BOOT/RAMDISK)
5825ifdef INSTALLED_DTBIMAGE_TARGET
5826 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_KERNEL_BOOT/dtb
5827endif
5828ifdef BOARD_KERNEL_PAGESIZE
5829 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_KERNEL_BOOT/pagesize
5830endif
5831endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08005832ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005833 @# Contents of the system image
5834 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005835 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005836else ifdef INSTALLED_BUILD_PROP_TARGET
5837 @# Copy the system build.prop even if not building a system image
5838 @# because add_img_to_target_files may need it to build other partition
5839 @# images.
5840 $(hide) mkdir -p "$(zip_root)/SYSTEM"
5841 $(hide) cp "$(INSTALLED_BUILD_PROP_TARGET)" "$(patsubst $(TARGET_OUT)/%,$(zip_root)/SYSTEM/%,$(INSTALLED_BUILD_PROP_TARGET))"
Dan Willemsen67495202019-01-16 12:42:05 -08005842endif
5843ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005844 @# Contents of the data image
5845 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005846 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08005847endif
5848ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07005849 @# Contents of the vendor image
5850 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005851 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07005852endif
Dan Willemsen67495202019-01-16 12:42:05 -08005853ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005854 @# Contents of the product image
5855 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005856 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005857endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005858ifdef BUILDING_SYSTEM_EXT_IMAGE
5859 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01005860 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09005861 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01005862endif
Dan Willemsen67495202019-01-16 12:42:05 -08005863ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005864 @# Contents of the odm image
5865 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005866 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005867endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005868ifdef BUILDING_VENDOR_DLKM_IMAGE
5869 @# Contents of the vendor_dlkm image
5870 $(hide) $(call package_files-copy-root, \
5871 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
5872endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005873ifdef BUILDING_ODM_DLKM_IMAGE
5874 @# Contents of the odm_dlkm image
5875 $(hide) $(call package_files-copy-root, \
5876 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
5877endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005878ifdef BUILDING_SYSTEM_DLKM_IMAGE
5879 @# Contents of the system_dlkm image
5880 $(hide) $(call package_files-copy-root, \
5881 $(TARGET_OUT_SYSTEM_DLKM),$(zip_root)/SYSTEM_DLKM)
5882endif
Dan Willemsen67495202019-01-16 12:42:05 -08005883ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07005884 @# Contents of the system_other image
5885 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005886 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07005887endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005888 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07005889 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07005890 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granatab582e0f2020-10-14 15:17:20 -06005891ifdef BUILDING_RAMDISK_IMAGE
5892ifeq (true,$(BOARD_IMG_USE_RAMDISK))
5893 @# Contents of the ramdisk image
5894 $(hide) mkdir -p $(zip_root)/IMAGES
5895 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
5896endif
5897endif
Yifan Hong65afc072020-04-17 10:08:10 -07005898ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08005899ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07005900 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07005901 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07005902endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08005903endif
Doug Zongker8678df42009-06-15 14:30:14 -07005904 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08005905 @# build them.
5906 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07005907 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005908 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005909ifneq ($(tool_extension),)
5910 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
5911endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07005912 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005913 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07005914 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00005915ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
5916 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5917 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005918endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005919ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
5920 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
5921 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005922endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005923ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
5924 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
5925 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005926endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005927ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
5928 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
5929 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01005930endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005931ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
5932 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
5933 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005934endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005935ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
5936 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
5937 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
5938endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005939ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
5940 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
5941 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
5942endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005943ifneq ($(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH),)
5944 $(hide) cp $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
5945 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH))
5946endif
Yifan Hong65afc072020-04-17 10:08:10 -07005947ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07005948ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07005949 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07005950 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07005951endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08005952endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005953ifeq ($(AB_OTA_UPDATER),true)
5954 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07005955 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Kelvin Zhangc06f0622021-11-30 12:38:39 -08005956 $(hide) cp $(TOPDIR)external/zucchini/version_info.h $(zip_root)/META/zucchini_config.txt
Kelvin Zhang6877e812022-01-06 11:12:04 -08005957 $(hide) cp $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so $(zip_root)/META/liblz4.so
Cole Faust90099992022-02-17 11:35:27 -08005958 $(hide) for part in $(sort $(AB_OTA_PARTITIONS)); do \
Alex Deymo8925d332015-10-01 17:38:09 -07005959 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
5960 done
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005961 $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
Sen Jiang8f22e2a2015-11-12 13:53:25 -08005962 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
5963 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005964ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07005965 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
5966 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
5967 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005968endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005969endif
Steve Fungdfbab492015-09-24 18:12:33 -07005970ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07005971 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07005972 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07005973endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07005974ifdef BOARD_PREBUILT_VENDORIMAGE
5975 $(hide) mkdir -p $(zip_root)/IMAGES
5976 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
5977endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005978ifdef BOARD_PREBUILT_PRODUCTIMAGE
5979 $(hide) mkdir -p $(zip_root)/IMAGES
5980 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
5981endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005982ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01005983 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09005984 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01005985endif
Devin Moore380d9e42021-11-04 19:01:19 +00005986ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
Devin Moorecda41f02022-01-05 00:08:39 +00005987 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5988 $(hide) cp $(INSTALLED_INIT_BOOT_IMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Devin Moore380d9e42021-11-04 19:01:19 +00005989endif
Ramji Jiyani034e7772022-01-24 04:00:29 +00005990
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005991ifndef BOARD_PREBUILT_BOOTIMAGE
Yi-Yo Chiang81939002022-01-08 23:46:40 +08005992ifneq (,$(strip $(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES))))
Yifan Hong49968aa2020-11-09 11:52:52 -08005993ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07005994 $(hide) mkdir -p $(zip_root)/IMAGES
5995 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08005996endif # INSTALLED_BOOTIMAGE_TARGET
5997endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005998else # BOARD_PREBUILT_BOOTIMAGE is defined
5999 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6000 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
6001endif # BOARD_PREBUILT_BOOTIMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006002ifdef BOARD_PREBUILT_ODMIMAGE
6003 $(hide) mkdir -p $(zip_root)/IMAGES
6004 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
6005endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07006006ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07006007 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07006008 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
6009endif
6010ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
6011 $(hide) mkdir -p $(zip_root)/IMAGES
6012 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07006013endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006014ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
6015 $(hide) mkdir -p $(zip_root)/IMAGES
6016 $(hide) cp $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
6017endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07006018ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07006019 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6020 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08006021endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01006022ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00006023 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6024 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Andrew Scullbbc930b2022-02-17 22:34:27 +00006025 $(hide) cp $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) $(zip_root)/PREBUILT_IMAGES/
Pierre-Clément Tosi03975ed2022-10-02 12:11:06 +01006026 $(hide) mkdir -p $(zip_root)/PVMFW
6027 $(hide) cp $(INSTALLED_PVMFW_BINARY_TARGET) $(zip_root)/PVMFW/
Pierre-Clément Tosid8248af2021-10-07 12:18:17 +02006028endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00006029ifdef BOARD_PREBUILT_BOOTLOADER
6030 $(hide) mkdir -p $(zip_root)/IMAGES
6031 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
6032endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07006033ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
6034 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
6035 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
6036 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
6037endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07006038 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
6039 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
6040 @# INSTALLED_RADIOIMAGE_TARGET.
6041 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
6042 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006043 @# Run fs_config on all the system, vendor, boot ramdisk,
6044 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08006045ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006046 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08006047endif
6048ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006049 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
6050endif
Dan Willemsen67495202019-01-16 12:42:05 -08006051ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006052 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
6053endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006054ifdef BUILDING_SYSTEM_EXT_IMAGE
6055 $(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 +01006056endif
Dan Willemsen67495202019-01-16 12:42:05 -08006057ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006058 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
6059endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006060ifdef BUILDING_VENDOR_DLKM_IMAGE
6061 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
6062endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07006063ifdef BUILDING_ODM_DLKM_IMAGE
6064 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
6065endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006066ifdef BUILDING_SYSTEM_DLKM_IMAGE
6067 $(hide) $(call fs_config,$(zip_root)/SYSTEM_DLKM,system_dlkm/) > $(zip_root)/META/system_dlkm_filesystem_config.txt
6068endif
Tom Cherryd14b8952018-08-09 14:26:00 -07006069 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006070 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08006071 @# BOOT/RAMDISK contains the first stage and recovery ramdisk.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006072 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Devin Moore380d9e42021-11-04 19:01:19 +00006073ifdef BUILDING_INIT_BOOT_IMAGE
6074 $(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK)
6075 $(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt
6076ifdef BOARD_KERNEL_PAGESIZE
6077 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize
6078endif # BOARD_KERNEL_PAGESIZE
6079endif # BUILDING_INIT_BOOT_IMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07006080ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
6081 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
6082endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006083ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
6084 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
6085endif
Dan Willemsen67495202019-01-16 12:42:05 -08006086ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006087 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
6088endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07006089 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07006090ifdef BUILT_KERNEL_CONFIGS_FILE
6091 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
6092endif
6093ifdef BUILT_KERNEL_VERSION_FILE
6094 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
6095endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07006096 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
6097ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6098 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
6099endif
Tao Baocbd6d492019-10-07 22:46:02 -07006100 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
6101 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08006102ifeq ($(BUILD_QEMU_IMAGES),true)
6103 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
6104 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
6105endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08006106 @# Zip everything up, preserving symlinks and placing META/ files first to
6107 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006108 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07006109 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08006110 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07006111
Ying Wanga0febe52013-03-20 11:02:05 -07006112.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08006113target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
6114
Bob Badour5acd4362022-04-12 18:31:35 -07006115$(call declare-1p-container,$(BUILT_TARGET_FILES_PACKAGE),)
6116$(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED_RADIOIMAGE_TARGET) \
6117 $(INSTALLED_RECOVERYIMAGE_TARGET) \
6118 $(INSTALLED_CACHEIMAGE_TARGET) \
6119 $(INSTALLED_DTBOIMAGE_TARGET) \
6120 $(INSTALLED_PVMFWIMAGE_TARGET) \
6121 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
6122 $(INSTALLED_CUSTOMIMAGES_TARGET) \
6123 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
6124 $(INSTALLED_KERNEL_TARGET) \
6125 $(INSTALLED_RAMDISK_TARGET) \
6126 $(INSTALLED_DTBIMAGE_TARGET) \
6127 $(INSTALLED_2NDBOOTLOADER_TARGET) \
6128 $(BOARD_PREBUILT_DTBOIMAGE) \
6129 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
6130 $(BOARD_RECOVERY_ACPIO) \
6131 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
6132 $(PRODUCT_VENDOR_BASE_FS_PATH) \
6133 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
6134 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
6135 $(PRODUCT_ODM_BASE_FS_PATH) \
6136 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
6137 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
6138 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
6139 $(LPMAKE) \
6140 $(SELINUX_FC) \
6141 $(INSTALLED_MISC_INFO_TARGET) \
6142 $(APKCERTS_FILE) \
6143 $(SOONG_APEX_KEYS_FILE) \
6144 $(HOST_OUT_EXECUTABLES)/fs_config \
6145 $(ADD_IMG_TO_TARGET_FILES) \
6146 $(MAKE_RECOVERY_PATCH) \
6147 $(BUILT_KERNEL_CONFIGS_FILE) \
6148 $(BUILT_KERNEL_VERSION_FILE),$(BUILT_TARGET_FILES_PACKAGE):)
6149
Ying Wang4709d7c2014-04-14 17:25:43 -07006150$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07006151
Dan Albert4d323332016-10-14 13:23:06 -07006152# -----------------------------------------------------------------
6153# NDK Sysroot Package
6154NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Colin Crossec65b762022-10-20 14:03:47 -07006155.PHONY: ndk_sysroot
6156ndk_sysroot: $(NDK_SYSROOT_TARGET)
Dan Willemsen14e10262018-06-17 21:54:21 -07006157$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07006158 @echo Package NDK sysroot...
6159 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
6160
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006161ifeq ($(HOST_OS),linux)
Colin Crossec65b762022-10-20 14:03:47 -07006162$(call dist-for-goals,sdk ndk_sysroot,$(NDK_SYSROOT_TARGET))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006163endif
Dan Albert4d323332016-10-14 13:23:06 -07006164
Ying Wang09c4b682015-08-11 11:24:19 -07006165ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07006166# -----------------------------------------------------------------
6167# OTA update package
6168
Yifan Hong50e79542018-11-08 17:44:12 -08006169# $(1): output file
6170# $(2): additional args
6171define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07006172PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07006173 $(OTA_FROM_TARGET_FILES) \
6174 --verbose \
6175 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
6176 --path $(HOST_OUT) \
6177 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
6178 $(2) \
6179 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08006180endef
6181
Tianjie6bd3b1a2020-10-16 18:53:47 -07006182product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07006183ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006184 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07006185endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07006186name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07006187
6188INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08006189INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
6190
Bob Badour5acd4362022-04-12 18:31:35 -07006191$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
6192
Doug Zongker8678df42009-06-15 14:30:14 -07006193$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08006194$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07006195$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07006196 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08006197 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07006198
Bob Badour5acd4362022-04-12 18:31:35 -07006199$(call declare-1p-container,$(INTERNAL_OTA_PACKAGE_TARGET),)
6200$(call declare-container-license-deps,$(INTERNAL_OTA_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6201
Doug Zongker8678df42009-06-15 14:30:14 -07006202.PHONY: otapackage
6203otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
6204
Tao Bao519d1822018-12-27 12:47:23 -08006205ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006206name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08006207
6208INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08006209$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07006210$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
6211 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07006212 $(OTA_FROM_TARGET_FILES) \
6213 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08006214 @echo "Package OTA (retrofit dynamic partitions): $@"
6215 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
6216
Bob Badour5acd4362022-04-12 18:31:35 -07006217$(call declare-1p-container,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),)
6218$(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)/:/)
6219
Yifan Hong50e79542018-11-08 17:44:12 -08006220.PHONY: otardppackage
6221
6222otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
6223
Tao Bao519d1822018-12-27 12:47:23 -08006224endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08006225
Tianjie6bd3b1a2020-10-16 18:53:47 -07006226ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
6227name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
6228
6229INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6230$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
6231$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
6232 @echo "Package partial OTA: $@"
6233 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
6234
Bob Badour5acd4362022-04-12 18:31:35 -07006235$(call declare-1p-container,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),)
6236$(call declare-container-license-deps,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6237
6238
Tianjie6bd3b1a2020-10-16 18:53:47 -07006239.PHONY: partialotapackage
6240partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
6241
6242endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
6243
Ying Wang09c4b682015-08-11 11:24:19 -07006244endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07006245
Ying Wang09a00a62010-10-20 14:01:09 -07006246# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01006247# A zip of the appcompat directory containing logs
6248APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
6249# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006250ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07006251$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
6252 $(INTERNAL_RAMDISK_FILES) \
6253 $(INTERNAL_USERDATAIMAGE_FILES) \
6254 $(INTERNAL_VENDORIMAGE_FILES) \
6255 $(INTERNAL_PRODUCTIMAGE_FILES) \
6256 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01006257endif
6258$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
6259$(APPCOMPAT_ZIP): $(SOONG_ZIP)
6260 @echo "appcompat logs: $@"
6261 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6262 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
6263 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
6264 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
6265
Jeongik Cha2522c362021-04-27 23:52:15 +09006266# The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
6267ifeq ($(BUILD_OS),linux)
Jeongik Cha62519de2021-05-13 13:29:39 +09006268ifneq ($(DEX2OAT),)
Saeid Farivar Asanjan0b4f8d52022-08-08 20:23:45 +00006269dexpreopt_tools_deps := $(DEXPREOPT_GEN_DEPS) $(DEXPREOPT_GEN)
Eric Miao1d0fd2c2021-11-08 19:34:50 +00006270dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/dexdump
6271dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/oatdump
Jeongik Cha2522c362021-04-27 23:52:15 +09006272DEXPREOPT_TOOLS_ZIP := $(PRODUCT_OUT)/dexpreopt_tools.zip
6273$(DEXPREOPT_TOOLS_ZIP): $(dexpreopt_tools_deps)
6274$(DEXPREOPT_TOOLS_ZIP): PRIVATE_DEXPREOPT_TOOLS_DEPS := $(dexpreopt_tools_deps)
6275$(DEXPREOPT_TOOLS_ZIP): $(SOONG_ZIP)
6276 $(hide) mkdir -p $(dir $@)
6277 $(hide) $(SOONG_ZIP) -d -o $@ -j $(addprefix -f ,$(PRIVATE_DEXPREOPT_TOOLS_DEPS)) -f $$(realpath $(DEX2OAT))
Bob Badour5acd4362022-04-12 18:31:35 -07006278$(call declare-1p-target,$(DEXPREOPT_TOOLS_ZIP),)
Jeongik Cha62519de2021-05-13 13:29:39 +09006279endif # DEX2OAT is set
6280endif # BUILD_OS == linux
Jeongik Cha2522c362021-04-27 23:52:15 +09006281
Jeongik Chaa8056d62021-04-07 23:57:16 +09006282DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
Jeongik Chab26bf582021-06-08 11:31:31 +09006283
6284$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
6285 $(INSTALLED_VENDORIMAGE_TARGET) \
6286 $(INSTALLED_ODMIMAGE_TARGET) \
6287 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6288
6289ifeq (,$(TARGET_BUILD_UNBUNDLED))
6290$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
6291 $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
6292
6293endif
Jeongik Chaa8056d62021-04-07 23:57:16 +09006294
6295$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
6296 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Chab26bf582021-06-08 11:31:31 +09006297
6298ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006299ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006300 $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006301endif
6302ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006303 $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006304endif
Jeongik Chab26bf582021-06-08 11:31:31 +09006305endif #!TARGET_BUILD_UNBUNDLED
Jeongik Chaa8056d62021-04-07 23:57:16 +09006306 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
6307
Jeongik Chab26bf582021-06-08 11:31:31 +09006308.PHONY: dexpreopt_config_zip
6309dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
6310
Bob Badour5acd4362022-04-12 18:31:35 -07006311$(call declare-1p-target,$(DEXPREOPT_CONFIG_ZIP),)
6312
Dario Frenid1011272018-07-23 20:20:15 +01006313# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006314# A zip of the symbols directory. Keep the full paths to make it
6315# more obvious where these files came from.
Colin Crossac7febc2022-04-06 01:11:20 +00006316# Also produces a textproto containing mappings from elf IDs to symbols
6317# filename, which will allow finding the appropriate symbols to deobfuscate
6318# a stack trace frame.
The Android Open Source Project88b60792009-03-03 19:28:42 -08006319#
Colin Crossac7febc2022-04-06 01:11:20 +00006320
The Android Open Source Project88b60792009-03-03 19:28:42 -08006321name := $(TARGET_PRODUCT)
6322ifeq ($(TARGET_BUILD_TYPE),debug)
6323 name := $(name)_debug
6324endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006325
Colin Crossac7febc2022-04-06 01:11:20 +00006326# The path to the zip file containing binaries with symbols.
6327SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols-$(FILE_NAME_TAG).zip
6328# The path to a file containing mappings from elf IDs to filenames.
6329SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping-$(FILE_NAME_TAG).textproto
6330.KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING
Colin Cross6cdc5d22017-10-20 11:37:33 -07006331# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006332ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006333$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07006334endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006335$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
Colin Crossac7febc2022-04-06 01:11:20 +00006336$(SYMBOLS_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)
6337$(SYMBOLS_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006338 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006339 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006340 $(hide) mkdir -p $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE)) $(PRIVATE_MAPPING_PACKAGING_DIR)
6341 # Find all of the files in the symbols directory and zip them into the symbols zip.
Jiyong Park88e09802019-03-21 15:19:16 +09006342 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07006343 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006344 # Find all of the files in the symbols mapping directory and merge them into the symbols mapping textproto.
6345 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6346 $(hide) $(SYMBOLS_MAP) -merge $(SYMBOLS_MAPPING) -ignore_missing_files @$(PRIVATE_LIST_FILE)
6347$(SYMBOLS_ZIP): .KATI_IMPLICIT_OUTPUTS := $(SYMBOLS_MAPPING)
6348
Bob Badour5acd4362022-04-12 18:31:35 -07006349$(call declare-1p-container,$(SYMBOLS_ZIP),)
6350ifeq (,$(TARGET_BUILD_UNBUNDLED))
6351$(call declare-container-license-deps,$(SYMBOLS_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6352endif
6353
Ryan Campbell81c9d292016-09-12 13:56:50 -07006354# -----------------------------------------------------------------
6355# A zip of the coverage directory.
6356#
Oliver Nguyene91ab232019-04-30 15:14:44 -07006357name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07006358ifeq ($(TARGET_BUILD_TYPE),debug)
6359name := $(name)_debug
6360endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07006361COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006362ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006363$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07006364endif
6365$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
6366$(COVERAGE_ZIP): $(SOONG_ZIP)
6367 @echo "Package coverage: $@"
6368 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6369 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
6370 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
6371 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006372
Bob Badourf2529722022-03-18 11:34:03 -07006373$(call declare-1p-container,$(COVERAGE_ZIP),)
Bob Badour5acd4362022-04-12 18:31:35 -07006374ifeq (,$(TARGET_BUILD_UNBUNDLED))
Bob Badourf2529722022-03-18 11:34:03 -07006375$(call declare-container-license-deps,$(COVERAGE_ZIP),$(INTERNAL_ALLIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badour5acd4362022-04-12 18:31:35 -07006376endif
Bob Badourf2529722022-03-18 11:34:03 -07006377
6378SYSTEM_NOTICE_DEPS += $(COVERAGE_ZIP)
6379
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006380#------------------------------------------------------------------
6381# Export the LLVM profile data tool and dependencies for Clang coverage processing
6382#
6383ifeq (true,$(CLANG_COVERAGE))
6384 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006385 LLVM_COV := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov
Qing Shend058fc32022-09-30 00:27:58 +00006386 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 -08006387 # Use llvm-profdata.zip for backwards compatibility with tradefed code.
6388 LLVM_COVERAGE_TOOLS_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006389
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006390 $(LLVM_COVERAGE_TOOLS_ZIP): $(SOONG_ZIP)
6391 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX) -f $(LLVM_COV)
6392
6393 $(call dist-for-goals,droidcore-unbundled apps_only,$(LLVM_COVERAGE_TOOLS_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006394endif
6395
The Android Open Source Project88b60792009-03-03 19:28:42 -08006396# -----------------------------------------------------------------
6397# A zip of the Android Apps. Not keeping full path so that we don't
6398# include product names when distributing
6399#
6400name := $(TARGET_PRODUCT)
6401ifeq ($(TARGET_BUILD_TYPE),debug)
6402 name := $(name)_debug
6403endif
6404name := $(name)-apps-$(FILE_NAME_TAG)
6405
6406APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07006407$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006408 @echo "Package apps: $@"
6409 $(hide) rm -rf $@
6410 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006411 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
6412 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00006413 echo "No apps to zip up. Generating empty apps archive." ; \
6414 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006415 else \
Anton Hansson6d814982018-11-26 18:12:05 +00006416 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006417 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07006418
Ying Wangbc415dd2012-08-15 12:22:44 -07006419ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07006420#------------------------------------------------------------------
6421# An archive of classes for use in generating code-coverage reports
6422# These are the uninstrumented versions of any classes that were
6423# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07006424# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006425
Colin Crossa6bc3a82017-09-27 14:28:41 -07006426JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Colin Cross330b1fe2021-04-06 18:04:06 -07006427$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
6428$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
6429$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
6430$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006431$(JACOCO_REPORT_CLASSES_ALL) :
6432 @echo "Collecting uninstrumented classes"
Colin Cross330b1fe2021-04-06 18:04:06 -07006433 mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
6434 $(SOONG_ZIP) -o $@ -L 0 \
6435 -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
6436 -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
6437 -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
6438 -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006439
Jiyong Park3c875602021-01-21 12:46:56 +09006440ifeq (,$(TARGET_BUILD_UNBUNDLED))
6441 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
6442endif
Ying Wangbc415dd2012-08-15 12:22:44 -07006443endif # EMMA_INSTRUMENT=true
6444
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006445
Ying Wangae9115a2013-08-22 20:52:47 -07006446#------------------------------------------------------------------
6447# A zip of Proguard obfuscation dictionary files.
Colin Crossac7febc2022-04-06 01:11:20 +00006448# Also produces a textproto containing mappings from the hashes of the
6449# dictionary contents (which are also stored in the dex files on the
6450# devices) to the filename of the proguard dictionary, which will allow
6451# finding the appropriate dictionary to deobfuscate a stack trace frame.
Ying Wangae9115a2013-08-22 20:52:47 -07006452#
Colin Crossac7febc2022-04-06 01:11:20 +00006453
6454# The path to the zip file containing proguard dictionaries.
Ying Wangc62c92c2013-08-28 18:38:25 -07006455PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Crossac7febc2022-04-06 01:11:20 +00006456# The path to the zip file containing mappings from dictionary hashes to filenames.
6457PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping-$(FILE_NAME_TAG).textproto
6458.KATI_READONLY := PROGUARD_DICT_ZIP PROGUARD_DICT_MAPPING
Colin Cross114e8df2019-09-05 17:19:35 -07006459# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006460ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006461$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07006462endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006463$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
Colin Crossac7febc2022-04-06 01:11:20 +00006464$(PROGUARD_DICT_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)
6465$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_filelist)/filelist
6466$(PROGUARD_DICT_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
Ying Wangae9115a2013-08-22 20:52:47 -07006467 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossac7febc2022-04-06 01:11:20 +00006468 rm -rf $@ $(PRIVATE_LIST_FILE)
6469 mkdir -p $(PRIVATE_PACKAGING_DIR) $(PRIVATE_MAPPING_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6470 # Zip all of the files in the proguard dictionary directory.
6471 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -D $(PRIVATE_PACKAGING_DIR)
6472 # Find all of the files in the proguard dictionary mapping directory and merge them into the mapping textproto.
6473 # Strip the PRIVATE_PACKAGING_DIR off the filenames to match soong_zip's -C argument.
6474 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6475 $(SYMBOLS_MAP) -merge $(PROGUARD_DICT_MAPPING) -strip_prefix $(PRIVATE_PACKAGING_DIR)/ -ignore_missing_files @$(PRIVATE_LIST_FILE)
6476$(PROGUARD_DICT_ZIP): .KATI_IMPLICIT_OUTPUTS := $(PROGUARD_DICT_MAPPING)
Ying Wangae9115a2013-08-22 20:52:47 -07006477
Bob Badour5acd4362022-04-12 18:31:35 -07006478$(call declare-1p-container,$(PROGUARD_DICT_ZIP),)
6479ifeq (,$(TARGET_BUILD_UNBUNDLED))
6480$(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6481endif
6482
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006483#------------------------------------------------------------------
6484# A zip of Proguard usage files.
6485#
6486PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
6487# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
6488ifeq (,$(TARGET_BUILD_UNBUNDLED))
6489$(PROGUARD_USAGE_ZIP): \
6490 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6491 $(INSTALLED_RAMDISK_TARGET) \
6492 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00006493 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006494 $(INSTALLED_USERDATAIMAGE_TARGET) \
6495 $(INSTALLED_VENDORIMAGE_TARGET) \
6496 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6497 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6498 $(INSTALLED_ODMIMAGE_TARGET) \
6499 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6500 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00006501 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006502 $(updater_dep)
6503endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006504$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
6505$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006506$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
6507 @echo "Packaging Proguard usage files."
Colin Cross330b1fe2021-04-06 18:04:06 -07006508 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6509 find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006510 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07006511
Bob Badour5acd4362022-04-12 18:31:35 -07006512$(call declare-1p-container,$(PROGUARD_USAGE_ZIP),)
6513ifeq (,$(TARGET_BUILD_UNBUNDLED))
6514$(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(INSTALLED_SYSTEMIMAGE_TARGET) \
6515 $(INSTALLED_RAMDISK_TARGET) \
6516 $(INSTALLED_BOOTIMAGE_TARGET) \
6517 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
6518 $(INSTALLED_USERDATAIMAGE_TARGET) \
6519 $(INSTALLED_VENDORIMAGE_TARGET) \
6520 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6521 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6522 $(INSTALLED_ODMIMAGE_TARGET) \
6523 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6524 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
6525 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
6526 $(updater_dep),$(PROGUARD_USAGE_ZIP):/)
6527endif
6528
Tao Bao48a2feb2019-06-28 11:00:05 -07006529ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6530
6531# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
6532# $(1): output file
6533define dump-super-image-info
6534 $(call dump-dynamic-partitions-info,$(1))
6535 $(if $(filter true,$(AB_OTA_UPDATER)), \
6536 echo "ab_update=true" >> $(1))
6537endef
6538
6539endif # PRODUCT_USE_DYNAMIC_PARTITIONS
6540
The Android Open Source Project88b60792009-03-03 19:28:42 -08006541# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07006542# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08006543
6544ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6545
6546# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
6547ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6548
6549ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07006550
6551# For real devices and for dist builds, build super image from target files to an intermediate directory.
6552INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
6553$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
6554$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
6555 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08006556 PATH=$(dir $(LPMAKE)):$$PATH \
6557 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07006558
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006559# Skip packing it in dist package because it is in update package.
6560ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07006561$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006562endif
Yifan Hongacd862a2019-04-16 15:44:30 -07006563
6564.PHONY: superimage_dist
6565superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07006566
6567endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07006568endif # BOARD_SUPER_PARTITION_SIZE != ""
6569endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08006570
Yifan Hongacd862a2019-04-16 15:44:30 -07006571# -----------------------------------------------------------------
6572# super partition image for development
6573
6574ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6575ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6576ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
6577
6578# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
6579# $(1): built image path
6580# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
6581define build-superimage-target
6582 mkdir -p $(dir $(2))
6583 rm -rf $(2)
6584 $(call dump-super-image-info,$(2))
6585 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
6586 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09006587 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
6588 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07006589 mkdir -p $(dir $(1))
6590 PATH=$(dir $(LPMAKE)):$$PATH \
6591 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
6592endef
6593
6594INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
6595INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
6596 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
6597
changho.shina8f9f112019-10-15 13:26:19 +09006598ifdef BUILDING_SYSTEM_OTHER_IMAGE
6599ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
6600INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
6601endif
6602endif
6603
Yifan Hongacd862a2019-04-16 15:44:30 -07006604$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6605 $(call pretty,"Target super fs image for debug: $@")
6606 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08006607 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006608
Yifan Hongacd862a2019-04-16 15:44:30 -07006609# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
6610.PHONY: superimage
6611superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08006612
Peter Collingbourne683c4932022-07-06 15:49:20 -07006613# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
6614# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
6615# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
6616# virtual devices.
6617ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
6618droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
6619
Isaac Chen52cc60c2019-08-14 18:52:13 +08006620$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006621endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
6622
6623# Build $(PRODUCT_OUT)/super.img without dependencies.
6624.PHONY: superimage-nodeps supernod
6625superimage-nodeps supernod: intermediates :=
6626superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6627 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
6628 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
6629 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
6630
6631endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
6632endif # BOARD_SUPER_PARTITION_SIZE != ""
6633endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
6634
6635# -----------------------------------------------------------------
6636# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00006637ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006638
Yifan Hong8b79d162018-11-29 12:32:00 -08006639INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
6640$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
6641$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
6642 $(call pretty,"Target empty super fs image: $@")
6643 mkdir -p $(intermediates)
6644 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07006645 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08006646 PATH=$(dir $(LPMAKE)):$$PATH \
6647 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08006648
6649$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6650
Bob Badourebdefc02022-02-12 15:39:22 -08006651$(call declare-0p-target,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6652
Yo Chiange86bab42021-03-25 10:12:28 +00006653endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006654
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006655
6656# -----------------------------------------------------------------
6657# The update package
6658
6659name := $(TARGET_PRODUCT)
6660ifeq ($(TARGET_BUILD_TYPE),debug)
6661 name := $(name)_debug
6662endif
6663name := $(name)-img-$(FILE_NAME_TAG)
6664
6665INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6666
Tao Bao57f8ed62019-08-14 23:08:18 -07006667$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
6668 $(call pretty,"Package: $@")
6669 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
6670 $(IMG_FROM_TARGET_FILES) \
6671 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
6672 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006673
Bob Badour5acd4362022-04-12 18:31:35 -07006674$(call declare-1p-container,$(INTERNAL_UPDATE_PACKAGE_TARGET),)
6675$(call declare-container-license-deps,$(INTERNAL_UPDATE_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES),$(PRODUCT_OUT)/:/)
6676
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006677.PHONY: updatepackage
6678updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07006679$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006680
6681
Yifan Hong2b891ac2018-11-29 12:06:31 -08006682# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006683# dalvik something
6684.PHONY: dalvikfiles
6685dalvikfiles: $(INTERNAL_DALVIK_MODULES)
6686
Bo Huf0d50bb2017-08-01 19:02:09 +00006687ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00006688MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08006689MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00006690SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08006691
6692ifdef INSTALLED_SYSTEMIMAGE_TARGET
6693INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08006694INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
6695$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
6696 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
6697 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08006698$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08006699 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
6700 @echo Create system-qemu.img now
6701 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08006702 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00006703
6704systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006705droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08006706endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006707ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00006708INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006709$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00006710 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006711 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00006712
6713vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006714droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
Bo Huf0d50bb2017-08-01 19:02:09 +00006715endif
bohu8fd437c2020-03-30 20:16:13 -07006716
6717ifdef INSTALLED_RAMDISK_TARGET
6718ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
6719ifdef INTERNAL_VENDOR_RAMDISK_TARGET
6720INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
6721$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
6722 @echo Create ramdisk-qemu.img
6723 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
6724
Bill Peckham315b98a2021-06-15 19:35:06 -07006725droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
bohu8fd437c2020-03-30 20:16:13 -07006726endif
6727endif
6728endif
6729
Anton Hansson32c76fe2018-12-13 14:34:18 +00006730ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006731INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006732$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006733 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006734 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006735
6736productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006737droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006738endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006739ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
6740INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
6741$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
6742 @echo Create system_ext-qemu.img
6743 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01006744
Justin Yun6151e3f2019-06-25 15:58:13 +09006745systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006746droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01006747endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006748ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006749INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
6750$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6751 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006752 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006753
6754odmimage: $(INSTALLED_QEMU_ODMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006755droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006756endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006757
Yifan Hongcfb917a2020-05-07 14:58:20 -07006758ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
6759INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
6760$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6761 @echo Create vendor_dlkm-qemu.img
6762 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
6763
6764vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006765droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07006766endif
6767
Yifan Hongf496f1b2020-07-15 16:52:59 -07006768ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
6769INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
6770$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6771 @echo Create odm_dlkm-qemu.img
6772 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
6773
6774odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006775droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07006776endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006777
Ramji Jiyani13a41372022-01-27 07:05:08 +00006778ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
6779INSTALLED_QEMU_SYSTEM_DLKMIMAGE := $(PRODUCT_OUT)/system_dlkm-qemu.img
6780$(INSTALLED_QEMU_SYSTEM_DLKMIMAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6781 @echo Create system_dlkm-qemu.img
6782 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET))
6783
6784system_dlkmimage: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6785droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6786endif
6787
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006788QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08006789$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
6790 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006791 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08006792 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
6793 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006794
6795systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
Bill Peckham315b98a2021-06-15 19:35:06 -07006796droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08006797
Bo Huf0d50bb2017-08-01 19:02:09 +00006798endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006799# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006800# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07006801ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006802INTERNAL_EMULATOR_PACKAGE_FILES += \
6803 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006804 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07006805 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6806 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006807
6808name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
6809
6810INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6811
Ying Wang5d887702015-11-04 10:06:25 -08006812$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006813 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07006814 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006815
Ying Wang7d8c5352012-07-26 10:15:21 -07006816endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08006817
The Android Open Source Project88b60792009-03-03 19:28:42 -08006818
6819# -----------------------------------------------------------------
6820# The SDK
6821
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006822ifneq ($(filter sdk,$(MAKECMDGOALS)),)
6823
The Android Open Source Project88b60792009-03-03 19:28:42 -08006824# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07006825sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006826
6827# Build a name that looks like:
6828#
6829# linux-x86 --> android-sdk_12345_linux-x86
6830# darwin-x86 --> android-sdk_12345_mac-x86
6831# windows-x86 --> android-sdk_12345_windows
6832#
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006833ifneq ($(HOST_OS),linux)
6834 $(error Building the monolithic SDK is only supported on Linux)
6835endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006836sdk_name := android-sdk_$(FILE_NAME_TAG)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006837INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH)
Joe Onorato03fbe402009-04-13 08:31:16 -07006838sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006839
6840sdk_dep_file := $(sdk_dir)/sdk_deps.mk
6841
6842ATREE_FILES :=
6843-include $(sdk_dep_file)
6844
6845# if we don't have a real list, then use "everything"
6846ifeq ($(strip $(ATREE_FILES)),)
6847ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006848 $(ALL_DOCS) \
6849 $(ALL_SDK_FILES)
6850endif
6851
6852atree_dir := development/build
6853
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01006854
Dan Willemsen53c98f72021-10-16 16:49:06 -07006855sdk_atree_files := $(atree_dir)/sdk.exclude.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08006856
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02006857# development/build/sdk-android-<abi>.atree is used to differentiate
6858# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
6859# files like the kernel image. We use TARGET_CPU_ABI because we don't
6860# have a better way to distinguish between CPU models.
6861ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
6862 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
6863endif
6864
Anton Hansson8dab0a62019-03-28 15:45:40 +00006865ifneq ($(PRODUCT_SDK_ATREE_FILES),)
6866sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08006867else
6868sdk_atree_files += $(atree_dir)/sdk.atree
6869endif
6870
The Android Open Source Project88b60792009-03-03 19:28:42 -08006871deps := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006872 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01006873 $(SDK_METADATA_FILES) \
Anton Hansson55a8f022022-05-12 08:45:29 +00006874 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006875 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08006876 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006877 $(HOST_OUT_EXECUTABLES)/atree \
Jerome Gaillardcf713d42019-10-23 11:43:26 +01006878 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08006879
Anton Hansson874dbe72022-10-26 15:00:55 +00006880# The name of the subdir within the platforms dir of the sdk. One of:
6881# - android-<SDK_INT> (stable base dessert SDKs)
6882# - android-<CODENAME> (stable extension SDKs)
6883# - android-<SDK_INT>-ext<EXT_INT> (codename SDKs)
6884sdk_platform_dir_name := $(strip \
6885 $(if $(filter REL,$(PLATFORM_VERSION_CODENAME)), \
6886 $(if $(filter $(PLATFORM_SDK_EXTENSION_VERSION),$(PLATFORM_BASE_SDK_EXTENSION_VERSION)), \
6887 android-$(PLATFORM_SDK_VERSION), \
6888 android-$(PLATFORM_SDK_VERSION)-ext$(PLATFORM_SDK_EXTENSION_VERSION) \
6889 ), \
6890 android-$(PLATFORM_VERSION_CODENAME) \
6891 ) \
6892)
6893
The Android Open Source Project88b60792009-03-03 19:28:42 -08006894INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
6895$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
6896$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
6897$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
6898$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
Anton Hansson874dbe72022-10-26 15:00:55 +00006899$(INTERNAL_SDK_TARGET): PRIVATE_PLATFORM_NAME := $(sdk_platform_dir_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006900# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
6901#
6902#SDK_GNU_ERROR := true
6903
Ying Wang5d887702015-11-04 10:06:25 -08006904$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006905 @echo "Package SDK: $@"
6906 $(hide) rm -rf $(PRIVATE_DIR) $@
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07006907 $(hide) for f in $(strip $(target_gnu_MODULES)); do \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006908 if [ -f $$f ]; then \
6909 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
6910 including GNU target $$f >&2; \
6911 FAIL=$(SDK_GNU_ERROR); \
6912 fi; \
6913 done; \
6914 if [ $$FAIL ]; then exit 1; fi
6915 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00006916 ATREE_STRIP="$(HOST_STRIP) -x" \
6917 $(HOST_OUT_EXECUTABLES)/atree \
6918 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
6919 -m $(PRIVATE_DEP_FILE) \
6920 -I . \
6921 -I $(PRODUCT_OUT) \
6922 -I $(HOST_OUT) \
6923 -I $(TARGET_COMMON_OUT_ROOT) \
Anton Hansson874dbe72022-10-26 15:00:55 +00006924 -v "PLATFORM_NAME=$(PRIVATE_PLATFORM_NAME)" \
Anton Hansson6d814982018-11-26 18:12:05 +00006925 -v "OUT_DIR=$(OUT_DIR)" \
6926 -v "HOST_OUT=$(HOST_OUT)" \
6927 -v "TARGET_ARCH=$(TARGET_ARCH)" \
6928 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
6929 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Anton Hansson6d814982018-11-26 18:12:05 +00006930 -o $(PRIVATE_DIR) && \
Anton Hansson6d814982018-11-26 18:12:05 +00006931 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
6932 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
6933 chmod -R ug+rwX $(PRIVATE_DIR) && \
6934 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006935 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
6936
Raphaelc4d47312011-02-15 16:09:36 -08006937MAIN_SDK_DIR := $(sdk_dir)
6938MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006939
6940endif # sdk in MAKECMDGOALS
Raphael3d224a02010-04-16 17:50:09 -07006941
The Android Open Source Project88b60792009-03-03 19:28:42 -08006942# -----------------------------------------------------------------
6943# Findbugs
6944INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
6945INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
6946$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
6947 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006948 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006949 > $@
6950$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
6951 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006952 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07006953 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08006954
6955# -----------------------------------------------------------------
6956# Findbugs
6957
6958# -----------------------------------------------------------------
6959# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07006960ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006961include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01006962-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07006963-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006964-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07006965# Also the project-specific tasks
6966-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
6967-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006968-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07006969# Also add test specifc tasks
6970include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07006971include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07006972endif
Raphaelc4d47312011-02-15 16:09:36 -08006973
Ying Wang67132ba2015-10-28 16:42:39 -07006974include $(BUILD_SYSTEM)/product-graph.mk
6975
Raphaelc4d47312011-02-15 16:09:36 -08006976# -----------------------------------------------------------------
6977# Create SDK repository packages. Must be done after tasks/* since
6978# we need the addon rules defined.
6979ifneq ($(sdk_repo_goal),)
6980include $(TOPDIR)development/build/tools/sdk_repo.mk
6981endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07006982
6983# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07006984# Soong generates the list of all shared libraries that are depended on by fuzz
6985# targets. It saves this list as a source:destination pair to
6986# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
6987# build of the unstripped shared library, and the destination is the
6988# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
6989# where fuzz target shared libraries are to be "reinstalled". The
6990# copy-many-files below generates the rules to copy the unstripped shared
6991# libraries to the device or host "reinstallation" directory. These rules are
6992# depended on by each module in soong_cc_prebuilt.mk, where the module will have
6993# a dependency on each shared library that it needs to be "reinstalled".
6994FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
6995
6996# -----------------------------------------------------------------
hamzeh5dfe7a22021-04-29 12:44:16 -07006997# The rule to build all fuzz targets for C++ and Rust, and package them.
Mitch Phillipsceefc442019-09-26 16:37:59 -07006998# Note: The packages are created in Soong, and in a perfect world,
6999# we'd be able to create the phony rule there. But, if we want to
7000# have dist goals for the fuzz target, we need to have the PHONY
7001# target defined in make. MakeVarsContext.DistForGoal doesn't take
7002# into account that a PHONY rule create by Soong won't be available
7003# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08007004# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07007005# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08007006.PHONY: haiku
7007haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
7008$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00007009$(call dist-for-goals,haiku,$(PRODUCT_OUT)/module-info.json)
hamzeh5dfe7a22021-04-29 12:44:16 -07007010
Muhammad Haseeb Ahmade3a89402022-10-13 21:19:06 +00007011.PHONY: haiku-java-device
7012haiku-java-device: $(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_DEVICE_TARGETS)
7013$(call dist-for-goals,haiku-java-device,$(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES))
7014$(call dist-for-goals,haiku-java-device,$(PRODUCT_OUT)/module-info.json)
7015
7016.PHONY: haiku-java-host
7017haiku-java-host: $(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_HOST_TARGETS)
7018$(call dist-for-goals,haiku-java-host,$(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES))
7019$(call dist-for-goals,haiku-java-host,$(PRODUCT_OUT)/module-info.json)
Muhammad Haseeb Ahmadcced1362022-01-13 03:17:39 +00007020
hamzeh5dfe7a22021-04-29 12:44:16 -07007021.PHONY: haiku-rust
7022haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
7023$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00007024$(call dist-for-goals,haiku-rust,$(PRODUCT_OUT)/module-info.json)
Jerome Gaillardcf713d42019-10-23 11:43:26 +01007025
7026# -----------------------------------------------------------------
7027# Extract platform fonts used in Layoutlib
7028include $(BUILD_SYSTEM)/layoutlib_fonts.mk
Bob Badourebdefc02022-02-12 15:39:22 -08007029
7030
7031# -----------------------------------------------------------------
7032# OS Licensing
7033
7034include $(BUILD_SYSTEM)/os_licensing.mk
7035
7036# When appending new code to this file, please insert above OS Licensing