blob: e96f210335d50760f904d54560c9c102d93ae2c5 [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
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800309# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700310define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700311 $(if $(9), \
312 $(eval _dir := $(9)/), \
313 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000314 $(foreach module,$(1), \
315 $(eval _src := $(module)) \
316 $(if $(8), \
317 $(eval _src := $(8)/$(notdir $(module))) \
318 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700319 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700320 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700321 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
322 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
323 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
324 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700325endef
326
327# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700328# $(2): mount point
329# $(3): staging dir
330# $(4): module load list
331# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800332# $(6): module archive
333# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700334# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800335# TODO(b/144844424): If a module archive is being used, this step (which
336# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
337# the output directory. This should be moved to a module with a
338# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
339# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700340define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700341$(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 -0700342$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700343$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
Steve Muckle474e4d02019-06-19 12:56:48 -0700344$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700345$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700346$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700347$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
Steve Muckle474e4d02019-06-19 12:56:48 -0700348$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800349$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
350$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
351$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700352 @echo depmod $$(PRIVATE_STAGING_DIR)
353 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700354 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800355 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700356 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800357 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700358 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800359 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
360 )
361 $(if $(1),\
362 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
363 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
364 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
365 done; \
366 )
Colin Cross4f60e362019-06-05 11:53:43 -0700367 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
368 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700369 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
370 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700371endef
372
Steve Muckle474e4d02019-06-19 12:56:48 -0700373# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700374# $(2): modules list
375# $(3): module load list
376# $(4): module load list filename
377# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700378define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700379 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
380 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700381endef
382
383# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700384# $(2): modules list
385# $(3): module load list
386# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700387define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700388$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
389$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
390 @echo load-list $$(@)
391 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700392endef
393
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800394# $(1): source options file
395# $(2): destination pathname
396# Returns a build rule that checks the syntax of and installs a kernel modules
397# options file. Strip and squeeze any extra space and blank lines.
398# For use via $(eval).
399define build-image-kernel-modules-options-file
400$(2): $(1)
401 @echo "libmodprobe options $$(@)"
402 $(hide) mkdir -p "$$(dir $$@)"
403 $(hide) rm -f "$$@"
404 $(hide) awk <"$$<" >"$$@" \
405 '/^#/ { print; next } \
406 NF == 0 { next } \
407 NF < 2 || $$$$1 != "options" \
408 { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
409 exit_status = 1; next } \
410 { $$$$1 = $$$$1; print } \
411 END { exit exit_status }'
412endef
413
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800414# $(1): source blocklist file
415# $(2): destination pathname
416# Returns a build rule that checks the syntax of and installs a kernel modules
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800417# blocklist file. Strip and squeeze any extra space and blank lines.
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800418# For use via $(eval).
419define build-image-kernel-modules-blocklist-file
420$(2): $(1)
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800421 @echo "libmodprobe blocklist $$(@)"
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800422 $(hide) mkdir -p "$$(dir $$@)"
423 $(hide) rm -f "$$@"
424 $(hide) awk <"$$<" >"$$@" \
425 '/^#/ { print; next } \
426 NF == 0 { next } \
427 NF != 2 || $$$$1 != "blocklist" \
428 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
429 exit_status = 1; next } \
430 { $$$$1 = $$$$1; print } \
431 END { exit exit_status }'
432endef
433
Steve Muckle2335d762020-05-28 18:39:38 -0700434# $(1): image name
435# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
436# $(3): mount point
437# $(4): module load filename
438# $(5): stripped staging directory
439# $(6): kernel module directory name (top is an out of band value for no directory)
440define build-image-kernel-modules-dir
441$(if $(filter top,$(6)),\
442 $(eval _kver :=)$(eval _sep :=),\
443 $(eval _kver := $(6))$(eval _sep :=_))\
444$(if $(5),\
445 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
446 $(eval _stripped_staging_dir :=))\
447$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
448 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
449 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Kelvin Zhangb66b11e2022-12-05 13:04:42 -0800450 $(if $(filter false,$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver))),\
451 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) :=),) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800452 $(call copy-many-files,$(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver)))) \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800453$(if $(_kver), \
454 $(eval _dir := $(_kver)/), \
455 $(eval _dir :=)) \
456$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
457 $(eval $(call build-image-kernel-modules-options-file, \
458 $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
459 $(2)/lib/modules/$(_dir)modules.options)) \
460 $(2)/lib/modules/$(_dir)modules.options) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800461$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
462 $(eval $(call build-image-kernel-modules-blocklist-file, \
463 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800464 $(2)/lib/modules/$(_dir)modules.blocklist)) \
465 $(2)/lib/modules/$(_dir)modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700466endef
467
468# $(1): kernel module directory name (top is an out of band value for no directory)
469define build-recovery-as-boot-load
470$(if $(filter top,$(1)),\
471 $(eval _kver :=)$(eval _sep :=),\
472 $(eval _kver := $(1))$(eval _sep :=_))\
473 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
474 $(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))))
475endef
476
477# $(1): kernel module directory name (top is an out of band value for no directory)
478define build-vendor-ramdisk-recovery-load
479$(if $(filter top,$(1)),\
480 $(eval _kver :=)$(eval _sep :=),\
481 $(eval _kver := $(1))$(eval _sep :=_))\
482 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
483 $(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))))
484endef
485
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700486# $(1): kernel module directory name (top is an out of band value for no directory)
487define build-vendor-charger-load
488$(if $(filter top,$(1)),\
489 $(eval _kver :=)$(eval _sep :=),\
490 $(eval _kver := $(1))$(eval _sep :=_))\
491 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
492 $(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))))
493endef
494
Steve Mucklee1b10862019-07-10 10:49:37 -0700495ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
496 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
497 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700498 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700499 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
500endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700501
Steve Muckle69280d22019-07-11 12:23:38 -0700502ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
503 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700504endif
505
Steve Mucklee1b10862019-07-10 10:49:37 -0700506ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700507 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700508 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700509 endif
510endif
511
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800512ifneq ($(BOARD_DO_NOT_STRIP_RECOVERY_MODULES),true)
513 RECOVERY_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery_stripped)
514else
515 RECOVERY_STRIPPED_MODULE_STAGING_DIR :=
516endif
517
J. Avilaa2ceec62020-05-12 23:40:02 +0000518ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
519 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
520else
521 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
522endif
Colin Cross4f60e362019-06-05 11:53:43 -0700523
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700524ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
525 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
526else
527 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
528endif
529
Lucas Weif57333f2022-02-24 10:30:15 +0800530ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_KERNEL_RAMDISK_MODULES),true)
531 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_kernel_ramdisk_stripped)
532else
533 VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
534endif
535
Steve Muckle2335d762020-05-28 18:39:38 -0700536BOARD_KERNEL_MODULE_DIRS += top
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800537$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800538 $(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 +0800539 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800540 $(if $(vendor_ramdisk_fragment), \
541 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
542 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
543 $(eval ### else ###), \
544 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
545 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800546 $(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 +0800547 $(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 +0800548 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
549 $(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))) \
550 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
551 $(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 +0000552 $(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 -0700553 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800554 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
555 $(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 -0700556
557# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800558# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700559# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900560# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700561# $2 certificate
562# $3 private key
563# $4 compressed
564# $5 partition tag
565# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100566define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700567$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
568$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
569$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
570$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700571
572endef
573
Jaewoong Jung704b4542020-06-29 19:37:53 -0700574# -----------------------------------------------------------------
575# Merge an individual apkcerts output into the final apkcerts.txt output.
576# Use a macro to make it compatible with _apkcerts_write_line
577# $1 apkcerts file to be merged
578# $2 output file
579define _apkcerts_merge
580$(hide) cat $1 >> $2
581
582endef
583
The Android Open Source Project88b60792009-03-03 19:28:42 -0800584name := $(TARGET_PRODUCT)
585ifeq ($(TARGET_BUILD_TYPE),debug)
586 name := $(name)_debug
587endif
588name := $(name)-apkcerts-$(FILE_NAME_TAG)
589intermediates := \
590 $(call intermediates-dir-for,PACKAGING,apkcerts)
591APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700592all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
593$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800594# We don't need to really build all the modules.
595# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700596$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597 @echo APK certs list: $@
598 @mkdir -p $(dir $@)
599 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700600 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700601 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
602 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
603 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700604 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700605 $(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 -0700606 $(if $(filter true,$(PRODUCT_FSVERITY_GENERATE_METADATA)),\
607 $(call _apkcerts_write_line,BuildManifest,$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system,$@) \
608 $(if $(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),\
Victor Hsiehadc94a12022-09-20 11:46:09 -0700609 $(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 -0700610 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700611 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800612
Bob Badour5acd4362022-04-12 18:31:35 -0700613$(call declare-0p-target,$(APKCERTS_FILE))
614
The Android Open Source Project88b60792009-03-03 19:28:42 -0800615.PHONY: apkcerts-list
616apkcerts-list: $(APKCERTS_FILE)
617
Ying Wang15e487a2011-02-15 10:56:18 -0800618ifneq (,$(TARGET_BUILD_APPS))
619 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900620 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800621endif
Ying Wangefb21682010-07-23 16:42:13 -0700622
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900623
The Android Open Source Project88b60792009-03-03 19:28:42 -0800624# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700625# build system stats
626BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
627$(BUILD_SYSTEM_STATS):
628 @rm -f $@
629 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
630 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700631$(call declare-1p-target,$(BUILD_SYSTEM_STATS),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700632$(call dist-for-goals,droidcore-unbundled,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700633
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700634# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800635# build /product/etc/security/avb/system_other.avbpubkey if needed
636ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800637ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800638INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
639ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800640endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800641endif # BUILDING_SYSTEM_OTHER_IMAGE
642
643# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700644# Modules ready to be converted to Soong, ordered by how many
645# modules depend on them.
646SOONG_CONV := $(sort $(SOONG_CONV))
647SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
648$(SOONG_CONV_DATA):
649 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700650 @$(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 -0700651
Bob Badour5acd4362022-04-12 18:31:35 -0700652$(call declare-1p-target,$(SOONG_CONV_DATA),build)
653
Colin Crossfdea8932017-12-06 14:38:40 -0800654SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700655SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
656$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
657 @rm -f $@
658 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
Bob Badour5acd4362022-04-12 18:31:35 -0700659$(call declare-1p-target,$(SOONG_TO_CONVERT),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700660$(call dist-for-goals,droidcore-unbundled,$(SOONG_TO_CONVERT))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700661
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700662$(PRODUCT_OUT)/product_packages.txt:
663 @rm -f $@
664 echo "" > $@
665 $(foreach x,$(PRODUCT_PACKAGES),echo $(x) >> $@$(newline))
666
Joe Onorato02fb89a2020-06-27 00:10:23 -0700667MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700668PRODUCT_PACKAGES_TXT := $(PRODUCT_OUT)/product_packages.txt
Joe Onorato02fb89a2020-06-27 00:10:23 -0700669MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
670$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700671$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato02fb89a2020-06-27 00:10:23 -0700672 @rm -f $@
673 $(hide) $(MK2BP_CATALOG_SCRIPT) \
674 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700675 --product-packages=$(PRODUCT_PACKAGES_TXT) \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700676 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
677 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700678 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700679 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700680 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700681$(call declare-1p-target,$(MK2BP_REMAINING_HTML),build)
Bill Peckham315b98a2021-06-15 19:35:06 -0700682$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_HTML))
Joe Onorato02fb89a2020-06-27 00:10:23 -0700683
Joe Onorato31986072020-08-10 09:58:49 -0700684MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700685$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
Joe Onorato31986072020-08-10 09:58:49 -0700686 @rm -f $@
687 $(hide) $(MK2BP_CATALOG_SCRIPT) \
688 --device=$(TARGET_DEVICE) \
Yuntao Xuc21dc3c2022-03-17 18:39:36 -0700689 --product-packages=$(PRODUCT_PACKAGES_TXT) \
690 --out-dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700691 --mode=csv \
692 > $@
Bob Badour5acd4362022-04-12 18:31:35 -0700693$(call declare-1p-target,$(MK2BP_REMAINING_CSV))
Bill Peckham315b98a2021-06-15 19:35:06 -0700694$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_CSV))
Joe Onorato31986072020-08-10 09:58:49 -0700695
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700696# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800697# Modules use -Wno-error, or added default -Wall -Werror
698WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
699$(WALL_WERROR):
700 @rm -f $@
701 echo "# Modules using -Wno-error" >> $@
702 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Yi Kongee99ddf2022-05-19 20:13:55 +0800703 echo "# Modules that allow warnings" >> $@
704 for m in $(sort $(SOONG_MODULES_WARNINGS_ALLOWED) $(MODULES_WARNINGS_ALLOWED)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800705
Bob Badour5acd4362022-04-12 18:31:35 -0700706$(call declare-0p-target,$(WALL_WERROR))
707
Bill Peckham315b98a2021-06-15 19:35:06 -0700708$(call dist-for-goals,droidcore-unbundled,$(WALL_WERROR))
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800709
710# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700711# C/C++ flag information for modules
Bill Peckham315b98a2021-06-15 19:35:06 -0700712$(call dist-for-goals,droidcore-unbundled,$(SOONG_MODULES_CFLAG_ARTIFACTS))
Jesse Paid0046922019-09-13 17:02:32 -0700713
Bob Badour5acd4362022-04-12 18:31:35 -0700714$(foreach a,$(SOONG_MODULES_CFLAG_ARTIFACTS),$(call declare-0p-target,$(call word-colon,1,$(a))))
715
Jesse Paid0046922019-09-13 17:02:32 -0700716# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800717# Modules missing profile files
718PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
719$(PGO_PROFILE_MISSING):
720 @rm -f $@
721 echo "# Modules missing PGO profile files" >> $@
722 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
723
Bob Badour5acd4362022-04-12 18:31:35 -0700724$(call declare-0p-target,$(PGO_PROFILE_MISSING))
725
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800726$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
727
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000728CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
729$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
730 rm -f $@
731 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
Bob Badour5acd4362022-04-12 18:31:35 -0700732$(call declare-0p-target,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000733$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
734
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800735# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700736# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700737# for future OTA packages installed by this system. Actual product
738# deliverables will be re-signed by hand. We expect this file to
739# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700740DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700741
742
Jeff Browne33ba4c2011-07-11 22:11:46 -0700743# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800744# if they don't do anything.
745.PHONY: systemimage
746systemimage:
747
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800748# -----------------------------------------------------------------
749
750.PHONY: event-log-tags
751
Joe Onoratob7510532010-07-14 10:22:54 -0700752# Produce an event logs tag file for everything we know about, in order
753# to properly allocate numbers. Then produce a file that's filtered
754# for what's going to be installed.
755
756all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
757
Colin Crossdc8f8e42012-04-12 13:25:54 -0700758event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
759
Joe Onoratob7510532010-07-14 10:22:54 -0700760# Include tags from all packages that we know about
761all_event_log_tags_src := \
762 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
763
Dan Willemsena3f66322020-05-28 15:46:33 -0700764$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
765$(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 -0700766 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900767 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700768
Bob Badour5acd4362022-04-12 18:31:35 -0700769$(call declare-0p-target,$(all_event_log_tags_file))
770
Doug Zongkera34fa952011-02-23 12:17:29 -0800771# Include tags from all packages included in this product, plus all
772# tags that are part of the system (ie, not in a vendor/ or device/
773# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800774event_log_tags_src := \
775 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800776 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800777 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800778 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
779 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800780
Dan Willemsena3f66322020-05-28 15:46:33 -0700781$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700782$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700783$(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 -0800784 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900785 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800786
Bob Badour2f66fd12022-03-09 17:30:24 -0800787$(eval $(call declare-0p-target,$(event_log_tags_file)))
788
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800789event-log-tags: $(event_log_tags_file)
790
791ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
792
Colin Cross79a76ec2022-03-21 15:06:11 -0700793# Initialize INSTALLED_FILES_OUTSIDE_IMAGES with the list of all device files,
794# files installed in images will be filtered out later.
795INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out \
796 $(PRODUCT_OUT)/apex/% \
Colin Cross41e93ea2022-03-25 17:31:49 -0700797 $(PRODUCT_OUT)/fake_packages/% \
Colin Cross79a76ec2022-03-21 15:06:11 -0700798 $(PRODUCT_OUT)/testcases/%, \
799 $(filter $(PRODUCT_OUT)/%,$(ALL_DEFAULT_INSTALLED_MODULES)))
Joe Onoratob7510532010-07-14 10:22:54 -0700800
The Android Open Source Project88b60792009-03-03 19:28:42 -0800801# #################################################################
802# Targets for boot/OS images
803# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800804ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
805 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000806 ifdef BOARD_PREBUILT_BOOTLOADER
807 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
808 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
809 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800810 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
811 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
812 else
813 INSTALLED_2NDBOOTLOADER_TARGET :=
814 endif
815else
816 INSTALLED_BOOTLOADER_MODULE :=
817 INSTALLED_2NDBOOTLOADER_TARGET :=
818endif # TARGET_NO_BOOTLOADER
819ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700820 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
821 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
822 $(PRODUCT_OUT)/$(k))
823 else
824 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
825 endif
Ying Wangc6349742014-01-13 16:14:20 -0800826else
827 INSTALLED_KERNEL_TARGET :=
828endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800829
830# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700831# the root dir
Colin Cross79a76ec2022-03-21 15:06:11 -0700832INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_ROOT_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Tom Cherryd14b8952018-08-09 14:26:00 -0700833INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800834 $(ALL_DEFAULT_INSTALLED_MODULES))
835
Colin Cross79a76ec2022-03-21 15:06:11 -0700836
Luis Hector Chavezff489932018-07-03 15:41:40 -0700837INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
838INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
839$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700840$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700841 @echo Installed file list: $@
SzuWei Linc230b0b2021-12-30 13:48:01 +0800842 mkdir -p $(TARGET_ROOT_OUT)
Petri Gynther728e0bd2021-03-06 13:29:28 -0800843 mkdir -p $(dir $@)
844 rm -f $@
845 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
846 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700847
Bob Badoure9bdbc52022-03-10 11:31:07 -0800848$(call declare-0p-target,$(INSTALLED_FILES_FILE_ROOT))
Bob Badour5acd4362022-04-12 18:31:35 -0700849$(call declare-0p-target,$(INSTALLED_FILES_JSON_ROOT))
Bob Badoure9bdbc52022-03-10 11:31:07 -0800850
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800851#------------------------------------------------------------------
852# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700853ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800854INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700855ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800856$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800857 cat $^ > $@
858endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700859endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800860
Tom Cherryd14b8952018-08-09 14:26:00 -0700861# -----------------------------------------------------------------
862# the ramdisk
Colin Cross79a76ec2022-03-21 15:06:11 -0700863INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -0800864ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700865INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
Tom Cherryd14b8952018-08-09 14:26:00 -0700866 $(ALL_DEFAULT_INSTALLED_MODULES))
867
868INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
869INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
870$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700871$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700872 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800873 mkdir -p $(TARGET_RAMDISK_OUT)
874 mkdir -p $(dir $@)
875 rm -f $@
876 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
877 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700878
Bob Badourebdefc02022-02-12 15:39:22 -0800879$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -0700880$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -0800881
Joe Onorato64d85d02009-04-09 19:31:12 -0700882BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
883
J. Avila3f6560e2020-05-11 20:20:03 +0000884ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
885# -l enables the legacy format used by the Linux kernel
886COMPRESSION_COMMAND_DEPS := $(LZ4)
887COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
888RAMDISK_EXT := .lz4
889else
890COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
891COMPRESSION_COMMAND := $(MINIGZIP)
892RAMDISK_EXT := .gz
893endif
894
Joe Onorato64d85d02009-04-09 19:31:12 -0700895# We just build this directly to the install location.
896INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900897$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
J. Avila3f6560e2020-05-11 20:20:03 +0000898$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800899 $(call pretty,"Target ramdisk: $@")
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900900 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
901ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
902 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
903endif
J. Avila3f6560e2020-05-11 20:20:03 +0000904 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800905
Bob Badourebdefc02022-02-12 15:39:22 -0800906$(call declare-1p-container,$(INSTALLED_RAMDISK_TARGET),)
907$(call declare-container-license-deps,$(INSTALLED_RAMDISK_TARGET),$(INTERNAL_RAMDISK_FILE),$(PRODUCT_OUT)/:/)
908
Justin Yundd15ec12022-09-23 10:47:21 +0900909UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -0800910
Ying Wangad7fd292013-08-08 16:34:29 -0700911.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000912ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700913 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000914 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800915
Dan Willemsen67495202019-01-16 12:42:05 -0800916endif # BUILDING_RAMDISK_IMAGE
917
The Android Open Source Project88b60792009-03-03 19:28:42 -0800918# -----------------------------------------------------------------
919# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700920
921# This is defined here since we may be building recovery as boot
922# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700923ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
924 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
925else
926 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
927endif
928
Yifan Hong0674a6e2020-10-22 14:37:01 -0700929INTERNAL_PREBUILT_BOOTIMAGE :=
930
931my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
932ifdef my_installed_prebuilt_gki_apex
933 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
934 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
935 endif # len(my_installed_prebuilt_gki_apex) > 1
936
937 ifdef BOARD_PREBUILT_BOOTIMAGE
938 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
939 endif # BOARD_PREBUILT_BOOTIMAGE defined
940
941 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
942 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
943 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
Bob Badoura60beee2022-09-07 15:34:12 -0700944 $(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 -0700945
946 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
947
948else # my_installed_prebuilt_gki_apex not defined
949
Steve Muckle04b6f052020-08-09 14:36:56 -0700950# $1: boot image target
951# returns the kernel used to make the bootimage
952define bootimage-to-kernel
953 $(if $(BOARD_KERNEL_BINARIES),\
954 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
955 $(INSTALLED_KERNEL_TARGET))
956endef
957
Steve Muckle903a1ca2020-05-07 17:32:10 -0700958ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
959 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
960endif
961
962# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800963# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700964define get-bootimage-partition-size
Peter Collingbourne730200e2022-02-16 13:32:53 -0800965$(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
966endef
967
968# $1: partition size
969define get-partition-size-argument
970 $(if $(1),--partition_size $(1),--dynamic_partition_size)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700971endef
Chris Grossa784ef12019-04-22 11:09:57 -0700972
celeste wange3d43202022-08-12 08:36:37 +0000973ifndef BOARD_PREBUILT_BOOTIMAGE
974
Chris Grossa784ef12019-04-22 11:09:57 -0700975ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800976INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700977 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700978
Bowgo Tsai85578e02022-04-19 10:50:59 +0800979# TODO(b/229701033): clean up BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK.
980ifneq ($(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +0800981 ifneq ($(BUILDING_INIT_BOOT_IMAGE),true)
982 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
Devin Moore380d9e42021-11-04 19:01:19 +0000983 endif
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700984endif
985
Steve Mucklee1b10862019-07-10 10:49:37 -0700986ifndef BUILDING_VENDOR_BOOT_IMAGE
987ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
988 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
989endif
990endif
991
The Android Open Source Project88b60792009-03-03 19:28:42 -0800992INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
993
Yifan Hong46aff092020-10-28 13:50:47 -0700994# kernel cmdline/base/pagesize in boot.
995# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
996# device-specific.
997# - If not using GKI:
998# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
999# - Otherwise, put them in boot.
1000ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07001001 ifdef GENERIC_KERNEL_CMDLINE
1002 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1003 endif
Yifan Hong46aff092020-10-28 13:50:47 -07001004else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
1005 ifdef INTERNAL_KERNEL_CMDLINE
1006 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1007 endif
1008 ifdef BOARD_KERNEL_BASE
1009 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1010 endif
1011 ifdef BOARD_KERNEL_PAGESIZE
1012 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1013 endif
1014endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -07001015
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001016ifdef BOARD_GKI_SIGNING_KEY_PATH
1017 # GKI boot images will not set system version & SPL value in the header.
1018 # They can be set by the device manufacturer in the AVB properties instead.
1019 INTERNAL_MKBOOTIMG_VERSION_ARGS :=
1020else
1021 INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -07001022 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +00001023 --os_patch_level $(PLATFORM_SECURITY_PATCH)
Bowgo Tsai662a2c62022-03-14 17:59:55 +08001024endif # BOARD_GKI_SIGNING_KEY_PATH
Sami Tolvanen3303d902016-03-15 16:49:30 +00001025
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001026# $(1): image target to certify
1027# $(2): out certificate target
1028# $(3): image name
1029# $(4): additional AVB arguments
1030define generate_generic_boot_image_certificate
1031 rm -rf "$(2)"
1032 mkdir -p "$(dir $(2))"
1033 $(GENERATE_GKI_CERTIFICATE) $(INTERNAL_GKI_CERTIFICATE_ARGS) \
1034 --additional_avb_args "$(4)" \
1035 --name "$(3)" --output "$(2)" "$(1)"
1036endef
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001037
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001038INTERNAL_GKI_CERTIFICATE_ARGS :=
1039INTERNAL_GKI_CERTIFICATE_DEPS :=
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001040ifdef BOARD_GKI_SIGNING_KEY_PATH
1041 ifndef BOARD_GKI_SIGNING_ALGORITHM
1042 $(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
1043 endif
1044
1045 INTERNAL_GKI_CERTIFICATE_ARGS := \
1046 --key "$(BOARD_GKI_SIGNING_KEY_PATH)" \
1047 --algorithm "$(BOARD_GKI_SIGNING_ALGORITHM)" \
1048 --avbtool "$(AVBTOOL)"
1049
1050 # Quote and pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string argument.
1051 ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
1052 INTERNAL_GKI_CERTIFICATE_ARGS += --additional_avb_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
1053 endif
1054
1055 INTERNAL_GKI_CERTIFICATE_DEPS := \
1056 $(GENERATE_GKI_CERTIFICATE) \
1057 $(BOARD_GKI_SIGNING_KEY_PATH) \
1058 $(AVBTOOL)
1059
Bowgo Tsai27c39b02021-03-12 21:40:32 +08001060endif
1061
Chris Grossa784ef12019-04-22 11:09:57 -07001062# Define these only if we are building boot
1063ifdef BUILDING_BOOT_IMAGE
1064INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1065
The Android Open Source Project88b60792009-03-03 19:28:42 -08001066ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -08001067$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001068endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -04001069
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001070$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
1071
1072ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -04001073
Steve Muckle04b6f052020-08-09 14:36:56 -07001074# $1: boot image target
1075define build_boot_board_avb_enabled
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001076 $(eval kernel := $(call bootimage-to-kernel,$(1)))
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001077 $(MKBOOTIMG) --kernel $(kernel) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001078 $(if $(BOARD_GKI_SIGNING_KEY_PATH), \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001079 $(eval boot_signature := $(call intermediates-dir-for,PACKAGING,generic_boot)/$(notdir $(1)).boot_signature) \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001080 $(eval kernel_signature := $(call intermediates-dir-for,PACKAGING,generic_kernel)/$(notdir $(kernel)).boot_signature) \
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001081 $(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 +08001082 $(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 +08001083 cat $(kernel_signature) >> $(boot_signature) $(newline) \
1084 $(call assert-max-image-size,$(boot_signature),16 << 10) $(newline) \
1085 truncate -s $$(( 16 << 10 )) $(boot_signature) $(newline) \
1086 cat "$(boot_signature)" >> $(1))
Yifan Hongebe65f82020-10-15 14:48:07 -07001087 $(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 -07001088 $(AVBTOOL) add_hash_footer \
1089 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001090 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) \
Steve Muckle04b6f052020-08-09 14:36:56 -07001091 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1092 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1093endef
1094
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001095$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001096 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001097 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -04001098
Bob Badoura60beee2022-09-07 15:34:12 -07001099$(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 -08001100$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES) $(INTERNAL_GKI_CERTIFICATE_DEPS),$(PRODUCT_OUT)/:/)
1101
Justin Yundd15ec12022-09-23 10:47:21 +09001102UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001103
David Zeuthen0eb10972016-09-28 17:55:27 -04001104.PHONY: bootimage-nodeps
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08001105bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(INTERNAL_GKI_CERTIFICATE_DEPS)
David Zeuthen0eb10972016-09-28 17:55:27 -04001106 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001107 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -04001108
hungweichenb2dd6832022-08-08 09:16:30 +00001109else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # BOARD_AVB_ENABLE != true
David Riley17be3d32015-03-03 08:54:11 -08001110
Steve Muckle04b6f052020-08-09 14:36:56 -07001111# $1: boot image target
1112define build_boot_supports_vboot
1113 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
1114 $(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 -07001115 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001116endef
1117
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001118$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001119 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001120 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -08001121
Bob Badoura60beee2022-09-07 15:34:12 -07001122$(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 -08001123$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1124
Justin Yundd15ec12022-09-23 10:47:21 +09001125UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001126
David Riley17be3d32015-03-03 08:54:11 -08001127.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001128bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001129 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001130 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -08001131
1132else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001133
Steve Muckle04b6f052020-08-09 14:36:56 -07001134# $1: boot image target
1135define build_boot_novboot
1136 $(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 -07001137 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001138endef
1139
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001140$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001141 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001142 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -07001143
Bob Badoura60beee2022-09-07 15:34:12 -07001144$(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 -08001145$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
1146
Justin Yundd15ec12022-09-23 10:47:21 +09001147UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001148
Ying Wangad7fd292013-08-08 16:34:29 -07001149.PHONY: bootimage-nodeps
1150bootimage-nodeps: $(MKBOOTIMG)
1151 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001152 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -07001153
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001154endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -07001155endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001156
Tao Baob1a2e352018-08-14 16:17:12 -07001157else # TARGET_NO_KERNEL == "true"
celeste wange3d43202022-08-12 08:36:37 +00001158INSTALLED_BOOTIMAGE_TARGET :=
1159endif # TARGET_NO_KERNEL
1160
1161else # BOARD_PREBUILT_BOOTIMAGE defined
Yifan Hong0674a6e2020-10-22 14:37:01 -07001162INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +09001163INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001164
1165ifeq ($(BOARD_AVB_ENABLE),true)
1166$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
1167 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1168 $(AVBTOOL) add_hash_footer \
1169 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001170 $(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001171 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1172 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001173
Bob Badoura60beee2022-09-07 15:34:12 -07001174$(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 -08001175$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_BOOTIMAGE),$(PRODUCT_OUT)/:/)
1176
Justin Yundd15ec12022-09-23 10:47:21 +09001177UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001178else
1179$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
1180 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1181endif # BOARD_AVB_ENABLE
1182
Tao Baob1a2e352018-08-14 16:17:12 -07001183endif # BOARD_PREBUILT_BOOTIMAGE
celeste wange3d43202022-08-12 08:36:37 +00001184
Yifan Hong0674a6e2020-10-22 14:37:01 -07001185endif # my_installed_prebuilt_gki_apex not defined
1186
1187my_apex_extracted_boot_image :=
1188my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001189
1190# -----------------------------------------------------------------
Devin Moore380d9e42021-11-04 19:01:19 +00001191# init boot image
1192ifeq ($(BUILDING_INIT_BOOT_IMAGE),true)
1193
1194INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1195$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_RAMDISK_TARGET)
1196
Yi-Yo Chiang8b0776d2022-06-30 17:33:29 +08001197INTERNAL_INIT_BOOT_IMAGE_ARGS := --ramdisk $(INSTALLED_RAMDISK_TARGET)
1198
Devin Moore380d9e42021-11-04 19:01:19 +00001199ifdef BOARD_KERNEL_PAGESIZE
1200 INTERNAL_INIT_BOOT_IMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1201endif
1202
1203ifeq ($(BOARD_AVB_ENABLE),true)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08001204$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
Devin Moore380d9e42021-11-04 19:01:19 +00001205 $(call pretty,"Target init_boot image: $@")
Yi-Yo Chiang2f7a1082022-02-22 19:13:32 +08001206 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output "$@"
Devin Moore380d9e42021-11-04 19:01:19 +00001207 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
1208 $(AVBTOOL) add_hash_footer \
1209 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001210 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001211 --partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1212 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001213
1214$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1215$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_GENERIC_RAMDISK_BOOT_SIGNATURE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001216else
1217$(INSTALLED_INIT_BOOT_IMAGE_TARGET):
1218 $(call pretty,"Target init_boot image: $@")
1219 $(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output $@
1220 $(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
Bob Badourebdefc02022-02-12 15:39:22 -08001221
1222$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001223endif
1224
Justin Yundd15ec12022-09-23 10:47:21 +09001225UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001226
Devin Moore380d9e42021-11-04 19:01:19 +00001227else # BUILDING_INIT_BOOT_IMAGE is not true
1228
1229ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
1230INTERNAL_PREBUILT_INIT_BOOT_IMAGE := $(BOARD_PREBUILT_INIT_BOOT_IMAGE)
1231INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
1232
1233ifeq ($(BOARD_AVB_ENABLE),true)
1234$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
1235 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
1236 $(AVBTOOL) add_hash_footer \
1237 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001238 $(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
Devin Moore380d9e42021-11-04 19:01:19 +00001239 --partition_name boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
1240 $(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08001241
1242$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
1243$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_PREBUILT_INIT_BOOT_IMAGE),$(PRODUCT_OUT)/:/)
Devin Moore380d9e42021-11-04 19:01:19 +00001244else
1245$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE)
1246 cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
Bob Badourebdefc02022-02-12 15:39:22 -08001247
1248$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
Devin Moore380d9e42021-11-04 19:01:19 +00001249endif # BOARD_AVB_ENABLE
1250
Justin Yundd15ec12022-09-23 10:47:21 +09001251UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08001252
Devin Moore380d9e42021-11-04 19:01:19 +00001253else # BOARD_PREBUILT_INIT_BOOT_IMAGE not defined
1254INSTALLED_INIT_BOOT_IMAGE_TARGET :=
1255endif # BOARD_PREBUILT_INIT_BOOT_IMAGE
1256
1257endif # BUILDING_INIT_BOOT_IMAGE is not true
Ramji Jiyani10655232022-01-20 06:43:09 +00001258
1259# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001260# vendor boot image
Colin Cross79a76ec2022-03-21 15:06:11 -07001261INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Steve Mucklee1b10862019-07-10 10:49:37 -07001262ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1263
Steve Mucklee1b10862019-07-10 10:49:37 -07001264INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
Steve Mucklee1b10862019-07-10 10:49:37 -07001265 $(ALL_DEFAULT_INSTALLED_MODULES))
1266
Petri Gynther6a6d6212021-03-06 00:45:53 -08001267INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001268
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001269# Exclude recovery files in the default vendor ramdisk if including a standalone
1270# recovery ramdisk in vendor_boot.
Yifan Hong881df392020-10-09 14:29:39 -07001271ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001272ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
Yifan Hong881df392020-10-09 14:29:39 -07001273$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1274$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1275endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001276endif
Yifan Hong881df392020-10-09 14:29:39 -07001277
J. Avila3f6560e2020-05-11 20:20:03 +00001278$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001279 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001280
Petri Gynther828828b2021-03-04 11:04:03 -08001281INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1282$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08001283 @echo "Target vendor ramdisk: $@"
Petri Gynther828828b2021-03-04 11:04:03 -08001284 $(copy-file-to-target)
Petri Gynther828828b2021-03-04 11:04:03 -08001285
Bob Badourebdefc02022-02-12 15:39:22 -08001286$(call declare-1p-container,$(INSTALLED_VENDOR_RAMDISK_TARGET),)
1287$(call declare-container-license-deps,$(INSTALLED_VENDOR_RAMDISK_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
1288
1289VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_RAMDISK_TARGET)
1290
Petri Gynther6ff52012020-11-20 11:59:41 -08001291INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1292INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1293$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1294$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1295$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001296 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001297 mkdir -p $(dir $@)
1298 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001299 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1300 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001301
Bob Badourebdefc02022-02-12 15:39:22 -08001302$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07001303$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08001304
Steve Mucklee1b10862019-07-10 10:49:37 -07001305ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Lucas Weif57333f2022-02-24 10:30:15 +08001306 ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1307 # If we have vendor_kernel_boot partition, we migrate dtb image to that image
1308 # and allow dtb in vendor_boot to be empty.
1309 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1310 endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001311endif
1312ifdef BOARD_KERNEL_BASE
1313 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1314endif
1315ifdef BOARD_KERNEL_PAGESIZE
1316 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1317endif
1318ifdef INTERNAL_KERNEL_CMDLINE
1319 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1320endif
1321
Devin Moore50509012021-01-13 10:45:04 -08001322ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001323 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1324 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001325 rm -f $@
1326 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1327 printf "%s\n" $(param) >> $@;)
1328 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1329endif
1330
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001331# $(1): Build target name
1332# $(2): Staging dir to be compressed
1333# $(3): Build dependencies
1334define build-vendor-ramdisk-fragment-target
1335$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1336 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1337endef
1338
1339# $(1): Ramdisk name
1340define build-vendor-ramdisk-fragment
1341$(strip \
1342 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1343 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1344 $(build_target) \
1345)
1346endef
1347
1348# $(1): Ramdisk name
1349# $(2): Prebuilt file path
1350define build-prebuilt-vendor-ramdisk-fragment
1351$(strip \
1352 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1353 $(eval $(call copy-one-file,$(2),$(build_target))) \
1354 $(build_target) \
1355)
1356endef
1357
1358INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1359INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1360
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001361$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001362 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1363 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1364 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1365 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001366 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001367 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1368 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1369)
1370
Steve Mucklee1b10862019-07-10 10:49:37 -07001371INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1372$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001373$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001374ifeq ($(BOARD_AVB_ENABLE),true)
1375$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1376 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001377 $(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 -07001378 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1379 $(AVBTOOL) add_hash_footer \
1380 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08001381 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Steve Mucklee1b10862019-07-10 10:49:37 -07001382 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1383 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1384else
1385$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1386 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001387 $(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 -07001388 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1389endif
Bob Badourebdefc02022-02-12 15:39:22 -08001390
1391$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
1392$(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)/:/)
1393VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001394endif # BUILDING_VENDOR_BOOT_IMAGE
1395
1396# -----------------------------------------------------------------
Lucas Weif57333f2022-02-24 10:30:15 +08001397# vendor kernel boot image
1398ifeq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
1399
1400INTERNAL_VENDOR_KERNEL_RAMDISK_FILES := $(filter $(TARGET_VENDOR_KERNEL_RAMDISK_OUT)/%, \
Lucas Weif57333f2022-02-24 10:30:15 +08001401 $(ALL_DEFAULT_INSTALLED_MODULES))
1402
1403INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_kernel_boot)/vendor_kernel_ramdisk.cpio$(RAMDISK_EXT)
1404
1405$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
1406 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
1407
1408INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_kernel_ramdisk.img
1409$(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1410 @echo "Target vendor kernel ramdisk: $@"
1411 $(copy-file-to-target)
1412
1413INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-kernel-ramdisk.txt
1414INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK:.txt=.json)
1415$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK)
1416$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1417$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
1418 @echo Installed file list: $@
1419 mkdir -p $(dir $@)
1420 rm -f $@
1421 $(FILESLIST) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) > $(@:.txt=.json)
1422 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
1423
Bob Badour5acd4362022-04-12 18:31:35 -07001424$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK))
1425$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK))
1426
Lucas Weif57333f2022-02-24 10:30:15 +08001427INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS := --vendor_ramdisk $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1428INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_kernel_boot.img
1429$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
1430
1431ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1432 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1433 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
1434endif
1435ifdef BOARD_KERNEL_PAGESIZE
1436 INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1437endif
1438
1439
1440ifeq ($(BOARD_AVB_ENABLE),true)
1441$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_KERNEL_BOOTIMAGE_KEY_PATH)
1442 $(call pretty,"Target vendor_kernel_boot image: $@")
1443 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1444 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1445 $(AVBTOOL) add_hash_footer \
1446 --image $@ \
1447 $(call get-partition-size-argument,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)) \
1448 --partition_name vendor_kernel_boot $(INTERNAL_AVB_VENDOR_KERNEL_BOOT_SIGNING_ARGS) \
1449 $(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)
1450else
1451$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):
1452 $(call pretty,"Target vendor_kernel_boot image: $@")
1453 $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
1454 $(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
1455endif
Bob Badour5acd4362022-04-12 18:31:35 -07001456$(call declare-1p-container,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
1457ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1458$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),\
1459 $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET),\
1460 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1461else
1462$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET),$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
1463endif
Lucas Weif57333f2022-02-24 10:30:15 +08001464endif # BUILDING_VENDOR_KERNEL_BOOT_IMAGE
1465
1466# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001467# NOTICE files
1468#
Steve Blockd14d3b42012-03-01 11:34:41 +00001469# We are required to publish the licenses for all code under BSD, GPL and
1470# Apache licenses (and possibly other more exotic ones as well). We err on the
1471# side of caution, so the licenses for other third-party code are included here
1472# too.
1473#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001474# This needs to be before the systemimage rules, because it adds to
1475# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1476# go into the systemimage.
1477
Steve Block495e5852012-02-29 19:18:08 +00001478.PHONY: notice_files
1479
Bob Badourebdefc02022-02-12 15:39:22 -08001480# Convert license metadata into xml notice file.
1481# $(1) - Output target notice filename
1482# $(2) - Product name
1483# $(3) - File title
1484# $(4) - License metadata file roots
1485# $(5) - Prefixes to strip
1486#
1487define xml-notice-rule
1488$(1): PRIVATE_PRODUCT := $(2)
1489$(1): PRIVATE_MESSAGE := $(3)
Bob Badour5acd4362022-04-12 18:31:35 -07001490$(1): PRIVATE_DEPS := $(call corresponding-license-metadata,$(4))
Bob Badourebdefc02022-02-12 15:39:22 -08001491$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badour5acd4362022-04-12 18:31:35 -07001492 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 -08001493
1494notice_files: $(1)
1495endef
1496
1497# Convert license metadata into text notice file.
1498# $(1) - Output target notice filename
1499# $(2) - Product name
1500# $(3) - File title
1501# $(4) - License metadata file roots
1502# $(5) - Prefixes to strip
1503#
1504define text-notice-rule
1505$(1): PRIVATE_PRODUCT := $(2)
1506$(1): PRIVATE_MESSAGE := $(3)
1507$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001508 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 -08001509
1510notice_files: $(1)
1511endef
1512
1513# Conversion license metadata into html notice file.
1514# $(1) - Output target notice filename
1515# $(2) - Product name
1516# $(3) - File title
1517# $(4) - License metadata file roots
1518# $(5) - Prefixes to strip
1519#
1520define html-notice-rule
1521$(1): PRIVATE_PRODUCT := $(2)
1522$(1): PRIVATE_MESSAGE := $(3)
1523$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
Bob Badourc778e4c2022-03-22 13:05:19 -07001524 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 -08001525
1526notice_files: $(1)
1527endef
1528
Bob Badour6259a092022-03-23 23:28:40 -07001529$(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 -08001530
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001531# Notice file logic isn't relevant for TARGET_BUILD_APPS
1532ifndef TARGET_BUILD_APPS
1533
The Android Open Source Project88b60792009-03-03 19:28:42 -08001534# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1535# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1536# the src subdirectory.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001537kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001538
Bob Badour4b25c902020-01-28 13:23:39 -08001539# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1540# reasons--not to be flashed onto any device. Targets under these directories
1541# need no associated notice file on the device UI.
1542exclude_target_dirs := apex
1543
Steven Morelandae69e572017-12-15 14:49:55 -08001544# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001545ifneq ($(PRODUCT_NOTICE_SPLIT),true)
Bob Badourebdefc02022-02-12 15:39:22 -08001546#target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001547target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1548installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
Bob Badour879cfa82021-04-15 10:41:38 -07001549
1550$(call declare-0p-target,$(target_notice_file_html_gz))
1551$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001552else
Bob Badourebdefc02022-02-12 15:39:22 -08001553# target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001554target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001555installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1556
1557target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001558target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1559installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001560
1561target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
Dario Freniadc972d2018-07-09 18:38:38 +01001562target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1563installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001564
Justin Yun6151e3f2019-06-25 15:58:13 +09001565target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
Justin Yun6151e3f2019-06-25 15:58:13 +09001566target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1567installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001568
Chris Gross15d96552019-07-16 14:38:43 -07001569target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
Chris Gross15d96552019-07-16 14:38:43 -07001570target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1571installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1572
Yifan Hong3d3f0302020-05-11 18:35:11 -07001573target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
Yifan Hong3d3f0302020-05-11 18:35:11 -07001574target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1575installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1576
Yifan Hongc83f9e92020-07-15 16:57:47 -07001577target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
Yifan Hongc83f9e92020-07-15 16:57:47 -07001578target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1579installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1580
Ramji Jiyani13a41372022-01-27 07:05:08 +00001581target_system_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.txt
Ramji Jiyani13a41372022-01-27 07:05:08 +00001582target_system_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.xml.gz
1583installed_system_dlkm_notice_xml_gz := $(TARGET_OUT_SYSTEM_DLKM)/etc/NOTICE.xml.gz
1584
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001585# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1586# being built. A notice xml file must depend on all modules that could potentially
1587# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001588license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001589# Only files copied to a system image need system image notices.
1590license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001591# Phonys/fakes don't have notice files (though their deps might)
1592license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001593# testcases are not relevant to the system image.
1594license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001595# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001596license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001597# system_other is relevant to system partition.
1598license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001599license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1600license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001601license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001602license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001603license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001604license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001605license_modules_odm_dlkm := $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001606license_modules_agg := $(license_modules_system) \
1607 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001608 $(license_modules_product) \
1609 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001610 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001611 $(license_modules_vendor_dlkm) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001612 $(license_modules_odm_dlkm) \
1613 $(license_modules_system_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001614# targets used for debug symbols only and do not get copied to the device
1615license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1616
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001617license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001618license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1619
1620# Identify the other targets we expect to have notices for:
1621# targets copied to the device but are not readable by the UI (e.g. must boot
1622# into a different partition to read or don't have an associated /etc
1623# directory) must have their notices built somewhere readable.
1624license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1625license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1626license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1627license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1628license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1629license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001630license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001631license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1632license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1633license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1634license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1635license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1636license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1637
1638# after removing targets in system images, targets reported in system images, and
1639# targets used for debug symbols that do not need notices, nothing must remain.
1640license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1641$(call maybe-print-list-and-error, $(license_modules_rest), \
1642 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001643
Chris Grossaad39b32019-06-13 09:43:26 -07001644# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1645# update its notice file, so include those notices in the system partition instead
1646ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001647license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001648system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1649system_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 -07001650else
Bob Badour4b25c902020-01-28 13:23:39 -08001651license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001652system_xml_directories := xml_system
1653system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001654endif
1655
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001656endif # PRODUCT_NOTICE_SPLIT
1657
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001658ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001659
Bob Badour56e0de52022-08-02 17:46:48 +00001660need_vendor_notice:=false
1661ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1662 need_vendor_notice:=true
1663endif
1664
1665ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
1666 need_vendor_notice:=true
1667endif
1668
1669ifdef BUILDING_VENDOR_IMAGE
1670 need_vendor_notice:=true
1671endif
1672
1673ifeq (true,$(need_vendor_notice))
1674ifneq (,$(installed_vendor_notice_xml_gz))
1675ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1676endif
1677endif
1678
1679need_vendor_notice:=
1680
1681ifdef BUILDING_ODM_IMAGE
1682ifneq (,$(installed_odm_notice_xml_gz))
1683ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
1684endif
1685endif
1686
1687ifdef BUILDING_PRODUCT_IMAGE
1688ifneq (,$(installed_product_notice_xml_gz))
1689ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1690endif
1691endif
1692
1693ifdef BUILDING_SYSTEM_EXT_IMAGE
1694ifneq (,$(installed_system_ext_notice_xml_gz))
1695ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1696endif
1697endif
1698
1699ifdef BUILDING_VENDOR_DLKM_IMAGE
1700ifneq (,$(installed_vendor_dlkm_notice_xml_gz)
1701ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
1702endif
1703endif
1704
1705ifdef BUILDING_ODM_DLKM_IMAGE
1706ifneq (,$(installed_odm_dlkm_notice_xml_gz))
1707ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
1708endif
1709endif
1710
1711ifdef BUILDING_SYSTEM_DLKM_IMAGE
1712ifneq (,$(installed_system_dlkm_notice_xml_gz))
1713ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_dlkm_notice_xml_gz)
1714endif
1715endif
1716
Ying Wang62c81f82013-08-22 20:02:03 -07001717endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001718
Bob Badoura60beee2022-09-07 15:34:12 -07001719# Presently none of the prebuilts etc. comply with policy to have a license text. Fake one here.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001720$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001721
Bob Badoura60beee2022-09-07 15:34:12 -07001722ifneq (,$(strip $(INSTALLED_KERNEL_TARGET)))
1723$(call declare-license-metadata,$(INSTALLED_KERNEL_TARGET),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
1724endif
Bob Badourebdefc02022-02-12 15:39:22 -08001725
Bob Badoura60beee2022-09-07 15:34:12 -07001726# No matter where it gets copied from, a copied linux kernel is licensed under "GPL 2.0 only"
1727$(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 -08001728
Doug Zongker8678df42009-06-15 14:30:14 -07001729
The Android Open Source Project88b60792009-03-03 19:28:42 -08001730# #################################################################
1731# Targets for user images
1732# #################################################################
1733
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001734# These options tell the recovery updater/installer how to mount the partitions writebale.
1735# <fstype>=<fstype_opts>[|<fstype_opts>]...
1736# fstype_opts := <opt>[,<opt>]...
1737# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001738# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1739DEFAULT_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 -07001740
Tao Baodba635a2019-06-24 10:39:54 -07001741INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001742 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001743 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001744 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001745
Bob Badour2f66fd12022-03-09 17:30:24 -08001746$(call declare-1p-target,$(MKE2FS_CONF),system/extras)
1747
Tao Baodba635a2019-06-24 10:39:54 -07001748ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1749INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001750endif
1751
Yifan Hongcfb917a2020-05-07 14:58:20 -07001752ifneq ($(filter \
1753 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1754 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1755 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1756 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1757 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1758 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001759 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001760 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001761 ,erofs),)
David Anderson94ad5bb2022-03-04 10:57:58 -08001762INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
David Andersonf54665f2022-03-04 14:42:18 -08001763ifeq ($(BOARD_EROFS_USE_LEGACY_COMPRESSION),true)
1764BOARD_EROFS_COMPRESSOR ?= "lz4"
1765else
Kelvin Zhang37d49292021-12-01 14:21:24 -08001766BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
Gao Xiang961041a2020-06-17 13:59:16 +08001767endif
David Andersonf54665f2022-03-04 14:42:18 -08001768endif
Gao Xiang961041a2020-06-17 13:59:16 +08001769
1770ifneq ($(filter \
1771 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1772 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1773 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1774 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1775 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1776 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1777 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00001778 $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001779 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001780INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1781endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001782
Tao Baodba635a2019-06-24 10:39:54 -07001783ifeq ($(BOARD_AVB_ENABLE),true)
1784INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1785endif
1786
1787# Get a colon-separated list of search paths.
1788INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1789
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001790# Collects file_contexts files from modules to be installed
1791$(call merge-fc-files, \
1792 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1793 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1794
Alex Klyubin092c9022017-03-13 13:28:34 -07001795SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001796
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001797INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1798
David Anderson707e6f52021-09-21 22:24:43 -07001799# $(1) the partition name (eg system)
1800# $(2) the image prop file
1801define add-common-flags-to-image-props
1802$(eval _var := $(call to-upper,$(1)))
1803$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
1804$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
1805endef
1806
1807# $(1) the partition name (eg system)
1808# $(2) the image prop file
1809define add-common-ro-flags-to-image-props
1810$(eval _var := $(call to-upper,$(1)))
David Anderson64b351b2021-10-13 00:20:43 -07001811$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001812$(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 -07001813$(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 -07001814$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
1815$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
1816$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
1817$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
1818$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
1819$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
1820$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
1821$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
1822$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
1823$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
1824$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
1825$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
1826$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
1827$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
1828$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
1829$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
David Anderson5f4aa6c2021-09-23 17:03:14 -07001830$(if $(or $(_size), $(_reserved), $(_headroom)),,
1831 $(hide) echo "$(1)_disable_sparse=true" >> $(2))
David Anderson707e6f52021-09-21 22:24:43 -07001832$(call add-common-flags-to-image-props,$(1),$(2))
David Anderson9e95a022021-08-31 21:32:45 -07001833endef
1834
Ying Wangbd93d422011-10-28 17:02:30 -07001835# $(1): the path of the output dictionary file
Ramji Jiyani13a41372022-01-27 07:05:08 +00001836# $(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 -07001837# $(3): additional "key=value" pairs to append to the dictionary file.
1838define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001839$(if $(filter $(2),system),\
Bowgo Tsai867ab662019-01-29 13:30:18 +08001840 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001841 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001842 $(call add-common-ro-flags-to-image-props,system,$(1))
Chris Gross203191b2020-05-30 02:39:12 +00001843)
1844$(if $(filter $(2),system_other),\
1845 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
David Anderson9e95a022021-08-31 21:32:45 -07001846 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
1847 $(hide) echo "system_other_disable_sparse=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001848)
Yifan Hong760d3c02018-05-30 11:16:46 -07001849$(if $(filter $(2),userdata),\
1850 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1851 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001852 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1853 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kim55c16dd2020-10-12 19:50:05 -07001854 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001855 $(call add-common-flags-to-image-props,userdata,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001856)
Yifan Hong760d3c02018-05-30 11:16:46 -07001857$(if $(filter $(2),cache),\
1858 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1859 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001860 $(call add-common-flags-to-image-props,cache,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001861)
1862$(if $(filter $(2),vendor),\
David Anderson707e6f52021-09-21 22:24:43 -07001863 $(call add-common-ro-flags-to-image-props,vendor,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001864)
1865$(if $(filter $(2),product),\
David Anderson707e6f52021-09-21 22:24:43 -07001866 $(call add-common-ro-flags-to-image-props,product,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001867)
Justin Yun6151e3f2019-06-25 15:58:13 +09001868$(if $(filter $(2),system_ext),\
David Anderson707e6f52021-09-21 22:24:43 -07001869 $(call add-common-ro-flags-to-image-props,system_ext,$(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001870)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001871$(if $(filter $(2),odm),\
David Anderson707e6f52021-09-21 22:24:43 -07001872 $(call add-common-ro-flags-to-image-props,odm,$(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001873)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001874$(if $(filter $(2),vendor_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001875 $(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001876)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001877$(if $(filter $(2),odm_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001878 $(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001879)
Ramji Jiyani13a41372022-01-27 07:05:08 +00001880$(if $(filter $(2),system_dlkm),\
1881 $(call add-common-ro-flags-to-image-props,system_dlkm,$(1))
1882)
Yifan Hong760d3c02018-05-30 11:16:46 -07001883$(if $(filter $(2),oem),\
1884 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1885 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1886 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1887 $(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 -07001888 $(call add-common-flags-to-image-props,oem,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001889)
Tao Bao3602eca2018-07-10 10:53:55 -07001890$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001891
Cole Faust8fc7bef2022-06-15 16:10:49 -07001892$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT2)),$(hide) echo "fs_type=ext2" >> $(1),
1893 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT3)),$(hide) echo "fs_type=ext3" >> $(1),
1894 $(if $(filter true,$(TARGET_USERIMAGES_USE_EXT4)),$(hide) echo "fs_type=ext4" >> $(1))))
1895
1896$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)),,$(hide) echo "extfs_sparse_flag=-s" >> $(1))
1897$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED)),,$(hide) echo "erofs_sparse_flag=-s" >> $(1))
1898$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)),,$(hide) echo "squashfs_sparse_flag=-s" >> $(1))
1899$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)),,$(hide) echo "f2fs_sparse_flag=-S" >> $(1))
David Anderson40a821f2021-09-22 18:02:01 -07001900$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
Dmitrii Merkurev8ab66032022-05-17 23:10:37 +00001901$(if $(BOARD_EROFS_COMPRESS_HINTS),$(hide) echo "erofs_default_compress_hints=$(BOARD_EROFS_COMPRESS_HINTS)" >> $(1))
David Anderson64b351b2021-10-13 00:20:43 -07001902$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
1903$(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 -08001904$(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 -07001905$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1906$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1907$(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 +08001908$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001909$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1910$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1911$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001912$(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 -07001913$(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 -07001914$(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 +00001915$(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 +00001916$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1917$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1918$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1919$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1920$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001921$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001922$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1923$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1924$(if $(BOARD_AVB_ENABLE),\
1925 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1926 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1927 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1928 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001929$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1930$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1931$(if $(BOARD_AVB_ENABLE),\
1932 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1933 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001934 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001935$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1936$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1937$(if $(BOARD_AVB_ENABLE),\
1938 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1939 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1940 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1941 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001942$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1943$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1944$(if $(BOARD_AVB_ENABLE),\
1945 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1946 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1947 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1948 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001949$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001950$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001951 $(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 +01001952$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001953 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1954 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1955 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1956 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001957$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1958$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1959$(if $(BOARD_AVB_ENABLE),\
1960 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1961 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1962 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1963 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001964$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1965$(if $(BOARD_AVB_ENABLE),\
1966 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1967$(if $(BOARD_AVB_ENABLE),\
1968 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1969 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1970 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1971 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001972$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1973$(if $(BOARD_AVB_ENABLE),\
1974 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1975$(if $(BOARD_AVB_ENABLE),\
1976 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1977 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1978 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1979 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Ramji Jiyani13a41372022-01-27 07:05:08 +00001980$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1981$(if $(BOARD_AVB_ENABLE),\
1982 $(hide) echo "avb_system_dlkm_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1983$(if $(BOARD_AVB_ENABLE),\
1984 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
1985 $(hide) echo "avb_system_dlkm_key_path=$(BOARD_AVB_SYSTEM_DLKM_KEY_PATH)" >> $(1)
1986 $(hide) echo "avb_system_dlkm_algorithm=$(BOARD_AVB_SYSTEM_DLKM_ALGORITHM)" >> $(1)
1987 $(hide) echo "avb_system_dlkm_rollback_index_location=$(BOARD_SYSTEM_SYSTEM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001988$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1989 $(hide) echo "recovery_as_boot=true" >> $(1))
Bowgo Tsai85578e02022-04-19 10:50:59 +08001990$(if $(filter true,$(BOARD_BUILD_GKI_BOOT_IMAGE_WITHOUT_RAMDISK)),\
1991 $(hide) echo "gki_boot_image_without_ramdisk=true" >> $(1))
Tom Cherryd14b8952018-08-09 14:26:00 -07001992$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001993$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1994 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001995$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1996endef
1997
1998# $(1): the path of the output dictionary file
1999# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07002000PROP_DICTIONARY_IMAGES := oem
2001ifdef BUILDING_CACHE_IMAGE
2002 PROP_DICTIONARY_IMAGES += cache
2003endif
2004ifdef BUILDING_SYSTEM_IMAGE
2005 PROP_DICTIONARY_IMAGES += system
2006endif
Chris Gross203191b2020-05-30 02:39:12 +00002007ifdef BUILDING_SYSTEM_OTHER_IMAGE
2008 PROP_DICTIONARY_IMAGES += system_other
2009endif
Daniel Norman72c626f2019-05-13 15:58:14 -07002010ifdef BUILDING_USERDATA_IMAGE
2011 PROP_DICTIONARY_IMAGES += userdata
2012endif
2013ifdef BUILDING_VENDOR_IMAGE
2014 PROP_DICTIONARY_IMAGES += vendor
2015endif
2016ifdef BUILDING_PRODUCT_IMAGE
2017 PROP_DICTIONARY_IMAGES += product
2018endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002019ifdef BUILDING_SYSTEM_EXT_IMAGE
2020 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07002021endif
2022ifdef BUILDING_ODM_IMAGE
2023 PROP_DICTIONARY_IMAGES += odm
2024endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002025ifdef BUILDING_VENDOR_DLKM_IMAGE
2026 PROP_DICTIONARY_IMAGES += vendor_dlkm
2027endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07002028ifdef BUILDING_ODM_DLKM_IMAGE
2029 PROP_DICTIONARY_IMAGES += odm_dlkm
2030endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00002031ifdef BUILDING_SYSTEM_DLKM_IMAGE
2032 PROP_DICTIONARY_IMAGES += system_dlkm
2033endif
Yifan Hong760d3c02018-05-30 11:16:46 -07002034define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07002035 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07002036endef
2037
Yifan Hongbbcba1e2018-06-18 16:32:35 -07002038# $(1): the path of the input dictionary file, where each line has the format key=value
2039# $(2): the key to look up
2040define read-image-prop-dictionary
2041$$(grep '$(2)=' $(1) | cut -f2- -d'=')
2042endef
2043
The Android Open Source Project88b60792009-03-03 19:28:42 -08002044# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07002045# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07002046
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002047# Recovery image exists if we are building recovery, or building recovery as boot.
Colin Cross79a76ec2022-03-21 15:06:11 -07002048INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RECOVERY_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Chris Grossa784ef12019-04-22 11:09:57 -07002049ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002050
Ying Wang37526142015-03-10 12:02:57 -07002051INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
2052 $(ALL_DEFAULT_INSTALLED_MODULES))
2053
Tao Bao10fc9492018-08-14 12:17:48 -07002054INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
2055INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
2056
Colin Cross359f4212020-12-02 15:14:04 -08002057ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2058INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
2059endif
2060
Tao Bao10fc9492018-08-14 12:17:48 -07002061# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
2062# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
2063# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
2064# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08002065$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07002066
2067$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002068$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07002069 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002070 mkdir -p $(dir $@)
2071 rm -f $@
2072 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
2073 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07002074
Bob Badour5acd4362022-04-12 18:31:35 -07002075$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RECOVERY)))
2076$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RECOVERY)))
2077
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002078recovery_sepolicy := \
2079 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07002080 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002081 $(TARGET_RECOVERY_ROOT_OUT)/plat_service_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002082 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002083 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002084 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_service_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08002085 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
2086 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002087 $(TARGET_RECOVERY_ROOT_OUT)/vendor_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002088 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08002089 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002090 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
2091 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
Yifan Hong276b8c02021-11-13 00:23:44 -08002092 $(TARGET_RECOVERY_ROOT_OUT)/product_service_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08002093 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08002094
Alex Klyubin2a7171a2017-03-10 12:53:02 -08002095# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
2096# SELinux files
2097IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
2098
Steve Muckle04b6f052020-08-09 14:36:56 -07002099# if building multiple boot images from multiple kernels, use the first kernel listed
2100# for the recovery image
2101recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002102recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07002103recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08002104
Anton Hansson45a40da2019-01-18 14:06:34 +00002105# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
2106# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
2107# which get remapped to a bucket.
2108recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07002109ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
2110recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00002111# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07002112# ------160------240------320----------480------------640------
2113# mdpi hdpi xhdpi xxhdpi xxxhdpi
2114recovery_density := $(strip \
2115 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
2116 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
2117 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
2118 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07002119endif
2120
2121ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
2122recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
2123else
Doug Zongker25d55f82014-04-04 13:51:15 -07002124recovery_resources_common := $(recovery_resources_common)-xhdpi
2125endif
2126
Tao Baoe1e829e2018-08-29 20:36:00 -07002127# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
2128# Note that the font selected here can be overridden for a particular device by putting a font.png
2129# in its private recovery resources.
2130ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07002131recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08002132else
Dan Willemsen97672232020-05-27 00:09:16 -07002133recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08002134endif
2135
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002136
2137# We will only generate the recovery background text images if the variable
2138# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
2139# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
2140# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
2141# BoardConfig in order to use this feature.
2142ifeq ($(recovery_density),xxxhdpi)
2143TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
2144else ifeq ($(recovery_density),xxhdpi)
2145TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
2146endif
2147
2148ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
2149# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
2150ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
2151 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
2152else
2153 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
2154endif
2155
2156
Dan Willemsen97672232020-05-27 00:09:16 -07002157RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002158RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
2159RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
2160RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
2161RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
2162
xunchangcc57d312018-12-07 12:12:17 -08002163RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
2164RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
2165RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
2166RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
2167RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
2168
2169generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002170 $(RECOVERY_INSTALLING_TEXT_FILE) \
2171 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
2172 $(RECOVERY_ERASING_TEXT_FILE) \
2173 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08002174 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
2175 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
2176 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
2177 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
2178 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
2179 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002180
Dan Willemsen97672232020-05-27 00:09:16 -07002181resource_dir := bootable/recovery/tools/recovery_l10n/res/
2182resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002183image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08002184zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002185$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07002186$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002187$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
2188$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08002189$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002190$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08002191$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002192 recovery_installing \
2193 recovery_installing_security \
2194 recovery_erasing \
2195 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08002196 recovery_no_command
2197$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08002198 recovery_cancel_wipe_data \
2199 recovery_factory_data_reset \
2200 recovery_try_again \
2201 recovery_wipe_data_menu_header \
2202 recovery_wipe_data_confirmation
2203$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07002204$(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 -08002205 # Prepares the font directory.
2206 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
2207 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08002208 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002209 @rm -rf $(dir $@)
2210 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08002211 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08002212 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08002213 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002214 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
2215 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
2216 --text_name $(text_name) \
2217 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2218 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002219 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002220 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002221else
2222RECOVERY_INSTALLING_TEXT_FILE :=
2223RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2224RECOVERY_ERASING_TEXT_FILE :=
2225RECOVERY_ERROR_TEXT_FILE :=
2226RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002227RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2228RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2229RECOVERY_TRY_AGAIN_TEXT_FILE :=
2230RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2231RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002232endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2233
Ying Wang9a175682015-08-06 11:47:47 -07002234ifndef TARGET_PRIVATE_RES_DIRS
2235TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2236endif
Doug Zongker4647f122009-07-02 09:00:54 -07002237recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002238 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002239recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002240
2241
Andrew Boiefa61ff02012-09-28 09:33:45 -07002242ifdef TARGET_RECOVERY_FSTAB
2243recovery_fstab := $(TARGET_RECOVERY_FSTAB)
Cole Faust64c2ddb2022-01-07 12:44:31 -08002244else ifdef TARGET_RECOVERY_FSTAB_GENRULE
2245# Specifies a soong genrule module that generates an fstab.
2246recovery_fstab := $(call intermediates-dir-for,ETC,$(TARGET_RECOVERY_FSTAB_GENRULE))/$(TARGET_RECOVERY_FSTAB_GENRULE)
Andrew Boiefa61ff02012-09-28 09:33:45 -07002247else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002248recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002249endif
Tao Baoc3c17532016-06-10 10:11:54 -07002250ifdef TARGET_RECOVERY_WIPE
2251recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002252else
Tao Baoc3c17532016-06-10 10:11:54 -07002253recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002254endif
Tao Bao8beab692015-07-22 12:33:18 -07002255
Tao Bao6d5d6232018-03-09 17:04:42 -08002256# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002257# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002258# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2259# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002260#
2261# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002262# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002263# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002264# b) We build a single image that contains boot and recovery both - no recovery image to install
2265# (BOARD_USES_RECOVERY_AS_BOOT = true);
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002266# c) We include the recovery DTBO image within recovery - not needing the resource file as we
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002267# do bsdiff because boot and recovery will contain different number of entries
2268# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002269# d) We include the recovery ACPIO image within recovery - not needing the resource file as we
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002270# do bsdiff because boot and recovery will contain different number of entries
2271# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002272# e) We build a single image that contains vendor_boot and recovery both - no recovery image to
Yifan Hongef7a9712020-10-20 13:17:42 -07002273# install
2274# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002275
Tom Cherry2929cad2018-09-20 11:04:37 -07002276ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002277 $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002278 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002279# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002280RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2281ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002282else
Tao Bao8beab692015-07-22 12:33:18 -07002283RECOVERY_RESOURCE_ZIP :=
2284endif
Doug Zongker4647f122009-07-02 09:00:54 -07002285
Tao Bao139c7272018-07-31 13:26:54 -07002286INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2287
2288$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002289 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2290 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2291 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2292 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2293 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2294 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2295 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2296 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2297
2298# Parses the given list of build variables and writes their values as build properties if defined.
2299# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2300# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2301# $(1): Map from the build variable names to property names
2302# $(2): Output file
2303define append-recovery-ui-properties
2304echo "#" >> $(2)
2305echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2306echo "#" >> $(2)
2307$(foreach prop,$(1), \
2308 $(eval _varname := $(call word-colon,1,$(prop))) \
2309 $(eval _propname := $(call word-colon,2,$(prop))) \
2310 $(eval _value := $($(_varname))) \
2311 $(if $(_value), \
2312 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2313endef
2314
2315$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002316 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002317 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2318 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2319 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002320 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002321 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002322 $(hide) mkdir -p $(dir $@)
2323 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002324 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002325 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002326 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002327 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002328 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002329 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2330
Bob Badour5acd4362022-04-12 18:31:35 -07002331$(call declare-1p-target,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),build)
2332$(call declare-license-deps,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),\
2333 $(INSTALLED_BUILD_PROP_TARGET) $(INSTALLED_VENDOR_BUILD_PROP_TARGET) $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2334 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET))
2335
Yifan Hong33fd5d42020-09-24 18:18:26 -07002336# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2337# On device with dedicated recovery partition, the file should come from the boot
2338# ramdisk.
2339ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2340INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2341$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2342 $(copy-file-to-target)
Bob Badour5acd4362022-04-12 18:31:35 -07002343
2344$(call declare-1p-target,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),build)
2345$(call declare-license-deps,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),$(INSTALLED_RAMDISK_BUILD_PROP_TARGET))
Yifan Hong33fd5d42020-09-24 18:18:26 -07002346endif
2347
Yifan Hongc56931c2020-10-28 16:35:19 -07002348INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002349
Yifan Hong78860162020-10-28 14:15:21 -07002350ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002351INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002352# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002353ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002354ifdef INTERNAL_KERNEL_CMDLINE
2355 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002356endif # INTERNAL_KERNEL_CMDLINE != ""
2357endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002358ifdef BOARD_KERNEL_BASE
2359 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2360endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002361ifdef BOARD_KERNEL_PAGESIZE
2362 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2363endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002364ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002365ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2366 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2367else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002368 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2369endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002370endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002371ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2372 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2373endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002374ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2375 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2376endif
Yifan Hong3941a872020-10-28 16:33:06 -07002377endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002378ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2379 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2380endif
Doug Zongker4647f122009-07-02 09:00:54 -07002381
Yifan Hong881df392020-10-09 14:29:39 -07002382$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002383 $(INTERNAL_ROOT_FILES) \
2384 $(INSTALLED_RAMDISK_TARGET) \
2385 $(INTERNAL_RECOVERYIMAGE_FILES) \
2386 $(recovery_sepolicy) \
2387 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2388 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002389 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002390 $(recovery_resource_deps) \
2391 $(recovery_fstab)
2392 # Making recovery image
2393 mkdir -p $(TARGET_RECOVERY_OUT)
2394 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2395 # Copying baseline ramdisk...
2396 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2397 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2398 # Modifying ramdisk contents...
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08002399 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init
Steve Muckleb3dda772020-03-11 16:03:07 -07002400 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2401 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2402 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2403 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2404 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2405 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2406 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2407 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2408 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2409 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2410 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2411 $(foreach item,$(recovery_fstab), \
2412 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2413 $(if $(strip $(recovery_wipe)), \
2414 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2415 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2416 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002417 $(hide) touch $@
2418
2419$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002420 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002421
Ying Wang747b9f12015-01-30 14:05:22 -08002422# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002423# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002424define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002425 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002426 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002427 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002428 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002429 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002430 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002431 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002432 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2433 $(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 +08002434 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002435 $(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 -07002436 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002437 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2438 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002439 $(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),\
2440 $(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 -08002441endef
2442
Dan Willemsend120ac62020-06-12 02:39:34 +00002443recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002444ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002445 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002446endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002447ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002448 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002449endif
Tao Baof4866c72018-08-22 14:35:09 -07002450ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002451 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2452 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2453 else
2454 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2455 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002456endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002457ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002458 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002459endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002460ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002461 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002462endif
Tao Baof4866c72018-08-22 14:35:09 -07002463
Dan Willemsend120ac62020-06-12 02:39:34 +00002464ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002465$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002466$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002467 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002468 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Bob Badourebdefc02022-02-12 15:39:22 -08002469
Bob Badoura60beee2022-09-07 15:34:12 -07002470$(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 -08002471$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2472
Justin Yundd15ec12022-09-23 10:47:21 +09002473UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BOOTIMAGE_TARGET)
Tao Baof4866c72018-08-22 14:35:09 -07002474endif # BOARD_USES_RECOVERY_AS_BOOT
2475
Dan Willemsend120ac62020-06-12 02:39:34 +00002476$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002477 $(call build-recoveryimage-target, $@, \
2478 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002479
Tao Bao4594d0e2015-12-22 09:47:46 -08002480ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002481$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002482 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002483 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2484 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002485endif
Doug Zongker56588872012-08-20 15:38:58 -07002486
Bob Badourebdefc02022-02-12 15:39:22 -08002487
2488$(call declare-1p-container,$(INSTALLED_RECOVERYIMAGE_TARGET),)
2489$(call declare-container-license-deps,$(INSTALLED_RECOVERYIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
2490
Justin Yundd15ec12022-09-23 10:47:21 +09002491UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_RECOVERYIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002492
Ying Wang747b9f12015-01-30 14:05:22 -08002493.PHONY: recoveryimage-nodeps
2494recoveryimage-nodeps:
2495 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002496 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2497 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002498
Chris Grossa784ef12019-04-22 11:09:57 -07002499else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002500RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002501endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002502
2503.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002504recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002505
Jiyong Park03eb0612017-10-04 21:22:41 +09002506ifneq ($(BOARD_NAND_PAGE_SIZE),)
2507$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002508endif
2509
Jiyong Park03eb0612017-10-04 21:22:41 +09002510ifneq ($(BOARD_NAND_SPARE_SIZE),)
2511$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002512endif
2513
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002514
Doug Zongker4647f122009-07-02 09:00:54 -07002515# -----------------------------------------------------------------
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002516# Build debug ramdisk and debug boot image.
Colin Cross79a76ec2022-03-21 15:06:11 -07002517INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002518ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
2519
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002520INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002521 $(ALL_DEFAULT_INSTALLED_MODULES))
2522
2523# Directories to be picked into the debug ramdisk.
2524# As these directories are all merged into one single cpio archive, the order
2525# matters. If there are multiple files with the same pathname, then the last one
2526# wins.
2527#
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002528# ramdisk-debug.img will merge the content from either ramdisk.img or
2529# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
2530# is set or not.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002531ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002532 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT)
2533 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002534else # BOARD_USES_RECOVERY_AS_BOOT == true
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002535 INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT)
2536 INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002537endif # BOARD_USES_RECOVERY_AS_BOOT != true
2538
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002539INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT)
2540INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES)
2541
2542# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
2543INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2544INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2545$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2546$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS)
2547$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2548 @echo "Installed file list: $@"
2549 $(hide) rm -f $@
2550 $(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT)
2551 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
2552 $(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2553 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2554
Bob Badourebdefc02022-02-12 15:39:22 -08002555$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_DEBUG_RAMDISK)))
Bob Badour5acd4362022-04-12 18:31:35 -07002556$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_DEBUG_RAMDISK)))
Bob Badourebdefc02022-02-12 15:39:22 -08002557
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002558ifdef BUILDING_DEBUG_BOOT_IMAGE
2559
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002560# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002561# the debug ramdisk, which is the original ramdisk plus additional
2562# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2563# When /force_debuggable is present, /init will load userdebug sepolicy
2564# and property files to allow adb root, if the device is unlocked.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002565INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
Bowgo Tsai0013f552019-03-20 17:59:52 +08002566
Bowgo Tsai610286a2021-04-23 11:31:32 +08002567$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002568$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2569 @echo "Target debug ramdisk: $@"
2570 $(hide) rm -f $@
2571 $(hide) mkdir -p $(dir $@)
2572 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002573
Bob Badourebdefc02022-02-12 15:39:22 -08002574$(call declare-1p-container,$(INSTALLED_DEBUG_RAMDISK_TARGET),)
2575$(call declare-container-license-deps,$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2576
Justin Yundd15ec12022-09-23 10:47:21 +09002577UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002578
Bowgo Tsai0013f552019-03-20 17:59:52 +08002579.PHONY: ramdisk_debug-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002580ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002581 @echo "make $@: ignoring dependencies"
2582 $(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET)
2583 $(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS)
2584 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002585
2586# -----------------------------------------------------------------
2587# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2588#
2589# Note: it's intentional to skip signing for boot-debug.img, because it
2590# can only be used if the device is unlocked with verification error.
Steve Muckleb3dda772020-03-11 16:03:07 -07002591ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002592 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002593 $(PRODUCT_OUT)/$(k).img)
2594else
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002595 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
Steve Muckleb3dda772020-03-11 16:03:07 -07002596endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002597
2598# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002599$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002600ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002601 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 +08002602else
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002603 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 +08002604endif
2605
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002606# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2607# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2608# Using a test key to sign boot-debug.img to continue booting with the mismatched
2609# public key, if the device is unlocked.
2610ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002611$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002612endif
2613
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002614BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2615INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2616# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002617# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002618define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002619$(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 +08002620$(AVBTOOL) add_hash_footer \
2621 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002622 $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),$(2)))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002623 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2624 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002625$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002626endef
2627
Steve Muckleb3dda772020-03-11 16:03:07 -07002628# $(1): output file
2629define build-debug-bootimage-target
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002630 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002631 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002632 $(BOARD_MKBOOTIMG_ARGS) --output $1
Yi-Yo Chiangffb366e2021-10-14 16:56:00 +08002633 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
Steve Muckleb3dda772020-03-11 16:03:07 -07002634endef
2635
Bowgo Tsai0013f552019-03-20 17:59:52 +08002636# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002637$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002638 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002639 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002640
Bob Badoura60beee2022-09-07 15:34:12 -07002641$(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 -08002642$(call declare-container-license-deps,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(INSTALLED_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2643
Justin Yundd15ec12022-09-23 10:47:21 +09002644UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002645
Bowgo Tsai0013f552019-03-20 17:59:52 +08002646.PHONY: bootimage_debug-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002647bootimage_debug-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002648 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002649 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002650
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002651endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002652
Bowgo Tsai6a683672020-02-14 19:00:15 +08002653# -----------------------------------------------------------------
2654# vendor debug ramdisk
2655# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Colin Cross79a76ec2022-03-21 15:06:11 -07002656INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002657ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2658
Bowgo Tsai610286a2021-04-23 11:31:32 +08002659INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
Bowgo Tsai610286a2021-04-23 11:31:32 +08002660 $(ALL_DEFAULT_INSTALLED_MODULES))
2661
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002662# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk.
2663INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT)
2664INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002665
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002666# Exclude recovery files in the default vendor ramdisk if including a standalone
2667# recovery ramdisk in vendor_boot.
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002668ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002669 ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2670 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT)
2671 INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
2672 endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true
2673endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002674
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002675INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT)
2676INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
2677
2678# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created.
2679INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2680INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2681$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2682$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS)
2683$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
2684 @echo "Installed file list: $@"
2685 $(hide) rm -f $@
2686 $(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2687 $(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
2688 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2689
Bob Badour5acd4362022-04-12 18:31:35 -07002690$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK))
2691$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK))
Bob Badourebdefc02022-02-12 15:39:22 -08002692
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002693INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
2694
Bowgo Tsai610286a2021-04-23 11:31:32 +08002695$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002696$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2697 $(hide) rm -f $@
2698 $(hide) mkdir -p $(dir $@)
2699 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002700
Petri Gyntherd7946d12021-03-10 12:38:15 -08002701INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2702$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002703 @echo "Target debug vendor ramdisk: $@"
Petri Gyntherd7946d12021-03-10 12:38:15 -08002704 $(copy-file-to-target)
Petri Gyntherd7946d12021-03-10 12:38:15 -08002705
Bob Badourebdefc02022-02-12 15:39:22 -08002706$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),)
2707$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2708
2709VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2710
Bowgo Tsai6a683672020-02-14 19:00:15 +08002711# -----------------------------------------------------------------
2712# vendor_boot-debug.img.
2713INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2714
2715# The util to sign vendor_boot-debug.img with a test key.
2716BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2717INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2718# $(1): the vendor bootimage to sign
2719define test-key-sign-vendor-bootimage
2720$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2721$(AVBTOOL) add_hash_footer \
2722 --image $(1) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08002723 $(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
Bowgo Tsai6a683672020-02-14 19:00:15 +08002724 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2725 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2726$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2727endef
2728
2729ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2730$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2731endif
2732
2733# 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 +08002734$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002735$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002736 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002737 $(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 +08002738 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2739 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2740
Bob Badourebdefc02022-02-12 15:39:22 -08002741$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),)
2742$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2743
2744VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
2745
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002746endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai6a683672020-02-14 19:00:15 +08002747
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002748# Appends a few test harness specific properties into the adb_debug.prop.
2749ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2750ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2751
2752INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES)))
2753INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2754$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET)
2755 $(hide) rm -f $@
2756 $(hide) mkdir -p $(dir $@)
2757ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET
2758 $(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@
2759endif
2760 $(hide) echo "" >> $@
2761 $(hide) echo "#" >> $@
2762 $(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@
2763 $(hide) echo "#" >> $@
2764 $(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \
2765 echo "$(line)" >> $@;)
2766
Bob Badour2f66fd12022-03-09 17:30:24 -08002767$(call declare-1p-target,$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET))
2768
Colin Cross79a76ec2022-03-21 15:06:11 -07002769INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002770INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
2771 $(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002772 $(ALL_DEFAULT_INSTALLED_MODULES))
2773
2774# The order is important here. The test harness ramdisk staging directory has to
2775# come last so that it can override the adb_debug.prop in the debug ramdisk
2776# staging directory.
2777INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2778INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
2779
2780ifdef BUILDING_DEBUG_BOOT_IMAGE
2781
Bowgo Tsai0013f552019-03-20 17:59:52 +08002782# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002783# The test harness ramdisk, which is based off debug_ramdisk, plus a
2784# few additional test-harness-specific properties in adb_debug.prop.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002785INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002786
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002787$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS)
2788$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2789 @echo "Target test harness ramdisk: $@"
2790 $(hide) rm -f $@
2791 $(hide) mkdir -p $(dir $@)
2792 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002793
Bob Badourebdefc02022-02-12 15:39:22 -08002794$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),)
2795$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS),$(PRODUCT_OUT)/:/)
2796
Justin Yundd15ec12022-09-23 10:47:21 +09002797UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002798
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002799.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002800ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002801 @echo "make $@: ignoring dependencies"
2802 $(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2803 $(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS)
2804 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002805
2806# -----------------------------------------------------------------
2807# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2808#
2809# Note: it's intentional to skip signing for boot-test-harness.img, because it
2810# can only be used if the device is unlocked with verification error.
Steve Muckle4866bd62020-04-02 11:31:08 -07002811ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2812 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2813 $(PRODUCT_OUT)/$(k).img)
2814else
2815 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2816endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002817
2818# 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 +08002819$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002820INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2821
2822# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2823# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2824# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2825# public key, if the device is unlocked.
2826ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2827$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2828endif
2829
Steve Muckle4866bd62020-04-02 11:31:08 -07002830# $(1): output file
2831define build-boot-test-harness-target
2832 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002833 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002834 $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002835 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002836endef
2837
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002838# 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 +08002839$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002840 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002841 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002842
Bob Badourebdefc02022-02-12 15:39:22 -08002843$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),)
2844$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
2845
Justin Yundd15ec12022-09-23 10:47:21 +09002846UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08002847
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002848.PHONY: bootimage_test_harness-nodeps
Yi-Yo Chiangcd6de3d2021-12-29 21:44:39 +08002849bootimage_test_harness-nodeps: $(MKBOOTIMG) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002850 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002851 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002852
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002853endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002854
Bowgo Tsai87f60012021-07-29 23:35:33 +08002855# -----------------------------------------------------------------
2856# vendor test harness ramdisk, which is a vendor ramdisk combined with
2857# a test harness ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002858ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai87f60012021-07-29 23:35:33 +08002859
2860INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
2861
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002862# The order is important here. The test harness ramdisk staging directory has to
2863# come last so that it can override the adb_debug.prop in the debug ramdisk
2864# staging directory.
2865INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
2866INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002867
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002868$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS)
Bowgo Tsai87f60012021-07-29 23:35:33 +08002869$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Yi-Yo Chiang9942f4e2021-10-01 21:33:42 +08002870 $(hide) rm -f $@
2871 $(hide) mkdir -p $(dir $@)
2872 $(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai87f60012021-07-29 23:35:33 +08002873
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002874INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
2875$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2876 @echo "Target test harness vendor ramdisk: $@"
2877 $(copy-file-to-target)
2878
Bob Badourebdefc02022-02-12 15:39:22 -08002879$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),)
2880$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2881
2882VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2883
Bowgo Tsai87f60012021-07-29 23:35:33 +08002884# -----------------------------------------------------------------
2885# vendor_boot-test-harness.img.
2886INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
2887
2888ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2889$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2890endif
2891
2892# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
2893$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
2894$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2895$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
2896 $(call pretty,"Target vendor_boot test harness image: $@")
2897 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
2898 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2899 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2900
Bob Badourebdefc02022-02-12 15:39:22 -08002901$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),)
2902$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
2903
2904VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
2905
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002906endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2907
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002908endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2909
Bowgo Tsai87f60012021-07-29 23:35:33 +08002910
Colin Crossbd382142020-08-26 15:08:57 -07002911# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2912# $1: from location (e.g $(TARGET_OUT)/vendor)
2913# $2: destination location (e.g. /vendor)
2914# $3: partition image name (e.g. vendor.img)
2915define create-partition-compat-symlink
2916$(eval \
2917$1:
2918 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2919 mkdir -p $(dir $1)
2920 if [ -d $1 ] && [ ! -h $1 ]; then \
2921 echo 'Non-symlink $1 detected!' 1>&2; \
2922 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2923 exit 1; \
2924 fi
2925 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002926$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002927)
2928$1
2929endef
2930
2931
Inseob Kim135c1f12022-01-06 17:22:07 +09002932# FSVerity metadata generation
2933# Generate fsverity metadata files (.fsv_meta) and build manifest
Victor Hsieh89415a82022-09-09 14:16:33 -07002934# (<partition>/etc/security/fsverity/BuildManifest<suffix>.apk) BEFORE filtering systemimage,
2935# vendorimage, odmimage, productimage files below.
2936ifeq ($(PRODUCT_FSVERITY_GENERATE_METADATA),true)
Inseob Kim135c1f12022-01-06 17:22:07 +09002937
Victor Hsieh89415a82022-09-09 14:16:33 -07002938fsverity-metadata-targets-patterns := \
Victor Hsiehfb3ef8a2022-01-07 14:05:42 -08002939 $(TARGET_OUT)/framework/% \
Inseob Kim135c1f12022-01-06 17:22:07 +09002940 $(TARGET_OUT)/etc/boot-image.prof \
2941 $(TARGET_OUT)/etc/dirty-image-objects \
Nicolas Geoffray13f28212022-03-18 17:28:14 +00002942 $(TARGET_OUT)/etc/preloaded-classes \
Victor Hsieh89415a82022-09-09 14:16:33 -07002943 $(TARGET_OUT)/etc/classpaths/%.pb \
2944
2945ifdef BUILDING_SYSTEM_EXT_IMAGE
2946fsverity-metadata-targets-patterns += $(TARGET_OUT_SYSTEM_EXT)/framework/%
2947endif
Victor Hsieh89415a82022-09-09 14:16:33 -07002948
2949# Generate fsv_meta
2950fsverity-metadata-targets := $(sort $(filter \
2951 $(fsverity-metadata-targets-patterns), \
Colin Crossa1de5df2022-03-21 14:31:31 -07002952 $(ALL_DEFAULT_INSTALLED_MODULES)))
Inseob Kim135c1f12022-01-06 17:22:07 +09002953
2954define fsverity-generate-metadata
Bob Badour2cd35362022-12-01 17:58:57 -08002955$(call declare-0p-target,$(1).fsv_meta)
2956
Inseob Kim135c1f12022-01-06 17:22:07 +09002957$(1).fsv_meta: PRIVATE_SRC := $(1)
2958$(1).fsv_meta: PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2959$(1).fsv_meta: $(HOST_OUT_EXECUTABLES)/fsverity_metadata_generator $(HOST_OUT_EXECUTABLES)/fsverity $(1)
2960 $$< --fsverity-path $$(PRIVATE_FSVERITY) --signature none \
2961 --hash-alg sha256 --output $$@ $$(PRIVATE_SRC)
2962endef
2963
2964$(foreach f,$(fsverity-metadata-targets),$(eval $(call fsverity-generate-metadata,$(f))))
2965ALL_DEFAULT_INSTALLED_MODULES += $(addsuffix .fsv_meta,$(fsverity-metadata-targets))
2966
Inseob Kim135c1f12022-01-06 17:22:07 +09002967FSVERITY_APK_KEY_PATH := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
Victor Hsieh89415a82022-09-09 14:16:33 -07002968FSVERITY_APK_MANIFEST_TEMPLATE_PATH := system/security/fsverity/AndroidManifest.xml
2969
2970# Generate and install BuildManifest<suffix>.apk for the given partition
2971# $(1): path of the output APK
2972# $(2): partition name
2973define fsverity-generate-and-install-manifest-apk
2974fsverity-metadata-targets-$(2) := $(filter $(PRODUCT_OUT)/$(2)/%,\
2975 $(fsverity-metadata-targets))
2976$(1): PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
2977$(1): PRIVATE_AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
2978$(1): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
2979$(1): PRIVATE_VERSION_CODE := $(PLATFORM_SDK_VERSION)
2980$(1): PRIVATE_VERSION_NAME := $(APPS_DEFAULT_VERSION_NAME)
2981$(1): PRIVATE_APKSIGNER := $(HOST_OUT_EXECUTABLES)/apksigner
2982$(1): PRIVATE_MANIFEST := $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH)
2983$(1): PRIVATE_FRAMEWORK_RES := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
2984$(1): PRIVATE_KEY := $(FSVERITY_APK_KEY_PATH)
2985$(1): PRIVATE_INPUTS := $$(fsverity-metadata-targets-$(2))
2986$(1): PRIVATE_ASSETS := $(call intermediates-dir-for,ETC,build_manifest-$(2))/assets
2987$(1): $(HOST_OUT_EXECUTABLES)/fsverity_manifest_generator \
Inseob Kim135c1f12022-01-06 17:22:07 +09002988 $(HOST_OUT_EXECUTABLES)/fsverity $(HOST_OUT_EXECUTABLES)/aapt2 \
Victor Hsieh89415a82022-09-09 14:16:33 -07002989 $(HOST_OUT_EXECUTABLES)/apksigner $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH) \
Victor Hsiehbe1029a2022-01-07 10:42:23 -08002990 $(FSVERITY_APK_KEY_PATH).x509.pem $(FSVERITY_APK_KEY_PATH).pk8 \
Jiyong Parkefbb6ff2022-01-10 17:14:30 +09002991 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk \
Victor Hsieh89415a82022-09-09 14:16:33 -07002992 $$(fsverity-metadata-targets-$(2))
2993 rm -rf $$(PRIVATE_ASSETS)
2994 mkdir -p $$(PRIVATE_ASSETS)
Victor Hsieh89415a82022-09-09 14:16:33 -07002995 $$< --fsverity-path $$(PRIVATE_FSVERITY) \
2996 --base-dir $$(PRODUCT_OUT) \
2997 --output $$(PRIVATE_ASSETS)/build_manifest.pb \
2998 $$(PRIVATE_INPUTS)
Victor Hsieh89415a82022-09-09 14:16:33 -07002999 $$(PRIVATE_AAPT2) link -o $$@ \
3000 -A $$(PRIVATE_ASSETS) \
3001 -I $$(PRIVATE_FRAMEWORK_RES) \
3002 --min-sdk-version $$(PRIVATE_MIN_SDK_VERSION) \
3003 --version-code $$(PRIVATE_VERSION_CODE) \
3004 --version-name $$(PRIVATE_VERSION_NAME) \
3005 --manifest $$(PRIVATE_MANIFEST) \
3006 --rename-manifest-package com.android.security.fsverity_metadata.$(2)
3007 $$(PRIVATE_APKSIGNER) sign --in $$@ \
3008 --cert $$(PRIVATE_KEY).x509.pem \
3009 --key $$(PRIVATE_KEY).pk8
Inseob Kim135c1f12022-01-06 17:22:07 +09003010
Victor Hsieh89415a82022-09-09 14:16:33 -07003011ALL_DEFAULT_INSTALLED_MODULES += $(1)
Inseob Kim135c1f12022-01-06 17:22:07 +09003012
Victor Hsieh89415a82022-09-09 14:16:33 -07003013endef # fsverity-generate-and-install-manifest-apk
3014
3015$(eval $(call fsverity-generate-and-install-manifest-apk, \
3016 $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk,system))
3017ifdef BUILDING_SYSTEM_EXT_IMAGE
3018 $(eval $(call fsverity-generate-and-install-manifest-apk, \
3019 $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk,system_ext))
3020endif
Victor Hsieh89415a82022-09-09 14:16:33 -07003021
3022endif # PRODUCT_FSVERITY_GENERATE_METADATA
3023
3024
3025# -----------------------------------------------------------------
3026# system image
Inseob Kim135c1f12022-01-06 17:22:07 +09003027
Colin Cross79a76ec2022-03-21 15:06:11 -07003028INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen37a19862018-10-31 16:31:46 -07003029INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Dan Willemsena3f66322020-05-28 15:46:33 -07003030 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07003031
Colin Crossbd382142020-08-26 15:08:57 -07003032# Create symlink /system/vendor to /vendor if necessary.
3033ifdef BOARD_USES_VENDORIMAGE
3034 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
3035endif
3036
3037# Create symlink /system/product to /product if necessary.
3038ifdef BOARD_USES_PRODUCTIMAGE
3039 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
3040endif
3041
3042# Create symlink /system/system_ext to /system_ext if necessary.
3043ifdef BOARD_USES_SYSTEM_EXTIMAGE
3044 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
3045endif
3046
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003047# -----------------------------------------------------------------
3048# system_dlkm partition image
3049
3050# Create symlinks for system_dlkm on devices with a system_dlkm partition:
3051# /system/lib/modules -> /system_dlkm/lib/modules
3052#
3053# On devices with a system_dlkm partition,
3054# - /system/lib/modules is a symlink to a directory that stores system DLKMs.
3055# - The system_dlkm partition is mounted at /system_dlkm at runtime.
Ramji Jiyani13a41372022-01-27 07:05:08 +00003056ifdef BOARD_USES_SYSTEM_DLKMIMAGE
Ramji Jiyanif9ce3572021-12-01 00:03:11 +00003057 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/lib/modules,/system_dlkm/lib/modules,system_dlkm.img)
3058endif
3059
Ying Wang82cceba2012-08-13 15:03:00 -07003060FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003061
3062# ASAN libraries in the system image - add dependency.
3063ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07003064ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07003065 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
3066 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
3067 endif
3068endif
3069
Tom Cherryd14b8952018-08-09 14:26:00 -07003070FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07003071
Ying Wange5e8c5f2011-09-09 16:35:53 -07003072# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08003073ifdef BUILDING_SYSTEM_IMAGE
3074
Kiyoung Kim36481e02020-11-16 10:50:05 +09003075# Install system linker configuration
3076# Collect all available stub libraries installed in system and install with predefined linker configuration
3077SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
Colin Crossd4a054f2022-03-15 15:07:07 -07003078SYSTEM_LINKER_CONFIG_SOURCE := $(call intermediates-dir-for,ETC,system_linker_config)/system_linker_config
3079$(SYSTEM_LINKER_CONFIG): PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE := $(SYSTEM_LINKER_CONFIG_SOURCE)
3080$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE) | conv_linker_config
3081 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE) \
Kiyoung Kim36481e02020-11-16 10:50:05 +09003082 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
3083
Bob Badour2f66fd12022-03-09 17:30:24 -08003084$(call declare-1p-target,$(SYSTEM_LINKER_CONFIG),)
Colin Crossd4a054f2022-03-15 15:07:07 -07003085$(call declare-license-deps,$(SYSTEM_LINKER_CONFIG),$(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE))
Bob Badour2f66fd12022-03-09 17:30:24 -08003086
Kiyoung Kim36481e02020-11-16 10:50:05 +09003087FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
3088
Ying Wange5e8c5f2011-09-09 16:35:53 -07003089# installed file list
3090# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
3091# We put installed-files.txt ahead of image itself in the dependency graph
3092# so that we can get the size stat even if the build fails due to too large
3093# system image.
3094INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07003095INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
3096$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003097$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003098 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003099 mkdir -p $(dir $@)
3100 rm -f $@
3101 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
3102 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07003103
Bob Badourebdefc02022-02-12 15:39:22 -08003104$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE)))
Bob Badour5acd4362022-04-12 18:31:35 -07003105$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON)))
Bob Badourebdefc02022-02-12 15:39:22 -08003106
Ying Wange5e8c5f2011-09-09 16:35:53 -07003107.PHONY: installed-file-list
3108installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08003109
Ying Wange5e8c5f2011-09-09 16:35:53 -07003110systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003111 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07003112BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
3113
The Android Open Source Project88b60792009-03-03 19:28:42 -08003114# $(1): output file
3115define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07003116 @echo "Target system fs image: $(1)"
3117 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003118 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07003119 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003120 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003121 $(BUILD_IMAGE) \
3122 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
3123 || ( mkdir -p $${DIST_DIR}; \
3124 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
3125 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08003126endef
3127
Dan Willemsen6b72c732019-06-12 21:33:38 +00003128ifeq ($(BOARD_AVB_ENABLE),true)
3129$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
3130endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07003131$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003132 $(call build-systemimage-target,$@)
3133
Bob Badour879cfa82021-04-15 10:41:38 -07003134$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
Bob Badourebdefc02022-02-12 15:39:22 -08003135$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:/)
Bob Badour879cfa82021-04-15 10:41:38 -07003136
Tao Baoe9d61b02018-08-20 21:09:07 -07003137INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07003138SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003139
Tao Baoe9d61b02018-08-20 21:09:07 -07003140# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
3141# compatibility, in case device-specific Makefiles still refer to the old name.
3142INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
3143
Doug Zongker73ef8252009-07-23 15:12:53 -07003144# The system partition needs room for the recovery image as well. We
3145# now store the recovery image as a binary patch using the boot image
3146# as the source (since they are very similar). Generate the patch so
3147# we can see how big it's going to be, and include that in the system
3148# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07003149ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07003150ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07003151ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08003152ifneq (,$(filter true,$(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08003153diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
3154else
3155diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
3156endif
Doug Zongker73ef8252009-07-23 15:12:53 -07003157intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
3158RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08003159$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
3160$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00003161 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07003162 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003163 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07003164 @echo "Construct recovery from boot"
3165 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07003166 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07003167else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
3168RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07003169endif # BOARD_USES_FULL_RECOVERY_IMAGE
3170endif # INSTALLED_RECOVERYIMAGE_TARGET
3171endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07003172
Yifan Hong9a3cad92020-04-27 19:06:59 -07003173$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003174 @echo "Install system fs image: $@"
3175 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003176 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003177
Bob Badour879cfa82021-04-15 10:41:38 -07003178$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
3179$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
3180
Tao Baoe9d61b02018-08-20 21:09:07 -07003181systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003182
Bob Badourebdefc02022-02-12 15:39:22 -08003183SYSTEM_NOTICE_DEPS += $(INSTALLED_SYSTEMIMAGE_TARGET)
Bob Badour879cfa82021-04-15 10:41:38 -07003184
The Android Open Source Project88b60792009-03-03 19:28:42 -08003185.PHONY: systemimage-nodeps snod
3186systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07003187 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003188 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07003189 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00003190 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08003191ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00003192 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08003193endif
3194
Dan Willemsen67495202019-01-16 12:42:05 -08003195endif # BUILDING_SYSTEM_IMAGE
3196
Anton Hansson30e061b2018-11-12 13:36:46 +00003197.PHONY: sync syncsys
3198sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07003199
Ying Wang3a61eeb2016-03-11 10:32:01 -08003200# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07003201# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07003202.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07003203platform:
3204 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07003205
3206.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07003207platform-java:
3208 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07003209
Ying Wang3a61eeb2016-03-11 10:32:01 -08003210# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08003211# data partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003212INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_DATA)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003213INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003214 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003215
Dan Willemsen67495202019-01-16 12:42:05 -08003216ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07003217userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07003218 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07003219BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
3220
Ying Wangbd93d422011-10-28 17:02:30 -07003221define build-userdataimage-target
3222 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
3223 @mkdir -p $(TARGET_OUT_DATA)
3224 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003225 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003226 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003227 $(BUILD_IMAGE) \
3228 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
3229 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
3230 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07003231endef
3232
Joe Onorato64d85d02009-04-09 19:31:12 -07003233# We just build this directly to the install location.
3234INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003235INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
3236 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003237 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07003238$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003239 $(build-userdataimage-target)
3240
Bob Badourebdefc02022-02-12 15:39:22 -08003241$(call declare-1p-container,$(INSTALLED_USERDATAIMAGE_TARGET),)
3242$(call declare-container-license-deps,$(INSTALLED_USERDATAIMAGE_TARGET),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS),$(PRODUCT_OUT)/:/)
3243
Justin Yundd15ec12022-09-23 10:47:21 +09003244UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_USERDATAIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003245
The Android Open Source Project88b60792009-03-03 19:28:42 -08003246.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07003247userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08003248 $(build-userdataimage-target)
3249
Dan Willemsen67495202019-01-16 12:42:05 -08003250endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07003251
Andreas Gampe039b5c72017-03-24 16:06:31 -07003252# ASAN libraries in the system image - build rule.
3253ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
3254 $(TARGET_OUT_SHARED_LIBRARIES) \
3255 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
3256 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
3257 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07003258# Extra options: Enforce the system user for the files to avoid having to change ownership.
3259ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07003260# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
3261# enough space.
3262$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07003263 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 -07003264
The Android Open Source Project88b60792009-03-03 19:28:42 -08003265# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04003266# partition table image
3267ifdef BOARD_BPT_INPUT_FILES
3268
3269BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003270BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04003271
3272INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
3273 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003274 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04003275 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
3276
3277ifdef BOARD_BPT_DISK_SIZE
3278INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
3279endif
3280
3281define build-bptimage-target
3282 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
3283 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
3284endef
3285
3286INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07003287$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
3288 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
3289
David Zeuthen25328622016-04-08 15:08:03 -04003290$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
3291 $(build-bptimage-target)
3292
Bob Badourebdefc02022-02-12 15:39:22 -08003293$(call declare-1p-container,$(INSTALLED_BPTIMAGE_TARGET),)
3294$(call declare-container-license-deps,$(INSTALLED_BPTIMAGE_TARGET),$(BOARD_BPT_INPUT_FILES),$(PRODUCT_OUT)/:/)
3295
Justin Yundd15ec12022-09-23 10:47:21 +09003296UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BPTIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003297
David Zeuthen25328622016-04-08 15:08:03 -04003298.PHONY: bptimage-nodeps
3299bptimage-nodeps:
3300 $(build-bptimage-target)
3301
3302endif # BOARD_BPT_INPUT_FILES
3303
3304# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07003305# cache partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003306INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_CACHE)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003307ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003308INTERNAL_CACHEIMAGE_FILES := \
3309 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
3310
3311cacheimage_intermediates := \
3312 $(call intermediates-dir-for,PACKAGING,cache)
3313BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
3314
3315define build-cacheimage-target
3316 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
3317 @mkdir -p $(TARGET_OUT_CACHE)
3318 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003319 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003320 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003321 $(BUILD_IMAGE) \
3322 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
3323 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
3324 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07003325endef
3326
3327# We just build this directly to the install location.
3328INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003329$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07003330 $(build-cacheimage-target)
3331
Bob Badourebdefc02022-02-12 15:39:22 -08003332$(call declare-1p-container,$(INSTALLED_CACHEIMAGE_TARGET),)
3333$(call declare-container-license-deps,$(INSTALLED_CACHEIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES),$(PRODUCT_OUT)/:/)
3334
Justin Yundd15ec12022-09-23 10:47:21 +09003335UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_CACHEIMAGE_TARGET)
Bob Badourebdefc02022-02-12 15:39:22 -08003336
Ying Wang9f8e8db2011-11-04 11:37:01 -07003337.PHONY: cacheimage-nodeps
3338cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3339 $(build-cacheimage-target)
3340
Dan Willemsen67495202019-01-16 12:42:05 -08003341else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07003342# we need to ignore the broken cache link when doing the rsync
3343IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08003344endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07003345
David Zeuthen0eb10972016-09-28 17:55:27 -04003346# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07003347# system_other partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003348INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_OTHER)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003349ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003350ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07003351# Marker file to identify that odex files are installed
3352INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
3353ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
3354$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
3355 $(hide) touch $@
Bob Badour2f66fd12022-03-09 17:30:24 -08003356
3357$(call declare-0p-target,$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER))
Alex Light4e358ab2016-06-16 14:47:10 -07003358endif
3359
Alex Light4e358ab2016-06-16 14:47:10 -07003360INTERNAL_SYSTEMOTHERIMAGE_FILES := \
3361 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003362 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07003363
Colin Cross6db5b0e2018-11-16 21:26:33 -08003364# system_other dex files are installed as a side-effect of installing system image files
3365INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
3366
Alex Light4e358ab2016-06-16 14:47:10 -07003367INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07003368INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
3369$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003370$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07003371 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003372 mkdir -p $(dir $@)
3373 rm -f $@
3374 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
3375 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07003376
Bob Badourebdefc02022-02-12 15:39:22 -08003377$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEMOTHER)))
Bob Badour5acd4362022-04-12 18:31:35 -07003378$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEMOTHER)))
Bob Badourebdefc02022-02-12 15:39:22 -08003379
Bowgo Tsai867ab662019-01-29 13:30:18 +08003380# Determines partition size for system_other.img.
3381ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
3382ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
3383INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
3384endif
3385endif
3386
3387ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
3388INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
3389endif
3390
Alex Light4e358ab2016-06-16 14:47:10 -07003391systemotherimage_intermediates := \
3392 $(call intermediates-dir-for,PACKAGING,system_other)
3393BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
3394
3395# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
3396define build-systemotherimage-target
3397 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
3398 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
3399 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003400 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003401 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003402 $(BUILD_IMAGE) \
3403 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
3404 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
3405 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07003406endef
3407
3408# We just build this directly to the install location.
3409INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003410ifneq (true,$(SANITIZE_LITE))
3411# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07003412$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
3413 $(build-systemotherimage-target)
Bob Badourebdefc02022-02-12 15:39:22 -08003414
3415$(call declare-1p-container,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),)
3416$(call declare-container-license-deps,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES),$(PRODUCT_OUT)/:/)
3417
3418UNMOUNTED_NOTICE_DEPS += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07003419endif
Alex Light4e358ab2016-06-16 14:47:10 -07003420
3421.PHONY: systemotherimage-nodeps
3422systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
3423 $(build-systemotherimage-target)
3424
Dan Willemsen67495202019-01-16 12:42:05 -08003425endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07003426
3427
3428# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07003429# vendor partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003430INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003431ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07003432INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07003433 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003434 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07003435
Ying Wang8da19e32015-09-15 14:22:12 -07003436
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003437# Create symlink /vendor/odm to /odm if necessary.
3438ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003439 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003440endif
3441
Yifan Honge51dff22020-06-23 17:26:57 -07003442# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
3443# /vendor/lib/modules -> /vendor_dlkm/lib/modules
3444#
3445# On devices with a vendor_dlkm partition,
3446# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
3447# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
3448# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3449# are hidden.
3450# On devices without a vendor_dlkm partition,
3451# - /vendor/lib/modules stores vendor DLKMs directly.
3452# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
3453# See system/core/rootdir/Android.mk for a list of created symlinks.
3454# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
3455# are not guaranteed to exist on all devices.
3456ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003457 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 -07003458endif
3459
Colin Crossbd382142020-08-26 15:08:57 -07003460INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
3461INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3462$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
3463$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3464 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003465 mkdir -p $(dir $@)
3466 rm -f $@
3467 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
3468 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07003469
Bob Badour5acd4362022-04-12 18:31:35 -07003470$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR))
3471$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR))
Bob Badourebdefc02022-02-12 15:39:22 -08003472
Ying Wanga0febe52013-03-20 11:02:05 -07003473vendorimage_intermediates := \
3474 $(call intermediates-dir-for,PACKAGING,vendor)
3475BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003476define build-vendorimage-target
3477 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3478 @mkdir -p $(TARGET_OUT_VENDOR)
3479 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003480 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003481 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003482 $(BUILD_IMAGE) \
3483 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3484 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003485 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003486endef
3487
3488# We just build this directly to the install location.
3489INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003490$(INSTALLED_VENDORIMAGE_TARGET): \
3491 $(INTERNAL_USERIMAGES_DEPS) \
3492 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003493 $(INSTALLED_FILES_FILE_VENDOR) \
3494 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003495 $(build-vendorimage-target)
3496
Bob Badourebdefc02022-02-12 15:39:22 -08003497VENDOR_NOTICE_DEPS += $(INSTALLED_VENDORIMAGE_TARGET)
3498
Bob Badour5acd4362022-04-12 18:31:35 -07003499$(call declare-container-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08003500$(call declare-container-license-deps,$(INSTALLED_VENDORIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(RECOVERY_FROM_BOOT_PATH),$(PRODUCT_OUT)/:/)
3501
Steven Morelanda2e734d2017-03-07 12:10:09 -08003502.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003503vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003504 $(build-vendorimage-target)
3505
Colin Cross91a52272017-06-20 16:57:52 -07003506sync: $(INTERNAL_VENDORIMAGE_FILES)
3507
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003508else ifdef BOARD_PREBUILT_VENDORIMAGE
3509INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3510$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
Bob Badour5acd4362022-04-12 18:31:35 -07003511$(if $(strip $(ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC)),,\
3512 $(if $(strip $(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
Bob Badourba337242022-05-27 19:40:41 -07003513 $(call declare-copy-target-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_PREBUILT_VENDORIMAGE)),\
Bob Badour5acd4362022-04-12 18:31:35 -07003514 $(call declare-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)))
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003515endif
Ying Wanga0febe52013-03-20 11:02:05 -07003516
Ying Wang9f8e8db2011-11-04 11:37:01 -07003517# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003518# product partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003519INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_PRODUCT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003520ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003521INTERNAL_PRODUCTIMAGE_FILES := \
3522 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003523 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003524
3525INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003526INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3527$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003528$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003529 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003530 mkdir -p $(dir $@)
3531 rm -f $@
3532 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3533 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003534
Bob Badour5acd4362022-04-12 18:31:35 -07003535$(call declare-0p-target,$(INSTALLED_FILES_FILE_PRODUCT))
3536$(call declare-0p-target,$(INSTALLED_FILES_JSON_PRODUCT))
Bob Badourebdefc02022-02-12 15:39:22 -08003537
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003538productimage_intermediates := \
3539 $(call intermediates-dir-for,PACKAGING,product)
3540BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3541define build-productimage-target
3542 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3543 @mkdir -p $(TARGET_OUT_PRODUCT)
3544 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003545 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003546 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003547 $(BUILD_IMAGE) \
3548 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3549 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3550 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003551endef
3552
3553# We just build this directly to the install location.
3554INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003555$(INSTALLED_PRODUCTIMAGE_TARGET): \
3556 $(INTERNAL_USERIMAGES_DEPS) \
3557 $(INTERNAL_PRODUCTIMAGE_FILES) \
3558 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003559 $(build-productimage-target)
3560
Bob Badourebdefc02022-02-12 15:39:22 -08003561PRODUCT_NOTICE_DEPS += $(INSTALLED_PRODUCTIMAGE_TARGET)
3562
3563$(call declare-1p-container,$(INSTALLED_PRODUCTIMAGE_TARGET),)
3564$(call declare-container-license-deps,$(INSTALLED_PRODUCTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT),$(PRODUCT_OUT)/:/)
3565
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003566.PHONY: productimage-nodeps pnod
3567productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3568 $(build-productimage-target)
3569
3570sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3571
3572else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3573INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3574$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3575endif
3576
3577# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003578# system_ext partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003579INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_EXT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Justin Yun6151e3f2019-06-25 15:58:13 +09003580ifdef BUILDING_SYSTEM_EXT_IMAGE
3581INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3582 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003583 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003584
Justin Yun6151e3f2019-06-25 15:58:13 +09003585INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3586INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3587$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3588$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003589 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003590 mkdir -p $(dir $@)
3591 rm -f $@
3592 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3593 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003594
Bob Badour5acd4362022-04-12 18:31:35 -07003595$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_EXT))
3596$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_EXT))
Bob Badourebdefc02022-02-12 15:39:22 -08003597
Justin Yun6151e3f2019-06-25 15:58:13 +09003598system_extimage_intermediates := \
3599 $(call intermediates-dir-for,PACKAGING,system_ext)
3600BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3601define build-system_extimage-target
3602 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3603 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3604 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3605 $(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 -07003606 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003607 $(BUILD_IMAGE) \
3608 $(TARGET_OUT_SYSTEM_EXT) \
3609 $(system_extimage_intermediates)/system_ext_image_info.txt \
3610 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3611 $(TARGET_OUT)
3612 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003613endef
3614
3615# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003616INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003617$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3618 $(INTERNAL_USERIMAGES_DEPS) \
3619 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3620 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003621 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003622
Bob Badourebdefc02022-02-12 15:39:22 -08003623SYSTEM_EXT_NOTICE_DEPS += $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
3624
3625$(call declare-1p-container,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),)
3626$(call declare-container-license-deps,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_EXT),$(PRODUCT_OUT)/:/)
3627
Justin Yun6151e3f2019-06-25 15:58:13 +09003628.PHONY: systemextimage-nodeps senod
3629systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3630 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003631
Justin Yun6151e3f2019-06-25 15:58:13 +09003632sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003633
Justin Yun6151e3f2019-06-25 15:58:13 +09003634else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3635INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3636$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003637endif
3638
3639# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003640# odm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003641INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Dan Willemsen67495202019-01-16 12:42:05 -08003642ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003643INTERNAL_ODMIMAGE_FILES := \
3644 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003645 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003646
Colin Crossbd382142020-08-26 15:08:57 -07003647# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3648# /odm/lib/modules -> /odm_dlkm/lib/modules
3649#
3650# On devices with a odm_dlkm partition,
3651# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3652# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3653# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3654# are hidden.
3655# On devices without a odm_dlkm partition,
3656# - /odm/lib/modules stores odm DLKMs directly.
3657# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3658# See system/core/rootdir/Android.mk for a list of created symlinks.
3659# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3660# are not guaranteed to exist on all devices.
3661ifdef BOARD_USES_ODM_DLKMIMAGE
3662 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3663endif
3664
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003665INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3666INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3667$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003668$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003669 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003670 mkdir -p $(dir $@)
3671 rm -f $@
3672 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3673 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003674
Bob Badour5acd4362022-04-12 18:31:35 -07003675$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM))
3676$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM))
Bob Badourebdefc02022-02-12 15:39:22 -08003677
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003678odmimage_intermediates := \
3679 $(call intermediates-dir-for,PACKAGING,odm)
3680BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3681define build-odmimage-target
3682 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3683 @mkdir -p $(TARGET_OUT_ODM)
3684 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003685 $(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
3686 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003687 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003688 $(BUILD_IMAGE) \
3689 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3690 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3691 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003692endef
3693
3694# We just build this directly to the install location.
3695INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003696$(INSTALLED_ODMIMAGE_TARGET): \
3697 $(INTERNAL_USERIMAGES_DEPS) \
3698 $(INTERNAL_ODMIMAGE_FILES) \
3699 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003700 $(build-odmimage-target)
3701
Bob Badourebdefc02022-02-12 15:39:22 -08003702ODM_NOTICE_DEPS += $(INSTALLED_ODMIMAGE_TARGET)
3703
3704$(call declare-1p-container,$(INSTALLED_ODMIMAGE_TARGET),)
3705$(call declare-container-license-deps,$(INSTALLED_ODMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM),$(PRODUCT_OUT)/:/)
3706
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003707.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003708odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003709 $(build-odmimage-target)
3710
3711sync: $(INTERNAL_ODMIMAGE_FILES)
3712
3713else ifdef BOARD_PREBUILT_ODMIMAGE
3714INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3715$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3716endif
3717
3718# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003719# vendor_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003720INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003721ifdef BUILDING_VENDOR_DLKM_IMAGE
3722INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3723 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003724 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003725
3726INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3727INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3728$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3729$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3730 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003731 mkdir -p $(dir $@)
3732 rm -f $@
3733 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3734 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003735
Bob Badour5acd4362022-04-12 18:31:35 -07003736$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DLKM))
3737$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003738
Yifan Hongcfb917a2020-05-07 14:58:20 -07003739vendor_dlkmimage_intermediates := \
3740 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3741BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3742define build-vendor_dlkmimage-target
3743 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3744 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3745 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003746 $(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
3747 vendor_dlkm, skip_fsck=true)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003748 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3749 $(BUILD_IMAGE) \
3750 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3751 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3752 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3753endef
3754
3755# We just build this directly to the install location.
3756INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3757$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3758 $(INTERNAL_USERIMAGES_DEPS) \
3759 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3760 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3761 $(build-vendor_dlkmimage-target)
3762
Bob Badourebdefc02022-02-12 15:39:22 -08003763VENDOR_DLKM_NOTICE_DEPS += $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
3764
3765$(call declare-1p-container,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),)
3766$(call declare-container-license-deps,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR_DLKM),$(PRODUCT_OUT)/:/)
3767
Yifan Hongcfb917a2020-05-07 14:58:20 -07003768.PHONY: vendor_dlkmimage-nodeps vdnod
3769vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3770 $(build-vendor_dlkmimage-target)
3771
3772sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3773
3774else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3775INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3776$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3777endif
3778
3779# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003780# odm_dlkm partition image
Colin Cross79a76ec2022-03-21 15:06:11 -07003781INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003782ifdef BUILDING_ODM_DLKM_IMAGE
3783INTERNAL_ODM_DLKMIMAGE_FILES := \
3784 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003785 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003786
3787INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3788INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3789$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3790$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3791 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003792 mkdir -p $(dir $@)
3793 rm -f $@
3794 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3795 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003796
Bob Badour5acd4362022-04-12 18:31:35 -07003797$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM_DLKM))
3798$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003799
Yifan Hongf496f1b2020-07-15 16:52:59 -07003800odm_dlkmimage_intermediates := \
3801 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3802BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3803define build-odm_dlkmimage-target
3804 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3805 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3806 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003807 $(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
3808 odm_dlkm, skip_fsck=true)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003809 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3810 $(BUILD_IMAGE) \
3811 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3812 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3813 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3814endef
3815
3816# We just build this directly to the install location.
3817INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3818$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3819 $(INTERNAL_USERIMAGES_DEPS) \
3820 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3821 $(INSTALLED_FILES_FILE_ODM_DLKM)
3822 $(build-odm_dlkmimage-target)
3823
Bob Badourebdefc02022-02-12 15:39:22 -08003824ODM_DLKM_NOTICE_DEPS += $(INSTALLED_ODM_DLKMIMAGE_TARGET)
3825
3826$(call declare-1p-container,$(INSTALLED_ODM_DLKMIMAGE_TARGET),)
3827$(call declare-container-license-deps,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM_DLKM),$(PRODUCT_OUT)/:/)
3828
Yifan Hongf496f1b2020-07-15 16:52:59 -07003829.PHONY: odm_dlkmimage-nodeps odnod
3830odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3831 $(build-odm_dlkmimage-target)
3832
3833sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3834
3835else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3836INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3837$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3838endif
3839
Ramji Jiyani13a41372022-01-27 07:05:08 +00003840# -----------------------------------------------------------------
3841# system_dlkm partition image
3842
Colin Cross79a76ec2022-03-21 15:06:11 -07003843INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
Ramji Jiyani13a41372022-01-27 07:05:08 +00003844ifdef BUILDING_SYSTEM_DLKM_IMAGE
3845
3846INTERNAL_SYSTEM_DLKMIMAGE_FILES := \
3847 $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,\
3848 $(ALL_DEFAULT_INSTALLED_MODULES))
3849
3850INSTALLED_FILES_FILE_SYSTEM_DLKM := $(PRODUCT_OUT)/installed-files-system_dlkm.txt
3851INSTALLED_FILES_JSON_SYSTEM_DLKM := $(INSTALLED_FILES_FILE_SYSTEM_DLKM:.txt=.json)
3852$(INSTALLED_FILES_FILE_SYSTEM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_DLKM)
3853$(INSTALLED_FILES_FILE_SYSTEM_DLKM): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3854 @echo Installed file list: $@
3855 mkdir -p $(dir $@)
Ramji Jiyani13a41372022-01-27 07:05:08 +00003856 rm -f $@
3857 $(FILESLIST) $(TARGET_OUT_SYSTEM_DLKM) > $(@:.txt=.json)
3858 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
3859
Bob Badour5acd4362022-04-12 18:31:35 -07003860$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_DLKM))
3861$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_DLKM))
Bob Badourebdefc02022-02-12 15:39:22 -08003862
Ramji Jiyani13a41372022-01-27 07:05:08 +00003863system_dlkmimage_intermediates := \
3864 $(call intermediates-dir-for,PACKAGING,system_dlkm)
3865BUILT_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3866define build-system_dlkmimage-target
3867 $(call pretty,"Target system_dlkm fs image: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)")
3868 @mkdir -p $(TARGET_OUT_SYSTEM_DLKM)
3869 @mkdir -p $(system_dlkmimage_intermediates) && rm -rf $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt
3870 $(call generate-image-prop-dictionary, $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt, \
3871 system_dlkm, skip_fsck=true)
3872 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3873 $(BUILD_IMAGE) \
3874 $(TARGET_OUT_SYSTEM_DLKM) $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt \
3875 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3876 $(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
3877endef
3878
3879# We just build this directly to the install location.
3880INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
3881$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): \
3882 $(INTERNAL_USERIMAGES_DEPS) \
3883 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
3884 $(INSTALLED_FILES_FILE_SYSTEM_DLKM)
3885 $(build-system_dlkmimage-target)
3886
Bob Badour56e0de52022-08-02 17:46:48 +00003887SYSTEM_DLKM_NOTICE_DEPS += $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
3888
3889$(call declare-1p-container,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),)
3890$(call declare-container-license-deps,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_DLKM),$(PRODUCT_OUT)/:/)
3891
Ramji Jiyani13a41372022-01-27 07:05:08 +00003892.PHONY: system_dlkmimage-nodeps sdnod
3893system_dlkmimage-nodeps sdnod: | $(INTERNAL_USERIMAGES_DEPS)
3894 $(build-system_dlkmimage-target)
3895
3896sync: $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
3897
3898else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
3899INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
3900$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_DLKMIMAGE),$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)))
3901endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07003902
3903# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003904# dtbo image
3905ifdef BOARD_PREBUILT_DTBOIMAGE
3906INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3907
3908ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003909$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003910 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3911 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003912 --image $@ \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003913 $(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
Anton Hansson6d814982018-11-26 18:12:05 +00003914 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3915 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Bob Badourebdefc02022-02-12 15:39:22 -08003916
3917$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_TARGET),)
3918$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_TARGET),$(BOARD_PREBUILT_DTBOIMAGE),$(PRODUCT_OUT)/:/)
3919
Justin Yundd15ec12022-09-23 10:47:21 +09003920UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DTBOIMAGE_TARGET)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003921else
3922$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3923 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3924endif
3925
Tao Bao0da43472018-08-22 22:53:41 -07003926endif # BOARD_PREBUILT_DTBOIMAGE
3927
Andrew Scull9b103e42020-11-29 14:04:28 +00003928# -----------------------------------------------------------------
3929# Protected VM firmware image
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003930ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Pierre-Clément Tosiadbf4da2022-09-09 15:57:58 +01003931
3932.PHONY: pvmfwimage
3933pvmfwimage: $(INSTALLED_PVMFWIMAGE_TARGET)
3934
Andrew Scull9b103e42020-11-29 14:04:28 +00003935INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
Andrew Scullbbc930b2022-02-17 22:34:27 +00003936INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003937INTERNAL_PVMFWIMAGE_FILES := $(call module-target-built-files,pvmfw_img)
Pierre-Clément Tosi615f0812022-10-26 16:05:16 +01003938INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,pvmfw_embedded_key)
Bob Badourebdefc02022-02-12 15:39:22 -08003939
3940$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003941$(call declare-container-license-deps,$(INSTALLED_PVMFWIMAGE_TARGET),$(INTERNAL_PVMFWIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badourebdefc02022-02-12 15:39:22 -08003942
Justin Yundd15ec12022-09-23 10:47:21 +09003943UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_PVMFWIMAGE_TARGET)
Pierre-Clément Tosid0000042022-09-08 13:26:08 +01003944
3945$(eval $(call copy-one-file,$(INTERNAL_PVMFWIMAGE_FILES),$(INSTALLED_PVMFWIMAGE_TARGET)))
Andrew Scull9b103e42020-11-29 14:04:28 +00003946
Andrew Scullbbc930b2022-02-17 22:34:27 +00003947$(INSTALLED_PVMFWIMAGE_TARGET): $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)
3948
3949$(eval $(call copy-one-file,$(INTERNAL_PVMFW_EMBEDDED_AVBKEY),$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)))
3950
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003951endif # BOARD_USES_PVMFWIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00003952
Tao Bao0da43472018-08-22 22:53:41 -07003953# Returns a list of image targets corresponding to the given list of partitions. For example, it
3954# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3955# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003956# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003957define images-for-partitions
Bowgo Tsai4f62aa02022-01-04 14:21:39 +08003958$(strip $(foreach item,$(1),\
3959 $(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
3960 $(if $(filter $(item),init_boot),$(INSTALLED_INIT_BOOT_IMAGE_TARGET),\
Ramji Jiyani13a41372022-01-27 07:05:08 +00003961 $(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))))
Tao Bao0da43472018-08-22 22:53:41 -07003962endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003963
3964# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003965# custom images
3966INSTALLED_CUSTOMIMAGES_TARGET :=
3967
3968ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3969INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3970
3971# Sign custom image.
3972# $(1): the prebuilt custom image.
3973# $(2): the mount point of the prebuilt custom image.
3974# $(3): the signed custom image target.
3975define sign_custom_image
3976$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3977 @echo Target custom image: $(3)
3978 mkdir -p $(dir $(3))
3979 cp $(1) $(3)
3980ifeq ($(BOARD_AVB_ENABLE),true)
3981 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3982 $(AVBTOOL) add_hashtree_footer \
3983 --image $(3) \
3984 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3985 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
Peter Collingbourne730200e2022-02-16 13:32:53 -08003986 $(call get-partition-size-argument,$(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE)) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003987 --partition_name $(2) \
3988 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3989 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3990endif
3991INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3992endef
3993
3994$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3995 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3996 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3997endif
3998
3999# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004000# vbmeta image
4001ifeq ($(BOARD_AVB_ENABLE),true)
4002
4003BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004004AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004005
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004006ifdef BOARD_AVB_KEY_PATH
4007$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
4008else
4009# If key path isn't specified, use the 4096-bit test key.
4010BOARD_AVB_ALGORITHM := SHA256_RSA4096
4011BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
4012endif
4013
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004014# AVB signing for system_other.img.
4015ifdef BUILDING_SYSTEM_OTHER_IMAGE
4016ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
4017$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
4018else
4019# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
4020BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
4021BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
4022endif
4023
Bowgo Tsaie4544b12019-02-27 10:15:51 +08004024$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
4025 @echo Extracting system_other avb key: $@
4026 @rm -f $@
4027 @mkdir -p $(dir $@)
4028 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08004029
Bob Badourebdefc02022-02-12 15:39:22 -08004030$(eval $(call declare-0p-target,$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET),))
4031
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08004032ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
4033BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
4034endif
4035
4036BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
4037endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
4038
Tao Bao744c4c72018-08-20 21:09:07 -07004039INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07004040 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07004041 $(BOARD_AVB_VBMETA_VENDOR)
4042
4043# Not allowing the same partition to appear in multiple groups.
4044ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07004045 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07004046endif
4047
cfig1aeef722019-09-20 22:45:06 +08004048# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
4049# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
4050# details.
Yifan Hong65afc072020-04-17 10:08:10 -07004051ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08004052ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4053$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07004054 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08004055 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
4056endif
4057endif
4058
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004059# Appends os version as a AVB property descriptor.
4060SYSTEM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4061BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
4062 --prop com.android.build.system.os_version:$(SYSTEM_OS_VERSION)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004063
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004064PRODUCT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4065BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
4066 --prop com.android.build.product.os_version:$(PRODUCT_OS_VERSION)
4067
4068SYSTEM_EXT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4069BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
4070 --prop com.android.build.system_ext.os_version:$(SYSTEM_EXT_OS_VERSION)
4071
4072INIT_BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4073BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4074 --prop com.android.build.init_boot.os_version:$(INIT_BOOT_OS_VERSION)
4075
4076BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4077BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4078 --prop com.android.build.boot.os_version:$(BOOT_OS_VERSION)
4079
4080VENDOR_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4081BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4082 --prop com.android.build.vendor.os_version:$(VENDOR_OS_VERSION)
4083
4084ODM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4085BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4086 --prop com.android.build.odm.os_version:$(ODM_OS_VERSION)
4087
4088VENDOR_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4089BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4090 --prop com.android.build.vendor_dlkm.os_version:$(VENDOR_DLKM_OS_VERSION)
4091
4092ODM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4093BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4094 --prop com.android.build.odm_dlkm.os_version:$(ODM_DLKM_OS_VERSION)
4095
4096SYSTEM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
4097BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4098 --prop com.android.build.system_dlkm.os_version:$(SYSTEM_DLKM_OS_VERSION)
4099
4100# Appends fingerprint and security patch level as a AVB property descriptor.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004101BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004102 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004103 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
4104
4105BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004106 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004107 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
4108
Justin Yun6151e3f2019-06-25 15:58:13 +09004109BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07004110 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004111 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004112
Bowgo Tsai9b548012019-05-14 16:57:03 +08004113BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsai8c7f8202022-02-22 14:47:45 +08004114 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004115
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004116BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004117 --prop com.android.build.init_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004118
Tao Bao19b02fe2019-10-09 00:04:28 -07004119BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
4120 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4121
Lucas Weif57333f2022-02-24 10:30:15 +08004122BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS += \
4123 --prop com.android.build.vendor_kernel_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
4124
Tao Bao19b02fe2019-10-09 00:04:28 -07004125BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
4126 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4127
Bowgo Tsai9b548012019-05-14 16:57:03 +08004128BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004129 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004130
4131BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004132 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08004133
Yifan Hongcfb917a2020-05-07 14:58:20 -07004134BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004135 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004136
Yifan Hongf496f1b2020-07-15 16:52:59 -07004137BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004138 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004139
Ramji Jiyani13a41372022-01-27 07:05:08 +00004140BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
Bowgo Tsaib0f43632022-03-30 11:32:32 +08004141 --prop com.android.build.system_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004142
Tao Bao19b02fe2019-10-09 00:04:28 -07004143BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
4144 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4145
Andrew Scull9b103e42020-11-29 14:04:28 +00004146BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4147 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
4148
Bowgo Tsai9b548012019-05-14 16:57:03 +08004149# The following vendor- and odm-specific images needs explicit SPL set per board.
Devin Moore380d9e42021-11-04 19:01:19 +00004150# TODO(b/210875415) Is this security_patch property used? Should it be removed from
4151# boot.img when there is no platform ramdisk included in it?
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004152ifdef BOOT_SECURITY_PATCH
4153BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
4154 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08004155endif
4156
4157ifdef INIT_BOOT_SECURITY_PATCH
4158BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4159 --prop com.android.build.init_boot.security_patch:$(INIT_BOOT_SECURITY_PATCH)
4160else ifdef BOOT_SECURITY_PATCH
Devin Moore380d9e42021-11-04 19:01:19 +00004161BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
4162 --prop com.android.build.init_boot.security_patch:$(BOOT_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08004163endif
4164
4165ifdef VENDOR_SECURITY_PATCH
4166BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
4167 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
4168endif
4169
4170ifdef ODM_SECURITY_PATCH
4171BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
4172 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
4173endif
4174
Yifan Hongcfb917a2020-05-07 14:58:20 -07004175ifdef VENDOR_DLKM_SECURITY_PATCH
4176BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4177 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
4178endif
4179
Yifan Hongf496f1b2020-07-15 16:52:59 -07004180ifdef ODM_DLKM_SECURITY_PATCH
4181BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4182 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
4183endif
4184
Ramji Jiyani13a41372022-01-27 07:05:08 +00004185ifdef SYSTEM_DLKM_SECURITY_PATCH
4186BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
4187 --prop com.android.build.system_dlkm.security_patch:$(SYSTEM_DLKM_SECURITY_PATCH)
4188endif
4189
Andrew Scull9b103e42020-11-29 14:04:28 +00004190ifdef PVMFW_SECURITY_PATCH
4191BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
4192 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
4193endif
4194
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004195BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Devin Moore380d9e42021-11-04 19:01:19 +00004196INIT_BOOT_FOOTER_ARGS := BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07004197VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Lucas Weif57333f2022-02-24 10:30:15 +08004198VENDOR_KERNEL_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004199DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00004200PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004201SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
4202VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05004203RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004204PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09004205SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004206ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07004207VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07004208ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Ramji Jiyani13a41372022-01-27 07:05:08 +00004209SYSTEM_DLKM_FOOTER_ARGS := BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004210
Tao Bao0da43472018-08-22 22:53:41 -07004211# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004212# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07004213define _check-and-set-avb-chain-args
4214$(eval part := $(1))
4215$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004216
4217$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
4218$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
4219$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
4220$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4221$(if $($(_key_path)),,$(error $(_key_path) is not defined))
4222$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
4223$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
4224$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4225
4226# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
4227$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
4228$(eval $(_signing_args) := \
4229 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
4230
cfig1aeef722019-09-20 22:45:06 +08004231# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
4232# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07004233$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08004234 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4235 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004236
Tao Bao744c4c72018-08-20 21:09:07 -07004237# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07004238# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07004239$(if $(filter $(part),$(part:vbmeta_%=%)),\
4240 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
4241 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004242endef
4243
Tao Bao0da43472018-08-22 22:53:41 -07004244# Checks and sets the required build variables for an AVB partition. The partition will be
4245# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07004246# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
4247# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004248# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
4249# but vbmeta would capture the image descriptor of only the first boot
4250# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07004251# $(1): Partition name, e.g. boot or system.
4252define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07004253$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07004254$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07004255 $(if $(_in_chained_vbmeta),\
4256 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07004257 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07004258 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07004259 $(if $(filter boot,$(1)),\
4260 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4261 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
4262 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4263 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07004264endef
4265
Hongguang Chenf23364d2020-04-27 18:36:36 -07004266# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
4267# $(1): the custom partition to enable AVB chain.
4268define check-and-set-custom-avb-chain-args
4269$(eval part := $(1))
4270$(eval PART=$(call to-upper,$(part)))
4271$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
4272$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
4273
4274INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
4275 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
4276endef
4277
Tao Baob1a2e352018-08-14 16:17:12 -07004278ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004279$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07004280endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004281
Devin Moore380d9e42021-11-04 19:01:19 +00004282ifdef INSTALLED_INIT_BOOT_IMAGE_TARGET
4283$(eval $(call check-and-set-avb-args,init_boot))
4284endif
4285
Steve Mucklee1b10862019-07-10 10:49:37 -07004286ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4287$(eval $(call check-and-set-avb-args,vendor_boot))
4288endif
4289
Lucas Weif57333f2022-02-24 10:30:15 +08004290ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
4291$(eval $(call check-and-set-avb-args,vendor_kernel_boot))
4292endif
4293
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004294ifdef INSTALLED_SYSTEMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004295$(eval $(call check-and-set-avb-args,system))
Bowgo Tsaie691aef2022-01-04 14:33:43 +08004296endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004297
4298ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004299$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004300endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004301
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004302ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004303$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004304endif
4305
Justin Yun6151e3f2019-06-25 15:58:13 +09004306ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
4307$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07004308endif
4309
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004310ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004311$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004312endif
4313
Yifan Hongcfb917a2020-05-07 14:58:20 -07004314ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
4315$(eval $(call check-and-set-avb-args,vendor_dlkm))
4316endif
4317
Yifan Hongf496f1b2020-07-15 16:52:59 -07004318ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
4319$(eval $(call check-and-set-avb-args,odm_dlkm))
4320endif
4321
Ramji Jiyani13a41372022-01-27 07:05:08 +00004322ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
4323$(eval $(call check-and-set-avb-args,system_dlkm))
4324endif
4325
Yueyao Zhu211c9012017-04-27 00:34:50 -07004326ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004327$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004328endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07004329
Andrew Scull9b103e42020-11-29 14:04:28 +00004330ifdef INSTALLED_PVMFWIMAGE_TARGET
4331$(eval $(call check-and-set-avb-args,pvmfw))
4332endif
4333
David Zeuthen8fecb282017-12-01 16:24:01 -05004334ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07004335$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05004336endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08004337
David Anderson7709ab22018-10-15 14:41:34 -07004338# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
4339ifdef BOARD_AVB_VBMETA_SYSTEM
4340$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07004341endif
4342
4343ifdef BOARD_AVB_VBMETA_VENDOR
4344$(eval $(call check-and-set-avb-args,vbmeta_vendor))
4345endif
4346
Hongguang Chenf23364d2020-04-27 18:36:36 -07004347ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4348$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4349 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
4350endif
4351
Tao Bao0da43472018-08-22 22:53:41 -07004352BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07004353BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07004354BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
4355
4356ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07004357# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07004358BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07004359endif
Tao Bao0da43472018-08-22 22:53:41 -07004360
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004361ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004362BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004363endif
4364
David Anderson7709ab22018-10-15 14:41:34 -07004365ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
4366BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
4367 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07004368endif
4369
4370ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
4371BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
4372 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07004373endif
4374
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004375# $(1): the directory to extract public keys to
4376define extract-avb-chain-public-keys
4377 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
4378 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
4379 --output $(1)/boot.avbpubkey)
Devin Moore380d9e42021-11-04 19:01:19 +00004380 $(if $(BOARD_AVB_INIT_BOOT_KEY_PATH),\
4381 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_INIT_BOOT_KEY_PATH) \
4382 --output $(1)/init_boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07004383 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
4384 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
4385 --output $(1)/vendor_boot.avbpubkey)
Lucas Weif57333f2022-02-24 10:30:15 +08004386 $(if $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH),\
4387 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH) \
4388 --output $(1)/vendor_kernel_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004389 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
4390 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
4391 --output $(1)/system.avbpubkey)
4392 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
4393 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
4394 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004395 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
4396 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
4397 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09004398 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
4399 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
4400 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004401 $(if $(BOARD_AVB_ODM_KEY_PATH),\
4402 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
4403 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07004404 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
4405 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
4406 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07004407 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
4408 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
4409 --output $(1)/odm_dlkm.avbpubkey)
Ramji Jiyani13a41372022-01-27 07:05:08 +00004410 $(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
4411 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH) \
4412 --output $(1)/system_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004413 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
4414 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
4415 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00004416 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
4417 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
4418 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05004419 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
4420 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
4421 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07004422 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
4423 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4424 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07004425 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
4426 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4427 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07004428 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
4429 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4430 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
4431 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004432endef
4433
Tao Bao744c4c72018-08-20 21:09:07 -07004434# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
4435# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07004436# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09004437# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
4438# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07004439# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07004440# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07004441# $(2): Output filename.
4442define build-chained-vbmeta-image
4443 $(call pretty,"Target chained vbmeta image: $@")
4444 $(hide) $(AVBTOOL) make_vbmeta_image \
4445 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
4446 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
4447 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
4448 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
4449 --output $@
4450endef
4451
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004452ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07004453ifdef BOARD_AVB_VBMETA_SYSTEM
4454INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
4455$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004456 $(AVBTOOL) \
4457 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
4458 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07004459 $(call build-chained-vbmeta-image,vbmeta_system)
Bob Badourebdefc02022-02-12 15:39:22 -08004460
4461$(call declare-1p-container,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET),)
4462
4463SYSTEM_NOTICE_DEPS += $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004464endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004465endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07004466
4467ifdef BOARD_AVB_VBMETA_VENDOR
4468INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
4469$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004470 $(AVBTOOL) \
4471 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
4472 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07004473 $(call build-chained-vbmeta-image,vbmeta_vendor)
Bob Badourebdefc02022-02-12 15:39:22 -08004474
4475$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
4476
Justin Yundd15ec12022-09-23 10:47:21 +09004477UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
Tao Bao744c4c72018-08-20 21:09:07 -07004478endif
4479
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004480define build-vbmetaimage-target
4481 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004482 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
4483 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004484 $(hide) $(AVBTOOL) make_vbmeta_image \
4485 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07004486 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004487 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
4488 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004489 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004490endef
4491
Paul Trautrim4e143232019-08-13 16:30:57 +09004492ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004493INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07004494$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4495 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
4496
David Zeuthen8fecb282017-12-01 16:24:01 -05004497$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00004498 $(AVBTOOL) \
4499 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00004500 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004501 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Lucas Weif57333f2022-02-24 10:30:15 +08004502 $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004503 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4504 $(INSTALLED_VENDORIMAGE_TARGET) \
4505 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004506 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004507 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004508 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004509 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004510 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004511 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004512 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004513 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004514 $(INSTALLED_RECOVERYIMAGE_TARGET) \
4515 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
4516 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
4517 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
4518 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
4519 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004520 $(build-vbmetaimage-target)
4521
Bob Badourebdefc02022-02-12 15:39:22 -08004522$(call declare-1p-container,$(INSTALLED_VBMETAIMAGE_TARGET),)
4523
4524UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETAIMAGE_TARGET)
4525
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004526.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08004527vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
4528 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004529vbmetaimage-nodeps:
4530 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09004531endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004532
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004533endif # BOARD_AVB_ENABLE
4534
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004535# List of files from all images
4536INTERNAL_ALLIMAGES_FILES := \
4537 $(FULL_SYSTEMIMAGE_DEPS) \
4538 $(INTERNAL_RAMDISK_FILES) \
4539 $(INTERNAL_USERDATAIMAGE_FILES) \
4540 $(INTERNAL_VENDORIMAGE_FILES) \
4541 $(INTERNAL_PRODUCTIMAGE_FILES) \
4542 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
4543 $(INTERNAL_ODMIMAGE_FILES) \
4544 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
4545 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00004546 $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004547
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08004548# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004549# Check VINTF of build
4550
Ramji Jiyani13a41372022-01-27 07:05:08 +00004551# Note: vendor_dlkm, odm_dlkm, and system_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004552ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07004553
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004554intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
4555check_vintf_all_deps :=
4556
Rob Seymour3f1c9572022-07-28 21:56:28 +00004557APEX_OUT := $(PRODUCT_OUT)/apex
4558# -----------------------------------------------------------------
4559# Create apex-info-file.xsd
4560
4561APEX_DIRS := \
4562 $(TARGET_OUT)/apex/% \
4563 $(TARGET_OUT_SYSTEM_EXT)/apex/% \
4564 $(TARGET_OUT_VENDOR)/apex/% \
4565 $(TARGET_OUT_ODM)/apex/% \
4566 $(TARGET_OUT_PRODUCT)/apex/% \
4567
4568apex_vintf_files := $(sort $(filter $(APEX_DIRS), $(INTERNAL_ALLIMAGES_FILES)))
4569APEX_INFO_FILE := $(APEX_OUT)/apex-info-list.xml
4570
4571$(APEX_INFO_FILE): $(HOST_OUT_EXECUTABLES)/dump_apex_info $(apex_vintf_files)
4572 @echo "Creating apex-info-file in $(PRODUCT_OUT) "
Jooyung Han8af44a92022-11-24 18:36:47 +09004573 $< --root_dir $(PRODUCT_OUT)
Rob Seymour3f1c9572022-07-28 21:56:28 +00004574
4575apex_vintf_files :=
4576
Yifan Hongaf9b0702020-01-21 12:46:57 -08004577# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
4578# because they are only used for prebuilt images.
4579check_vintf_common_srcs_patterns := \
4580 $(TARGET_OUT)/etc/vintf/% \
4581 $(TARGET_OUT_VENDOR)/etc/vintf/% \
4582 $(TARGET_OUT_ODM)/etc/vintf/% \
4583 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
4584 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
4585
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09004586check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Rob Seymour3f1c9572022-07-28 21:56:28 +00004587check_vintf_common_srcs += $(APEX_INFO_FILE)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004588check_vintf_common_srcs_patterns :=
4589
4590check_vintf_has_system :=
4591check_vintf_has_vendor :=
4592
Yifan Hong28ffd732020-03-13 13:11:10 -07004593ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
4594$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
4595endif
4596ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
4597$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
4598endif
4599
Yifan Hong605ea042020-01-14 21:36:00 +00004600# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08004601check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
4602ifneq ($(check_vintf_system_deps),)
4603check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00004604
Yifan Hongfd150d32021-03-09 12:19:11 -08004605check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00004606check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004607$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00004608 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
Bob Badour5acd4362022-04-12 18:31:35 -07004609$(call declare-0p-target,$(check_vintf_system_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004610check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00004611
Devin Moore62d0a732022-10-13 16:50:50 +00004612# -- Check framework manifest against frozen manifests for GSI targets. They need to be compatible.
4613ifneq (true, $(BUILDING_VENDOR_IMAGE))
4614 vintffm_log := $(intermediates)/vintffm.log
4615endif
Yifan Hong7a157b02020-10-20 17:08:11 +00004616check_vintf_all_deps += $(vintffm_log)
4617$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
4618 @( $< --check --dirmap /system:$(TARGET_OUT) \
4619 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
4620
Bob Badour5acd4362022-04-12 18:31:35 -07004621$(call declare-0p-target,$(vintffm_log))
4622
Yifan Hongaf9b0702020-01-21 12:46:57 -08004623endif # check_vintf_system_deps
4624check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004625
4626# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004627check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
4628ifneq ($(check_vintf_vendor_deps),)
4629check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08004630check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00004631check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07004632# Check vendor SKU=(empty) case when:
4633# - DEVICE_MANIFEST_FILE is not empty; OR
4634# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004635$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004636 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4637 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004638 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08004639$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07004640 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4641 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4642 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4643 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Bob Badour5acd4362022-04-12 18:31:35 -07004644$(call declare-0p-target,$(check_vintf_vendor_log))
Yifan Hong605ea042020-01-14 21:36:00 +00004645check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08004646endif # check_vintf_vendor_deps
4647check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00004648
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004649# -- Kernel version and configurations.
4650ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
4651
Yifan Hong605ea042020-01-14 21:36:00 +00004652BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
4653BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
4654
4655my_board_extracted_kernel :=
4656
4657# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
4658# from INSTALLED_KERNEL_TARGET.
4659ifdef BOARD_KERNEL_CONFIG_FILE
4660ifdef BOARD_KERNEL_VERSION
4661$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
4662 cp $< $@
4663$(BUILT_KERNEL_VERSION_FILE):
4664 echo $(BOARD_KERNEL_VERSION) > $@
4665
Bob Badour5acd4362022-04-12 18:31:35 -07004666$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4667$(call declare-0p-target,$(BUILT_KERNEL_VERSION_FILE))
4668
Yifan Hong605ea042020-01-14 21:36:00 +00004669my_board_extracted_kernel := true
4670endif # BOARD_KERNEL_VERSION
4671endif # BOARD_KERNEL_CONFIG_FILE
4672
4673ifneq ($(my_board_extracted_kernel),true)
Yifan Hong605ea042020-01-14 21:36:00 +00004674# Tools for decompression that is not in PATH.
4675# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
4676# Algorithms that are in the script but not in this list will be found in PATH.
4677my_decompress_tools := \
4678 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
4679
Yifan Hongb1627772021-07-14 15:01:50 -07004680endif # my_board_extracted_kernel
4681
4682ifneq ($(my_board_extracted_kernel),true)
4683ifdef INSTALLED_KERNEL_TARGET
Yifan Hong605ea042020-01-14 21:36:00 +00004684$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4685$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4686$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07004687$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
4688 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00004689 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08004690 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00004691
Bob Badour5acd4362022-04-12 18:31:35 -07004692$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4693
Yifan Hongb1627772021-07-14 15:01:50 -07004694my_board_extracted_kernel := true
Yifan Hong605ea042020-01-14 21:36:00 +00004695endif # INSTALLED_KERNEL_TARGET
Yifan Hongb1627772021-07-14 15:01:50 -07004696endif # my_board_extracted_kernel
4697
4698ifneq ($(my_board_extracted_kernel),true)
4699ifdef INSTALLED_BOOTIMAGE_TARGET
4700$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4701$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4702$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
4703$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
4704$(BUILT_KERNEL_CONFIGS_FILE): \
4705 $(HOST_OUT_EXECUTABLES)/unpack_bootimg \
4706 $(EXTRACT_KERNEL) \
4707 $(INSTALLED_BOOTIMAGE_TARGET)
4708 $(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
4709 $(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
4710 --output-configs $@ \
4711 --output-release $(BUILT_KERNEL_VERSION_FILE)
4712
Bob Badour5acd4362022-04-12 18:31:35 -07004713$(call declare-0p-target,$(BUILT_KERNEL_CONFIGS_FILE))
4714
Yifan Hongb1627772021-07-14 15:01:50 -07004715my_board_extracted_kernel := true
4716endif # INSTALLED_BOOTIMAGE_TARGET
4717endif # my_board_extracted_kernel
4718
4719ifneq ($(my_board_extracted_kernel),true)
4720$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
4721 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
4722 cannot be built into OTA update package. You can fix this by: \
4723 (1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
4724 so that kernel information will be extracted from the built kernel; or \
4725 (2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
4726 (3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
4727 BOARD_KERNEL_VERSION manually; or \
4728 (4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
4729# Clear their values to indicate that these two files does not exist.
4730BUILT_KERNEL_CONFIGS_FILE :=
4731BUILT_KERNEL_VERSION_FILE :=
4732endif
4733
4734my_decompress_tools :=
4735my_board_extracted_kernel :=
Yifan Hong605ea042020-01-14 21:36:00 +00004736
Yifan Hongc0f904e2021-03-17 11:25:31 -07004737endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4738
4739# -- Check VINTF compatibility of build.
4740# Skip partial builds; only check full builds. Only check if:
4741# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
4742# - system / vendor VINTF metadata exists
4743# - Building product / system_ext / odm images if board has product / system_ext / odm images
4744ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4745ifeq ($(check_vintf_has_system),true)
4746ifeq ($(check_vintf_has_vendor),true)
4747ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
4748ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
4749ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
4750
4751check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
4752check_vintf_all_deps += $(check_vintf_compatible_log)
4753
4754check_vintf_compatible_args :=
4755check_vintf_compatible_deps := $(check_vintf_common_srcs)
4756
4757ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004758ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004759check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004760check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004761endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004762endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4763
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004764check_vintf_compatible_args += \
4765 --dirmap /system:$(TARGET_OUT) \
4766 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4767 --dirmap /odm:$(TARGET_OUT_ODM) \
4768 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4769 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
Rob Seymour3f1c9572022-07-28 21:56:28 +00004770 --dirmap /apex:$(APEX_OUT) \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004771
4772ifdef PRODUCT_SHIPPING_API_LEVEL
4773check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4774endif # PRODUCT_SHIPPING_API_LEVEL
4775
4776$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4777$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004778# Check ODM SKU=(empty) case when:
4779# - ODM_MANIFEST_FILES is not empty; OR
4780# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004781$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004782 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
4783 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004784 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07004785# Check vendor SKU=(empty) case when:
4786# - DEVICE_MANIFEST_FILE is not empty; OR
4787# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004788$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004789 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4790 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004791 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004792$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08004793 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
4794 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004795 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
4796 @echo -n -e 'Args: \n ' >> $@
4797 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07004798 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4799 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004800 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004801 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
4802 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4803 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004804
Bob Badour5acd4362022-04-12 18:31:35 -07004805$(call declare-0p-target,$(check_vintf_compatible_log))
4806
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004807check_vintf_compatible_log :=
4808check_vintf_compatible_args :=
4809check_vintf_compatible_deps :=
4810
4811endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4812endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4813endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004814endif # check_vintf_has_vendor
4815endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004816endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4817
4818# Add all logs of VINTF checks to dist builds
4819droid_targets: $(check_vintf_all_deps)
4820$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4821
4822# Helper alias to check all VINTF of current build.
4823.PHONY: check-vintf-all
4824check-vintf-all: $(check_vintf_all_deps)
4825 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4826
Yifan Hongaf9b0702020-01-21 12:46:57 -08004827check_vintf_has_vendor :=
4828check_vintf_has_system :=
4829check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004830check_vintf_all_deps :=
4831intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004832endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004833
4834# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004835# Check image sizes <= size of super partition
4836
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004837ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004838
4839ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004840
Tianjie16bcac12021-05-13 15:44:43 -07004841PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
4842
4843# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
4844ifdef BUILDING_SYSTEM_OTHER_IMAGE
4845PARTITIONS_AND_OTHER_IN_SUPER += system_other
4846endif # BUILDING_SYSTEM_OTHER_IMAGE
4847
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004848# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004849# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004850define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004851 mkdir -p $(dir $(1))
4852 rm -f $(1)
4853 $(call dump-super-image-info, $(1))
Tianjie16bcac12021-05-13 15:44:43 -07004854 $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004855 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004856 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004857endef
4858
Yifan Hongd11953c2021-03-11 14:47:48 -08004859check_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 -07004860droid_targets: $(check_all_partition_sizes_log)
4861$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004862
Yifan Hong30910932019-10-25 20:36:55 -07004863$(check_all_partition_sizes_log): \
4864 $(CHECK_PARTITION_SIZES) \
Tianjie16bcac12021-05-13 15:44:43 -07004865 $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
Yifan Hong30910932019-10-25 20:36:55 -07004866 $(call check-all-partition-sizes-target, \
4867 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4868 $@)
4869
Bob Badour5acd4362022-04-12 18:31:35 -07004870$(call declare-0p-target,$(check_all_partition_sizes_log))
4871
Yifan Hong30910932019-10-25 20:36:55 -07004872.PHONY: check-all-partition-sizes
4873check-all-partition-sizes: $(check_all_partition_sizes_log)
4874
4875.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004876check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004877 $(call check-all-partition-sizes-target, \
4878 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004879
Yifan Hong2dae5722018-07-31 12:47:27 -07004880endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004881
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004882endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004883
4884# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004885# bring in the installer image generation defines if necessary
4886ifeq ($(TARGET_USE_DISKINSTALLER),true)
4887include bootable/diskinstaller/config.mk
4888endif
4889
4890# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004891# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004892
Ying Wangbd2d0242015-09-22 11:17:52 -07004893ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004894 build_ota_package := false
4895 build_otatools_package := false
4896else
Tao Bao9be20c72019-04-08 21:11:59 -07004897 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004898 build_ota_package := true
4899 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4900 build_ota_package := false
4901 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004902 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004903 build_ota_package := false
4904 endif
4905 ifeq ($(TARGET_PRODUCT),sdk)
4906 build_ota_package := false
4907 endif
Yifan Hongf32f65c2021-07-14 14:19:12 -07004908 # A target without a kernel may be one of the following:
Yifan Hong8c1e5262021-07-19 16:35:05 +00004909 # - A generic target. In this case, the OTA package usually isn't built.
4910 # PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
4911 # generation.
4912 # - A real device target, with TARGET_NO_KERNEL set to true and
4913 # BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
4914 # an OTA package.
Tao Bao9be20c72019-04-08 21:11:59 -07004915 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4916 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4917 build_ota_package := false
4918 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004919 ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4920 ifeq ($(TARGET_NO_KERNEL),true)
4921 build_ota_package := false
4922 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004923 endif # INSTALLED_BOOTIMAGE_TARGET == ""
Yifan Hongbf777872021-07-19 16:28:49 +00004924 ifeq ($(recovery_fstab),)
4925 build_ota_package := false
4926 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004927 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004928
Tao Bao9be20c72019-04-08 21:11:59 -07004929 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004930 build_otatools_package := true
4931 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4932 build_otatools_package := false
4933 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004934endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004935
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004936ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004937
4938INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004939 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004940 add_img_to_target_files \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004941 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004942 append2simg \
4943 avbtool \
4944 blk_alloc_to_base_fs \
4945 boot_signer \
4946 brillo_update_payload \
4947 brotli \
4948 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004949 build_image \
4950 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004951 build_verity_metadata \
4952 build_verity_tree \
4953 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004954 check_ota_package_signature \
4955 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004956 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004957 checkvintf \
4958 delta_generator \
4959 e2fsck \
4960 e2fsdroid \
4961 fc_sort \
4962 fec \
Woody Line4164192022-03-21 18:29:41 +08004963 fsck.erofs \
Jaegeuk Kim01da65f2021-06-08 18:24:46 -07004964 fsck.f2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07004965 fs_config \
Yi-Yo Chiang44fb3612022-01-08 22:19:20 +08004966 generate_gki_certificate \
Tao Bao96daeeb2019-05-01 21:17:13 -07004967 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08004968 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07004969 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004970 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004971 imgdiff \
4972 libconscrypt_openjdk_jni \
4973 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004974 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07004975 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07004976 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07004977 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07004978 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004979 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004980 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004981 mkbootfs \
4982 mkbootimg \
4983 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004984 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08004985 mkfs.erofs \
Cole Faustb0002082022-09-05 18:34:56 -07004986 mkf2fsuserimg \
Tao Bao96daeeb2019-05-01 21:17:13 -07004987 mksquashfs \
Cole Faustb0002082022-09-05 18:34:56 -07004988 mksquashfsimage \
Tao Bao96daeeb2019-05-01 21:17:13 -07004989 mkuserimg_mke2fs \
Kelvin Zhang83eb9f72022-03-15 11:12:50 -07004990 ota_extractor \
Tao Bao8821d642019-08-05 12:05:45 -07004991 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08004992 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08004993 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07004994 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004995 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004996 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004997 sign_apex \
4998 sign_target_files_apks \
Jooyung Han8caba5e2021-10-27 03:58:09 +09004999 sign_virt_apex \
Tao Bao96daeeb2019-05-01 21:17:13 -07005000 signapk \
5001 simg2img \
5002 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07005003 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07005004 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08005005 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07005006 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07005007 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07005008 verity_signer \
5009 verity_verifier \
5010 zipalign \
Kelvin Zhangb673bbf2021-08-20 10:09:20 -07005011 zucchini \
Tao Bao5e04c382017-02-22 16:38:19 -08005012
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005013# Additional tools to unpack and repack the apex file.
5014INTERNAL_OTATOOLS_MODULES += \
5015 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00005016 apex_compression_tool \
Dennis Shen888539c2022-11-07 18:53:10 +00005017 blkid \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005018 deapexer \
5019 debugfs_static \
Baligh Uddin67ab6892022-10-17 17:17:42 +00005020 dump_apex_info \
Dennis Shen888539c2022-11-07 18:53:10 +00005021 fsck.erofs \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08005022 merge_zips \
5023 resize2fs \
5024 soong_zip \
5025
Anton Hansson8dab0a62019-03-28 15:45:40 +00005026ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005027INTERNAL_OTATOOLS_MODULES += \
5028 futility \
5029 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08005030endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08005031
Tao Bao96daeeb2019-05-01 21:17:13 -07005032INTERNAL_OTATOOLS_FILES := \
5033 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005034
Ying Wang06898662010-06-17 17:52:18 -07005035.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07005036otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07005037
Tao Bao96daeeb2019-05-01 21:17:13 -07005038# For each module, recursively resolve its host shared library dependencies. Then we have a full
5039# list of modules whose installed files need to be packed.
5040INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
5041 $(sort $(INTERNAL_OTATOOLS_MODULES) \
5042 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005043
Tao Bao96daeeb2019-05-01 21:17:13 -07005044INTERNAL_OTATOOLS_PACKAGE_FILES := \
5045 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
5046
5047INTERNAL_OTATOOLS_PACKAGE_FILES += \
5048 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
hungweichenf1f5dd32022-08-17 08:01:50 +00005049 -name "*.pk8"))
Tao Bao93ab8442018-10-12 11:03:04 -07005050
Hongguang07babe02022-10-31 17:21:22 -07005051ifneq (,$(wildcard packages/modules))
Hongguang547812d2022-10-31 10:20:14 -07005052INTERNAL_OTATOOLS_PACKAGE_FILES += \
5053 $(sort $(shell find packages/modules -type f -name "*.x509.pem" -o -name "*.pk8" -o -name \
5054 "key.pem"))
Hongguang07babe02022-10-31 17:21:22 -07005055endif
Hongguang547812d2022-10-31 10:20:14 -07005056
Tao Bao93ab8442018-10-12 11:03:04 -07005057ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07005058INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07005059 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07005060 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07005061endif
5062ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07005063INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07005064 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
5065 -name "atx_metadata.bin"))
5066endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005067ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07005068INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00005069 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07005070endif
5071
Tao Bao96daeeb2019-05-01 21:17:13 -07005072INTERNAL_OTATOOLS_RELEASETOOLS := \
Kelvin Zhanged714e02022-09-22 12:42:24 -07005073 $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
5074 \( -type f -o -type l \) -print | sort)
Tao Bao96daeeb2019-05-01 21:17:13 -07005075
5076BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
5077$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
5078$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
5079$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
5080$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07005081$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005082 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07005083 rm -rf $@ $(PRIVATE_ZIP_ROOT)
5084 mkdir -p $(dir $@)
5085 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
5086 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08005087 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07005088 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005089
Bob Badour5acd4362022-04-12 18:31:35 -07005090$(call declare-1p-container,$(BUILT_OTATOOLS_PACKAGE),build)
5091$(call declare-container-license-deps,$(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS),$(BUILT_OTATOOLS_PACKAGE):)
5092
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005093.PHONY: otatools-package
5094otatools-package: $(BUILT_OTATOOLS_PACKAGE)
5095
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08005096endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07005097
The Android Open Source Project88b60792009-03-03 19:28:42 -08005098# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07005099# misc_info.txt
5100
5101INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
5102
5103ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
5104# default to common dir for device vendor
5105tool_extensions := $(TARGET_DEVICE_DIR)/../common
5106else
5107tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
5108endif
5109.KATI_READONLY := tool_extensions
5110
Steve Muckle903a1ca2020-05-07 17:32:10 -07005111# $1: boot image file name
5112define misc_boot_size
5113$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
5114endef
5115
Daniel Normane1e48082019-06-27 13:55:23 -07005116$(INSTALLED_MISC_INFO_TARGET):
5117 rm -f $@
5118 $(call pretty,"Target misc_info.txt: $@")
5119 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
5120 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
5121ifdef BOARD_FLASH_BLOCK_SIZE
5122 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
5123endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07005124ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
5125 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
5126 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07005127endif
5128ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
5129 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07005130else
5131 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005132endif
Devin Moore380d9e42021-11-04 19:01:19 +00005133ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
5134 $(hide) echo "init_boot=true" >> $@
5135 $(hide) echo "init_boot_size=$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)" >> $@
5136endif
J. Avila98cd4cc2020-06-10 20:09:10 +00005137ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
5138 echo "lz4_ramdisks=true" >> $@
5139endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005140ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5141 echo "vendor_boot=true" >> $@
5142 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
5143endif
Lucas Weif57333f2022-02-24 10:30:15 +08005144ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
5145 echo "vendor_kernel_boot=true" >> $@
5146 echo "vendor_kernel_boot_size=$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)" >> $@
5147endif
Daniel Normane1e48082019-06-27 13:55:23 -07005148ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5149 $(hide) echo "no_recovery=true" >> $@
5150endif
5151ifdef BOARD_INCLUDE_RECOVERY_DTBO
5152 $(hide) echo "include_recovery_dtbo=true" >> $@
5153endif
5154ifdef BOARD_INCLUDE_RECOVERY_ACPIO
5155 $(hide) echo "include_recovery_acpio=true" >> $@
5156endif
5157ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
5158 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
5159endif
5160ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
5161 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
5162 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5163else
5164 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
5165endif
5166 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
5167 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
Jacky Liubeb0b692021-12-29 16:29:05 +08005168ifdef PRODUCT_EXTRA_OTA_KEYS
5169 $(hide) echo "extra_ota_keys=$(PRODUCT_EXTRA_OTA_KEYS)" >> $@
5170endif
Daniel Normane1e48082019-06-27 13:55:23 -07005171ifdef PRODUCT_EXTRA_RECOVERY_KEYS
5172 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
5173endif
5174 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07005175 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005176 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Devin Moore380d9e42021-11-04 19:01:19 +00005177 $(hide) echo 'mkbootimg_init_args=$(BOARD_MKBOOTIMG_INIT_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005178ifdef BOARD_GKI_SIGNING_KEY_PATH
5179 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
5180 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08005181 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
5182endif
Daniel Normane1e48082019-06-27 13:55:23 -07005183 $(hide) echo "multistage_support=1" >> $@
5184 $(hide) echo "blockimgdiff_versions=3,4" >> $@
5185ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
5186 $(hide) echo "build_generic_ota_package=true" >> $@
5187endif
5188ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
5189 # OTA scripts are only interested in fingerprint related properties
5190 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
5191endif
5192ifneq (,$(filter address, $(SANITIZE_TARGET)))
5193 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
5194 $(hide) echo "userdata_img_with_data=true" >> $@
5195endif
5196ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
5197 $(hide) echo "full_recovery_image=true" >> $@
5198endif
Bill Peckhame868aec2019-09-17 17:06:47 -07005199ifdef BOARD_USES_VENDORIMAGE
5200 $(hide) echo "board_uses_vendorimage=true" >> $@
5201endif
Daniel Normane1e48082019-06-27 13:55:23 -07005202ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08005203ifeq ($(BUILDING_VBMETA_IMAGE),true)
5204 $(hide) echo "avb_building_vbmeta_image=true" >> $@
5205endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005206 $(hide) echo "avb_enable=true" >> $@
5207 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
5208 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
5209 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
5210 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5211ifdef BOARD_AVB_BOOT_KEY_PATH
5212 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
5213 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
5214 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5215endif # BOARD_AVB_BOOT_KEY_PATH
Yi-Yo Chiang33f973f2022-01-08 22:11:17 +08005216 $(hide) echo "avb_init_boot_add_hash_footer_args=$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5217ifdef BOARD_AVB_INIT_BOOT_KEY_PATH
5218 $(hide) echo "avb_init_boot_key_path=$(BOARD_AVB_INIT_BOOT_KEY_PATH)" >> $@
5219 $(hide) echo "avb_init_boot_algorithm=$(BOARD_AVB_INIT_BOOT_ALGORITHM)" >> $@
5220 $(hide) echo "avb_init_boot_rollback_index_location=$(BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5221endif # BOARD_AVB_INIT_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07005222 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5223ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
5224 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
5225 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
5226 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5227endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Lucas Weif57333f2022-02-24 10:30:15 +08005228 echo "avb_vendor_kernel_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
5229ifdef BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
5230 echo "avb_vendor_kernel_boot_key_path=$(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH)" >> $@
5231 echo "avb_vendor_kernel_boot_algorithm=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ALGORITHM)" >> $@
5232 echo "avb_vendor_kernel_boot_rollback_index_location=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
5233endif # BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07005234 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
5235ifdef BOARD_AVB_RECOVERY_KEY_PATH
5236 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
5237 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
5238 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
5239endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07005240ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
5241 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
5242 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5243 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
5244 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
5245 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
5246 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
5247 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
5248 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
5249endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07005250ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
5251 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
5252 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
5253 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
5254 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
5255 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
5256endif # BOARD_AVB_VBMETA_SYSTEM
5257ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
5258 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
Bowgo Tsaic85a2012022-06-07 11:36:35 +08005259 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS)" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07005260 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
5261 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
5262 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
5263endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
5264endif # BOARD_AVB_ENABLE
5265ifdef BOARD_BPT_INPUT_FILES
5266 $(hide) echo "board_bpt_enable=true" >> $@
5267 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
5268 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
5269endif
5270ifdef BOARD_BPT_DISK_SIZE
5271 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
5272endif
5273 $(call generate-userimage-prop-dictionary, $@)
5274ifeq ($(AB_OTA_UPDATER),true)
5275 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
5276 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
5277 $(hide) echo "ab_update=true" >> $@
5278endif
Yifan Hong65afc072020-04-17 10:08:10 -07005279ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
5280 $(hide) echo "allow_non_ab=true" >> $@
5281endif
Daniel Normane1e48082019-06-27 13:55:23 -07005282ifdef BOARD_PREBUILT_DTBOIMAGE
5283 $(hide) echo "has_dtbo=true" >> $@
5284ifeq ($(BOARD_AVB_ENABLE),true)
5285 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
5286 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
5287ifdef BOARD_AVB_DTBO_KEY_PATH
5288 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
5289 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
5290 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
5291endif # BOARD_AVB_DTBO_KEY_PATH
5292endif # BOARD_AVB_ENABLE
5293endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005294ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005295 $(hide) echo "has_pvmfw=true" >> $@
5296ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosi592a3ca2021-10-04 11:34:11 +02005297 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@
Andrew Scull9b103e42020-11-29 14:04:28 +00005298 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
5299ifdef BOARD_AVB_PVMFW_KEY_PATH
5300 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
5301 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
5302 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
5303endif # BOARD_AVB_PVMFW_KEY_PATH
5304endif # BOARD_AVB_ENABLE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02005305endif # BOARD_USES_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07005306 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07005307 @# VINTF checks
5308ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
5309 $(hide) echo "vintf_enforce=true" >> $@
5310endif
5311ifdef ODM_MANIFEST_SKUS
5312 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
5313endif
Yifan Hong28ffd732020-03-13 13:11:10 -07005314ifdef ODM_MANIFEST_FILES
5315 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
5316endif
5317ifdef DEVICE_MANIFEST_SKUS
5318 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
5319endif
5320ifdef DEVICE_MANIFEST_FILE
5321 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
5322endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005323ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
5324 $(hide) echo "bootloader_in_update_package=true" >> $@
5325endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07005326ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
5327 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
5328endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05005329ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5330 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
5331endif
Jose Galmes9c8f6eb2021-07-21 09:34:08 -07005332ifeq ($(BUILDING_WITH_VSDK),true)
5333 $(hide) echo "building_with_vsdk=true" >> $@
5334endif
5335ifeq ($(TARGET_FLATTEN_APEX),false)
5336 $(hide) echo "target_flatten_apex=false" >> $@
5337endif
Daniel Normane1e48082019-06-27 13:55:23 -07005338
Bob Badourebdefc02022-02-12 15:39:22 -08005339$(call declare-0p-target,$(INSTALLED_MISC_INFO_TARGET))
5340
Daniel Normane1e48082019-06-27 13:55:23 -07005341.PHONY: misc_info
5342misc_info: $(INSTALLED_MISC_INFO_TARGET)
5343
Bill Peckham315b98a2021-06-15 19:35:06 -07005344droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
Daniel Normane1e48082019-06-27 13:55:23 -07005345
5346# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005347# A zip of the directories that map to the target filesystem.
5348# This zip can be used to create an OTA package or filesystem image
5349# as a post-build step.
5350#
5351name := $(TARGET_PRODUCT)
5352ifeq ($(TARGET_BUILD_TYPE),debug)
5353 name := $(name)_debug
5354endif
5355name := $(name)-target_files-$(FILE_NAME_TAG)
5356
5357intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
5358BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
5359$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
5360$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005361 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005362
5363# $(1): Directory to copy
5364# $(2): Location to copy it to
5365# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
5366define package_files-copy-root
5367 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
5368 mkdir -p $(2) && \
5369 $(ACP) -rd $(strip $(1))/* $(2); \
5370 fi
5371endef
5372
Tao Baoa04fca32015-11-30 12:22:24 -08005373built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07005374
5375# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08005376ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07005377built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07005378 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07005379endif
5380
The Android Open Source Project88b60792009-03-03 19:28:42 -08005381$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
5382
Dan Willemsen653bea92017-03-21 15:47:37 -07005383tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07005384$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07005385
HÃ¥kan Kvist8cabc712022-05-02 07:43:34 +02005386updater_dep :=
Sen Jiang4438fd92016-03-07 16:51:01 -08005387ifeq ($(AB_OTA_UPDATER),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005388updater_dep += system/update_engine/update_engine.conf
Bob Badour5acd4362022-04-12 18:31:35 -07005389$(call declare-1p-target,system/update_engine/update_engine.conf,system/update_engine)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005390updater_dep += external/zucchini/version_info.h
Bob Badour5acd4362022-04-12 18:31:35 -07005391$(call declare-license-metadata,external/zucchini/version_info.h,legacy_notice,notice,external/zucchini/LICENSE,external/zucchini)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005392updater_dep += $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so
Yifan Hong65afc072020-04-17 10:08:10 -07005393endif
5394
5395# Build OTA tools if non-A/B is allowed
5396ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Kelvin Zhang6877e812022-01-06 11:12:04 -08005397updater_dep += $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07005398endif
Yifan Hong65afc072020-04-17 10:08:10 -07005399
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09005400$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07005401
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005402# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07005403# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005404ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5405$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07005406else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
5407$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005408else
5409$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
5410endif
5411
Dan Willemsen653bea92017-03-21 15:47:37 -07005412ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07005413 ifdef OSRELEASED_DIRECTORY
5414 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
5415 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
5416 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
5417 endif
Tao Baoa835f382019-07-18 15:55:30 -07005418
5419 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
5420 # additionally include radio or bootloader partitions).
5421 ifeq ($(AB_OTA_PARTITIONS),)
5422 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
5423 endif
5424endif
5425
5426ifneq ($(AB_OTA_PARTITIONS),)
5427 ifneq ($(AB_OTA_UPDATER),true)
5428 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
5429 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07005430endif
5431
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005432# Run fs_config while creating the target files package
5433# $1: root directory
5434# $2: add prefix
5435define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08005436(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 -08005437endef
5438
Yifan Hong60bfcc42019-11-01 11:39:45 -07005439define filter-out-missing-vendor
5440$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
5441endef
Petri Gynther09865a42021-03-10 18:23:39 -08005442define filter-out-missing-vendor_dlkm
5443$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
5444endef
5445define filter-out-missing-odm
5446$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
5447endef
5448define filter-out-missing-odm_dlkm
5449$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
5450endef
Ramji Jiyani13a41372022-01-27 07:05:08 +00005451define filter-out-missing-system_dlkm
5452$(if $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(1),$(filter-out system_dlkm,$(1)))
5453endef
5454# Filter out vendor,vendor_dlkm,odm,odm_dlkm,system_dlkm from the list for AOSP targets.
Petri Gynther09865a42021-03-10 18:23:39 -08005455# $(1): list
5456define filter-out-missing-partitions
5457$(call filter-out-missing-vendor,\
5458 $(call filter-out-missing-vendor_dlkm,\
5459 $(call filter-out-missing-odm,\
Ramji Jiyani13a41372022-01-27 07:05:08 +00005460 $(call filter-out-missing-odm_dlkm,\
5461 $(call filter-out-missing-system_dlkm,$(1))))))
Petri Gynther09865a42021-03-10 18:23:39 -08005462endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07005463
5464# Information related to dynamic partitions and virtual A/B. This information
5465# is needed for building the super image (see dump-super-image-info) and
5466# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08005467# $(1): file
5468define dump-dynamic-partitions-info
5469 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
5470 echo "use_dynamic_partitions=true" >> $(1))
5471 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
5472 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08005473 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
5474 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
5475 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00005476 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
5477 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08005478 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
5479 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005480 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
5481 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5482 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
5483 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
5484 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
5485 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005486 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005487 $(if $(BOARD_SUPER_PARTITION_GROUPS),
5488 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
5489 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
5490 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
5491 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08005492 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 -07005493 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
5494 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07005495 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
5496 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005497 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
5498 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00005499 $(if $(BOARD_SUPER_PARTITION_SIZE), \
5500 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
5501 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
5502 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
5503 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
5504 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
5505 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
5506 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005507 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
5508 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05005509 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
5510 echo "virtual_ab_compression=true" >> $(1))
Kelvin Zhangfa91e982022-02-09 11:19:16 -08005511# This value controls the compression algorithm used for VABC
5512# valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
5513# e.g. "none", "gz", "brotli"
5514 $(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD), \
5515 echo "virtual_ab_compression_method=$(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07005516 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
5517 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08005518endef
5519
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005520# By conditionally including the dependency of the target files package on the
5521# full system image deps, we speed up builds that do not build the system
5522# image.
5523ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005524 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005525else
5526 # releasetools may need the system build.prop even when building a
5527 # system-image-less product.
5528 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BUILD_PROP_TARGET)
Colin Cross43f2eb22020-08-26 18:41:29 -07005529endif
5530
5531ifdef BUILDING_USERDATA_IMAGE
5532 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
5533endif
5534
5535ifdef BUILDING_SYSTEM_OTHER_IMAGE
5536 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
5537endif
5538
5539ifdef BUILDING_VENDOR_BOOT_IMAGE
5540 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005541 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Devin Moore55af5062021-06-09 10:44:44 -07005542 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Colin Crosse6431202021-02-24 11:44:55 -08005543 # The vendor ramdisk may be built from the recovery ramdisk.
5544 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
5545 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
5546 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07005547endif
5548
5549ifdef BUILDING_RECOVERY_IMAGE
5550 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08005551 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07005552 # commands in build-recoveryimage-target, which would touch the files under
5553 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
5554 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
5555 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5556 else
5557 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
5558 endif
5559 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
5560endif
5561
5562# Conditionally depend on the image files if the image is being built so the
5563# target-files.zip rule doesn't wait on the image creation rule, or the image
5564# if it is coming from a prebuilt.
5565
5566ifdef BUILDING_VENDOR_IMAGE
5567 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
5568else ifdef BOARD_PREBUILT_VENDORIMAGE
5569 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
5570endif
5571
5572ifdef BUILDING_PRODUCT_IMAGE
5573 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
5574else ifdef BOARD_PREBUILT_PRODUCTIMAGE
5575 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
5576endif
5577
5578ifdef BUILDING_SYSTEM_EXT_IMAGE
5579 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
5580else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
5581 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
5582endif
5583
Devin Moore380d9e42021-11-04 19:01:19 +00005584ifneq (,$(BUILDING_BOOT_IMAGE)$(BUILDING_INIT_BOOT_IMAGE))
Colin Cross43f2eb22020-08-26 18:41:29 -07005585 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Devin Moore380d9e42021-11-04 19:01:19 +00005586endif # BUILDING_BOOT_IMAGE != "" || BUILDING_INIT_BOOT_IMAGE != ""
5587
Yifan Hong49968aa2020-11-09 11:52:52 -08005588ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07005589 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
5590endif
5591
5592ifdef BUILDING_ODM_IMAGE
5593 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
5594else ifdef BOARD_PREBUILT_ODMIMAGE
5595 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
5596endif
5597
5598ifdef BUILDING_VENDOR_DLKM_IMAGE
5599 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005600else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005601 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
5602endif
5603
5604ifdef BUILDING_ODM_DLKM_IMAGE
5605 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08005606else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07005607 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07005608endif
5609
Ramji Jiyani13a41372022-01-27 07:05:08 +00005610ifdef BUILDING_SYSTEM_DLKM_IMAGE
5611 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
5612else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5613 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
5614endif
5615
Isaac Chen9e09d472019-07-05 17:30:41 +08005616ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07005617 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
5618 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08005619endif
5620
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005621ifdef BOARD_PREBUILT_BOOTLOADER
5622$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005623droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005624endif
5625
The Android Open Source Project88b60792009-03-03 19:28:42 -08005626# Depending on the various images guarantees that the underlying
5627# directories are up-to-date.
5628$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00005629 $(INSTALLED_RADIOIMAGE_TARGET) \
5630 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005631 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005632 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00005633 $(INSTALLED_PVMFWIMAGE_TARGET) \
Andrew Scullbbc930b2022-02-17 22:34:27 +00005634 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07005635 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005636 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
5637 $(INSTALLED_KERNEL_TARGET) \
Enrico Granatab582e0f2020-10-14 15:17:20 -06005638 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005639 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005640 $(INSTALLED_2NDBOOTLOADER_TARGET) \
5641 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08005642 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005643 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005644 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5645 $(PRODUCT_VENDOR_BASE_FS_PATH) \
5646 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09005647 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00005648 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07005649 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07005650 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00005651 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00005652 $(LPMAKE) \
5653 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07005654 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00005655 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005656 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005657 $(SOONG_ZIP) \
5658 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07005659 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07005660 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07005661 $(BUILT_KERNEL_CONFIGS_FILE) \
5662 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00005663 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005664 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005665 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005666 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07005667ifneq (,$(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 -08005668 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005669 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005670# Exclude recovery files in the default vendor ramdisk if including a standalone
5671# recovery ramdisk in vendor_boot.
5672ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005673 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005674 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08005675endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005676ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005677ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07005678 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07005679else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07005680 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
5681endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005682endif
Yifan Hong78860162020-10-28 14:15:21 -07005683ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08005684ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005685 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005686endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005687ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08005688ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07005689 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08005690else
Steve Mucklee1b10862019-07-10 10:49:37 -07005691 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07005692endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005693endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005694ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07005695 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08005696endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07005697ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005698 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005699endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005700ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07005701ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07005702 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07005703endif # INTERNAL_KERNEL_CMDLINE != ""
5704endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07005705ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005706 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005707endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005708ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005709 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005710endif
Yifan Hong3941a872020-10-28 16:33:06 -07005711endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08005712endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08005713 @# Components of the boot image
5714 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07005715 $(hide) mkdir -p $(zip_root)/ROOT
5716 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005717 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08005718 @# If we are using recovery as boot, this is already done when processing recovery.
5719ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005720 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005721 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005722ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07005723 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08005724endif
Yifan Hong46aff092020-10-28 13:50:47 -07005725ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07005726 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07005727else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07005728 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08005729ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005730 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08005731endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005732ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07005733 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08005734endif
Doug Zongker38a649f2009-06-17 09:07:09 -07005735ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07005736 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07005737endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07005738ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07005739 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07005740endif
Yifan Hongaad34e52020-10-12 11:08:30 -07005741endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07005742endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07005743 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
5744 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07005745 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07005746ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5747 mkdir -p $(zip_root)/VENDOR_BOOT
5748 $(call package_files-copy-root, \
5749 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
5750ifdef INSTALLED_DTBIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005751ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
Steve Mucklee1b10862019-07-10 10:49:37 -07005752 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
5753endif
Lucas Weif57333f2022-02-24 10:30:15 +08005754endif # end of INSTALLED_DTBIMAGE_TARGET
Devin Moore50509012021-01-13 10:45:04 -08005755ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
5756 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
5757endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005758ifdef BOARD_KERNEL_BASE
5759 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
5760endif
5761ifdef BOARD_KERNEL_PAGESIZE
5762 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
5763endif
5764 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005765ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
5766 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
5767 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005768 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
5769 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
5770 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
5771 $(if $(prebuilt_ramdisk), \
5772 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
5773 $(call package_files-copy-root, \
5774 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
5775 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
5776 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005777endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07005778endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Lucas Weif57333f2022-02-24 10:30:15 +08005779ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
5780 mkdir -p $(zip_root)/VENDOR_KERNEL_BOOT
5781 $(call package_files-copy-root, \
5782 $(TARGET_VENDOR_KERNEL_RAMDISK_OUT),$(zip_root)/VENDOR_KERNEL_BOOT/RAMDISK)
5783ifdef INSTALLED_DTBIMAGE_TARGET
5784 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_KERNEL_BOOT/dtb
5785endif
5786ifdef BOARD_KERNEL_PAGESIZE
5787 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_KERNEL_BOOT/pagesize
5788endif
5789endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08005790ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005791 @# Contents of the system image
5792 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005793 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Yi-Yo Chiang9b258412022-01-04 00:05:11 +08005794else ifdef INSTALLED_BUILD_PROP_TARGET
5795 @# Copy the system build.prop even if not building a system image
5796 @# because add_img_to_target_files may need it to build other partition
5797 @# images.
5798 $(hide) mkdir -p "$(zip_root)/SYSTEM"
5799 $(hide) cp "$(INSTALLED_BUILD_PROP_TARGET)" "$(patsubst $(TARGET_OUT)/%,$(zip_root)/SYSTEM/%,$(INSTALLED_BUILD_PROP_TARGET))"
Dan Willemsen67495202019-01-16 12:42:05 -08005800endif
5801ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005802 @# Contents of the data image
5803 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005804 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08005805endif
5806ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07005807 @# Contents of the vendor image
5808 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005809 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07005810endif
Dan Willemsen67495202019-01-16 12:42:05 -08005811ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005812 @# Contents of the product image
5813 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005814 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005815endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005816ifdef BUILDING_SYSTEM_EXT_IMAGE
5817 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01005818 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09005819 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01005820endif
Dan Willemsen67495202019-01-16 12:42:05 -08005821ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005822 @# Contents of the odm image
5823 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005824 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005825endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005826ifdef BUILDING_VENDOR_DLKM_IMAGE
5827 @# Contents of the vendor_dlkm image
5828 $(hide) $(call package_files-copy-root, \
5829 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
5830endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005831ifdef BUILDING_ODM_DLKM_IMAGE
5832 @# Contents of the odm_dlkm image
5833 $(hide) $(call package_files-copy-root, \
5834 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
5835endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005836ifdef BUILDING_SYSTEM_DLKM_IMAGE
5837 @# Contents of the system_dlkm image
5838 $(hide) $(call package_files-copy-root, \
5839 $(TARGET_OUT_SYSTEM_DLKM),$(zip_root)/SYSTEM_DLKM)
5840endif
Dan Willemsen67495202019-01-16 12:42:05 -08005841ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07005842 @# Contents of the system_other image
5843 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005844 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07005845endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005846 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07005847 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07005848 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granatab582e0f2020-10-14 15:17:20 -06005849ifdef BUILDING_RAMDISK_IMAGE
5850ifeq (true,$(BOARD_IMG_USE_RAMDISK))
5851 @# Contents of the ramdisk image
5852 $(hide) mkdir -p $(zip_root)/IMAGES
5853 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
5854endif
5855endif
Yifan Hong65afc072020-04-17 10:08:10 -07005856ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08005857ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07005858 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07005859 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07005860endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08005861endif
Doug Zongker8678df42009-06-15 14:30:14 -07005862 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08005863 @# build them.
5864 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07005865 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005866 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005867ifneq ($(tool_extension),)
5868 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
5869endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07005870 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005871 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07005872 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00005873ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
5874 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5875 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005876endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005877ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
5878 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
5879 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005880endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005881ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
5882 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
5883 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005884endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005885ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
5886 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
5887 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01005888endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005889ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
5890 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
5891 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005892endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005893ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
5894 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
5895 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
5896endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005897ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
5898 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
5899 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
5900endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005901ifneq ($(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH),)
5902 $(hide) cp $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
5903 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH))
5904endif
Yifan Hong65afc072020-04-17 10:08:10 -07005905ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07005906ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07005907 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07005908 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07005909endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08005910endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005911ifeq ($(AB_OTA_UPDATER),true)
5912 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07005913 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Kelvin Zhangc06f0622021-11-30 12:38:39 -08005914 $(hide) cp $(TOPDIR)external/zucchini/version_info.h $(zip_root)/META/zucchini_config.txt
Kelvin Zhang6877e812022-01-06 11:12:04 -08005915 $(hide) cp $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so $(zip_root)/META/liblz4.so
Cole Faust90099992022-02-17 11:35:27 -08005916 $(hide) for part in $(sort $(AB_OTA_PARTITIONS)); do \
Alex Deymo8925d332015-10-01 17:38:09 -07005917 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
5918 done
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005919 $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
Sen Jiang8f22e2a2015-11-12 13:53:25 -08005920 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
5921 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005922ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07005923 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
5924 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
5925 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005926endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005927endif
Steve Fungdfbab492015-09-24 18:12:33 -07005928ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07005929 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07005930 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07005931endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07005932ifdef BOARD_PREBUILT_VENDORIMAGE
5933 $(hide) mkdir -p $(zip_root)/IMAGES
5934 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
5935endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005936ifdef BOARD_PREBUILT_PRODUCTIMAGE
5937 $(hide) mkdir -p $(zip_root)/IMAGES
5938 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
5939endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005940ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01005941 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09005942 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01005943endif
Devin Moore380d9e42021-11-04 19:01:19 +00005944ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
Devin Moorecda41f02022-01-05 00:08:39 +00005945 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5946 $(hide) cp $(INSTALLED_INIT_BOOT_IMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Devin Moore380d9e42021-11-04 19:01:19 +00005947endif
Ramji Jiyani034e7772022-01-24 04:00:29 +00005948
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005949ifndef BOARD_PREBUILT_BOOTIMAGE
Yi-Yo Chiang81939002022-01-08 23:46:40 +08005950ifneq (,$(strip $(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES))))
Yifan Hong49968aa2020-11-09 11:52:52 -08005951ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07005952 $(hide) mkdir -p $(zip_root)/IMAGES
5953 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08005954endif # INSTALLED_BOOTIMAGE_TARGET
5955endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005956else # BOARD_PREBUILT_BOOTIMAGE is defined
5957 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5958 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5959endif # BOARD_PREBUILT_BOOTIMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005960ifdef BOARD_PREBUILT_ODMIMAGE
5961 $(hide) mkdir -p $(zip_root)/IMAGES
5962 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
5963endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07005964ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07005965 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07005966 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5967endif
5968ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
5969 $(hide) mkdir -p $(zip_root)/IMAGES
5970 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07005971endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00005972ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
5973 $(hide) mkdir -p $(zip_root)/IMAGES
5974 $(hide) cp $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5975endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07005976ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07005977 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5978 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08005979endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi4bbb8dd2022-01-31 20:25:52 +01005980ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00005981 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5982 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Andrew Scullbbc930b2022-02-17 22:34:27 +00005983 $(hide) cp $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) $(zip_root)/PREBUILT_IMAGES/
Pierre-Clément Tosid8248af2021-10-07 12:18:17 +02005984endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005985ifdef BOARD_PREBUILT_BOOTLOADER
5986 $(hide) mkdir -p $(zip_root)/IMAGES
5987 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
5988endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07005989ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
5990 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5991 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5992 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
5993endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07005994 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
5995 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
5996 @# INSTALLED_RADIOIMAGE_TARGET.
5997 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
5998 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005999 @# Run fs_config on all the system, vendor, boot ramdisk,
6000 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08006001ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006002 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08006003endif
6004ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006005 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
6006endif
Dan Willemsen67495202019-01-16 12:42:05 -08006007ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006008 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
6009endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006010ifdef BUILDING_SYSTEM_EXT_IMAGE
6011 $(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 +01006012endif
Dan Willemsen67495202019-01-16 12:42:05 -08006013ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006014 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
6015endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006016ifdef BUILDING_VENDOR_DLKM_IMAGE
6017 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
6018endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07006019ifdef BUILDING_ODM_DLKM_IMAGE
6020 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
6021endif
Ramji Jiyani13a41372022-01-27 07:05:08 +00006022ifdef BUILDING_SYSTEM_DLKM_IMAGE
6023 $(hide) $(call fs_config,$(zip_root)/SYSTEM_DLKM,system_dlkm/) > $(zip_root)/META/system_dlkm_filesystem_config.txt
6024endif
Tom Cherryd14b8952018-08-09 14:26:00 -07006025 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006026 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Yi-Yo Chiang06c62732022-10-07 21:18:45 +08006027 @# BOOT/RAMDISK contains the first stage and recovery ramdisk.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006028 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Devin Moore380d9e42021-11-04 19:01:19 +00006029ifdef BUILDING_INIT_BOOT_IMAGE
6030 $(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK)
6031 $(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt
6032ifdef BOARD_KERNEL_PAGESIZE
6033 $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize
6034endif # BOARD_KERNEL_PAGESIZE
6035endif # BUILDING_INIT_BOOT_IMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07006036ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
6037 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
6038endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006039ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
6040 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
6041endif
Dan Willemsen67495202019-01-16 12:42:05 -08006042ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08006043 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
6044endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07006045 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07006046ifdef BUILT_KERNEL_CONFIGS_FILE
6047 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
6048endif
6049ifdef BUILT_KERNEL_VERSION_FILE
6050 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
6051endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07006052 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
6053ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6054 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
6055endif
Tao Baocbd6d492019-10-07 22:46:02 -07006056 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
6057 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08006058ifeq ($(BUILD_QEMU_IMAGES),true)
6059 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
6060 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
6061endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08006062 @# Zip everything up, preserving symlinks and placing META/ files first to
6063 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006064 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07006065 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08006066 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07006067
Ying Wanga0febe52013-03-20 11:02:05 -07006068.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08006069target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
6070
Bob Badour5acd4362022-04-12 18:31:35 -07006071$(call declare-1p-container,$(BUILT_TARGET_FILES_PACKAGE),)
6072$(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED_RADIOIMAGE_TARGET) \
6073 $(INSTALLED_RECOVERYIMAGE_TARGET) \
6074 $(INSTALLED_CACHEIMAGE_TARGET) \
6075 $(INSTALLED_DTBOIMAGE_TARGET) \
6076 $(INSTALLED_PVMFWIMAGE_TARGET) \
6077 $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
6078 $(INSTALLED_CUSTOMIMAGES_TARGET) \
6079 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
6080 $(INSTALLED_KERNEL_TARGET) \
6081 $(INSTALLED_RAMDISK_TARGET) \
6082 $(INSTALLED_DTBIMAGE_TARGET) \
6083 $(INSTALLED_2NDBOOTLOADER_TARGET) \
6084 $(BOARD_PREBUILT_DTBOIMAGE) \
6085 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
6086 $(BOARD_RECOVERY_ACPIO) \
6087 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
6088 $(PRODUCT_VENDOR_BASE_FS_PATH) \
6089 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
6090 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
6091 $(PRODUCT_ODM_BASE_FS_PATH) \
6092 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
6093 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
6094 $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
6095 $(LPMAKE) \
6096 $(SELINUX_FC) \
6097 $(INSTALLED_MISC_INFO_TARGET) \
6098 $(APKCERTS_FILE) \
6099 $(SOONG_APEX_KEYS_FILE) \
6100 $(HOST_OUT_EXECUTABLES)/fs_config \
6101 $(ADD_IMG_TO_TARGET_FILES) \
6102 $(MAKE_RECOVERY_PATCH) \
6103 $(BUILT_KERNEL_CONFIGS_FILE) \
6104 $(BUILT_KERNEL_VERSION_FILE),$(BUILT_TARGET_FILES_PACKAGE):)
6105
Ying Wang4709d7c2014-04-14 17:25:43 -07006106$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07006107
Dan Albert4d323332016-10-14 13:23:06 -07006108# -----------------------------------------------------------------
6109# NDK Sysroot Package
6110NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Colin Crossec65b762022-10-20 14:03:47 -07006111.PHONY: ndk_sysroot
6112ndk_sysroot: $(NDK_SYSROOT_TARGET)
Dan Willemsen14e10262018-06-17 21:54:21 -07006113$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07006114 @echo Package NDK sysroot...
6115 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
6116
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006117ifeq ($(HOST_OS),linux)
Colin Crossec65b762022-10-20 14:03:47 -07006118$(call dist-for-goals,sdk ndk_sysroot,$(NDK_SYSROOT_TARGET))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07006119endif
Dan Albert4d323332016-10-14 13:23:06 -07006120
Ying Wang09c4b682015-08-11 11:24:19 -07006121ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07006122# -----------------------------------------------------------------
6123# OTA update package
6124
Yifan Hong50e79542018-11-08 17:44:12 -08006125# $(1): output file
6126# $(2): additional args
6127define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07006128PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07006129 $(OTA_FROM_TARGET_FILES) \
6130 --verbose \
6131 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
6132 --path $(HOST_OUT) \
6133 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
6134 $(2) \
6135 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08006136endef
6137
Tianjie6bd3b1a2020-10-16 18:53:47 -07006138product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07006139ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006140 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07006141endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07006142name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07006143
6144INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08006145INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
6146
Bob Badour5acd4362022-04-12 18:31:35 -07006147$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
6148
Doug Zongker8678df42009-06-15 14:30:14 -07006149$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08006150$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07006151$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07006152 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08006153 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07006154
Bob Badour5acd4362022-04-12 18:31:35 -07006155$(call declare-1p-container,$(INTERNAL_OTA_PACKAGE_TARGET),)
6156$(call declare-container-license-deps,$(INTERNAL_OTA_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6157
Doug Zongker8678df42009-06-15 14:30:14 -07006158.PHONY: otapackage
6159otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
6160
Tao Bao519d1822018-12-27 12:47:23 -08006161ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07006162name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08006163
6164INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08006165$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07006166$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
6167 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07006168 $(OTA_FROM_TARGET_FILES) \
6169 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08006170 @echo "Package OTA (retrofit dynamic partitions): $@"
6171 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
6172
Bob Badour5acd4362022-04-12 18:31:35 -07006173$(call declare-1p-container,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),)
6174$(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)/:/)
6175
Yifan Hong50e79542018-11-08 17:44:12 -08006176.PHONY: otardppackage
6177
6178otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
6179
Tao Bao519d1822018-12-27 12:47:23 -08006180endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08006181
Tianjie6bd3b1a2020-10-16 18:53:47 -07006182ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
6183name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
6184
6185INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6186$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
6187$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
6188 @echo "Package partial OTA: $@"
6189 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
6190
Bob Badour5acd4362022-04-12 18:31:35 -07006191$(call declare-1p-container,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),)
6192$(call declare-container-license-deps,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
6193
6194
Tianjie6bd3b1a2020-10-16 18:53:47 -07006195.PHONY: partialotapackage
6196partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
6197
6198endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
6199
Ying Wang09c4b682015-08-11 11:24:19 -07006200endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07006201
Ying Wang09a00a62010-10-20 14:01:09 -07006202# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01006203# A zip of the appcompat directory containing logs
6204APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
6205# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006206ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07006207$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
6208 $(INTERNAL_RAMDISK_FILES) \
6209 $(INTERNAL_USERDATAIMAGE_FILES) \
6210 $(INTERNAL_VENDORIMAGE_FILES) \
6211 $(INTERNAL_PRODUCTIMAGE_FILES) \
6212 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01006213endif
6214$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
6215$(APPCOMPAT_ZIP): $(SOONG_ZIP)
6216 @echo "appcompat logs: $@"
6217 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6218 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
6219 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
6220 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
6221
Jeongik Cha2522c362021-04-27 23:52:15 +09006222# The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
6223ifeq ($(BUILD_OS),linux)
Jeongik Cha62519de2021-05-13 13:29:39 +09006224ifneq ($(DEX2OAT),)
Saeid Farivar Asanjan0b4f8d52022-08-08 20:23:45 +00006225dexpreopt_tools_deps := $(DEXPREOPT_GEN_DEPS) $(DEXPREOPT_GEN)
Eric Miao1d0fd2c2021-11-08 19:34:50 +00006226dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/dexdump
6227dexpreopt_tools_deps += $(HOST_OUT_EXECUTABLES)/oatdump
Jeongik Cha2522c362021-04-27 23:52:15 +09006228DEXPREOPT_TOOLS_ZIP := $(PRODUCT_OUT)/dexpreopt_tools.zip
6229$(DEXPREOPT_TOOLS_ZIP): $(dexpreopt_tools_deps)
6230$(DEXPREOPT_TOOLS_ZIP): PRIVATE_DEXPREOPT_TOOLS_DEPS := $(dexpreopt_tools_deps)
6231$(DEXPREOPT_TOOLS_ZIP): $(SOONG_ZIP)
6232 $(hide) mkdir -p $(dir $@)
6233 $(hide) $(SOONG_ZIP) -d -o $@ -j $(addprefix -f ,$(PRIVATE_DEXPREOPT_TOOLS_DEPS)) -f $$(realpath $(DEX2OAT))
Bob Badour5acd4362022-04-12 18:31:35 -07006234$(call declare-1p-target,$(DEXPREOPT_TOOLS_ZIP),)
Jeongik Cha62519de2021-05-13 13:29:39 +09006235endif # DEX2OAT is set
6236endif # BUILD_OS == linux
Jeongik Cha2522c362021-04-27 23:52:15 +09006237
Jeongik Chaa8056d62021-04-07 23:57:16 +09006238DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
Jeongik Chab26bf582021-06-08 11:31:31 +09006239
6240$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
6241 $(INSTALLED_VENDORIMAGE_TARGET) \
6242 $(INSTALLED_ODMIMAGE_TARGET) \
6243 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6244
6245ifeq (,$(TARGET_BUILD_UNBUNDLED))
6246$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
6247 $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
6248
6249endif
Jeongik Chaa8056d62021-04-07 23:57:16 +09006250
6251$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
6252 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Chab26bf582021-06-08 11:31:31 +09006253
6254ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006255ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006256 $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006257endif
6258ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09006259 $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09006260endif
Jeongik Chab26bf582021-06-08 11:31:31 +09006261endif #!TARGET_BUILD_UNBUNDLED
Jeongik Chaa8056d62021-04-07 23:57:16 +09006262 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
6263
Jeongik Chab26bf582021-06-08 11:31:31 +09006264.PHONY: dexpreopt_config_zip
6265dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
6266
Bob Badour5acd4362022-04-12 18:31:35 -07006267$(call declare-1p-target,$(DEXPREOPT_CONFIG_ZIP),)
6268
Dario Frenid1011272018-07-23 20:20:15 +01006269# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006270# A zip of the symbols directory. Keep the full paths to make it
6271# more obvious where these files came from.
Colin Crossac7febc2022-04-06 01:11:20 +00006272# Also produces a textproto containing mappings from elf IDs to symbols
6273# filename, which will allow finding the appropriate symbols to deobfuscate
6274# a stack trace frame.
The Android Open Source Project88b60792009-03-03 19:28:42 -08006275#
Colin Crossac7febc2022-04-06 01:11:20 +00006276
The Android Open Source Project88b60792009-03-03 19:28:42 -08006277name := $(TARGET_PRODUCT)
6278ifeq ($(TARGET_BUILD_TYPE),debug)
6279 name := $(name)_debug
6280endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006281
Colin Crossac7febc2022-04-06 01:11:20 +00006282# The path to the zip file containing binaries with symbols.
6283SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols-$(FILE_NAME_TAG).zip
6284# The path to a file containing mappings from elf IDs to filenames.
6285SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping-$(FILE_NAME_TAG).textproto
6286.KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING
Colin Cross6cdc5d22017-10-20 11:37:33 -07006287# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006288ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006289$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07006290endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006291$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
Colin Crossac7febc2022-04-06 01:11:20 +00006292$(SYMBOLS_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,elf_symbol_mapping)
6293$(SYMBOLS_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006294 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07006295 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006296 $(hide) mkdir -p $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE)) $(PRIVATE_MAPPING_PACKAGING_DIR)
6297 # Find all of the files in the symbols directory and zip them into the symbols zip.
Jiyong Park88e09802019-03-21 15:19:16 +09006298 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07006299 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Colin Crossac7febc2022-04-06 01:11:20 +00006300 # Find all of the files in the symbols mapping directory and merge them into the symbols mapping textproto.
6301 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6302 $(hide) $(SYMBOLS_MAP) -merge $(SYMBOLS_MAPPING) -ignore_missing_files @$(PRIVATE_LIST_FILE)
6303$(SYMBOLS_ZIP): .KATI_IMPLICIT_OUTPUTS := $(SYMBOLS_MAPPING)
6304
Bob Badour5acd4362022-04-12 18:31:35 -07006305$(call declare-1p-container,$(SYMBOLS_ZIP),)
6306ifeq (,$(TARGET_BUILD_UNBUNDLED))
6307$(call declare-container-license-deps,$(SYMBOLS_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6308endif
6309
Ryan Campbell81c9d292016-09-12 13:56:50 -07006310# -----------------------------------------------------------------
6311# A zip of the coverage directory.
6312#
Oliver Nguyene91ab232019-04-30 15:14:44 -07006313name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07006314ifeq ($(TARGET_BUILD_TYPE),debug)
6315name := $(name)_debug
6316endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07006317COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006318ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006319$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07006320endif
6321$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
6322$(COVERAGE_ZIP): $(SOONG_ZIP)
6323 @echo "Package coverage: $@"
6324 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
6325 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
6326 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
6327 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006328
Bob Badourf2529722022-03-18 11:34:03 -07006329$(call declare-1p-container,$(COVERAGE_ZIP),)
Bob Badour5acd4362022-04-12 18:31:35 -07006330ifeq (,$(TARGET_BUILD_UNBUNDLED))
Bob Badourf2529722022-03-18 11:34:03 -07006331$(call declare-container-license-deps,$(COVERAGE_ZIP),$(INTERNAL_ALLIMAGE_FILES),$(PRODUCT_OUT)/:/)
Bob Badour5acd4362022-04-12 18:31:35 -07006332endif
Bob Badourf2529722022-03-18 11:34:03 -07006333
6334SYSTEM_NOTICE_DEPS += $(COVERAGE_ZIP)
6335
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006336#------------------------------------------------------------------
6337# Export the LLVM profile data tool and dependencies for Clang coverage processing
6338#
6339ifeq (true,$(CLANG_COVERAGE))
6340 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006341 LLVM_COV := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov
Qing Shend058fc32022-09-30 00:27:58 +00006342 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 -08006343 # Use llvm-profdata.zip for backwards compatibility with tradefed code.
6344 LLVM_COVERAGE_TOOLS_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006345
Pirama Arumuga Nainar4e3d6332022-03-08 22:28:33 -08006346 $(LLVM_COVERAGE_TOOLS_ZIP): $(SOONG_ZIP)
6347 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX) -f $(LLVM_COV)
6348
6349 $(call dist-for-goals,droidcore-unbundled apps_only,$(LLVM_COVERAGE_TOOLS_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08006350endif
6351
The Android Open Source Project88b60792009-03-03 19:28:42 -08006352# -----------------------------------------------------------------
6353# A zip of the Android Apps. Not keeping full path so that we don't
6354# include product names when distributing
6355#
6356name := $(TARGET_PRODUCT)
6357ifeq ($(TARGET_BUILD_TYPE),debug)
6358 name := $(name)_debug
6359endif
6360name := $(name)-apps-$(FILE_NAME_TAG)
6361
6362APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07006363$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006364 @echo "Package apps: $@"
6365 $(hide) rm -rf $@
6366 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006367 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
6368 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00006369 echo "No apps to zip up. Generating empty apps archive." ; \
6370 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006371 else \
Anton Hansson6d814982018-11-26 18:12:05 +00006372 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07006373 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07006374
Ying Wangbc415dd2012-08-15 12:22:44 -07006375ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07006376#------------------------------------------------------------------
6377# An archive of classes for use in generating code-coverage reports
6378# These are the uninstrumented versions of any classes that were
6379# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07006380# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006381
Colin Crossa6bc3a82017-09-27 14:28:41 -07006382JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Colin Cross330b1fe2021-04-06 18:04:06 -07006383$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
6384$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
6385$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
6386$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006387$(JACOCO_REPORT_CLASSES_ALL) :
6388 @echo "Collecting uninstrumented classes"
Colin Cross330b1fe2021-04-06 18:04:06 -07006389 mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
6390 $(SOONG_ZIP) -o $@ -L 0 \
6391 -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
6392 -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
6393 -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
6394 -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006395
Jiyong Park3c875602021-01-21 12:46:56 +09006396ifeq (,$(TARGET_BUILD_UNBUNDLED))
6397 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
6398endif
Ying Wangbc415dd2012-08-15 12:22:44 -07006399endif # EMMA_INSTRUMENT=true
6400
Jeff Gastonaaae43c2017-04-11 16:36:46 -07006401
Ying Wangae9115a2013-08-22 20:52:47 -07006402#------------------------------------------------------------------
6403# A zip of Proguard obfuscation dictionary files.
Colin Crossac7febc2022-04-06 01:11:20 +00006404# Also produces a textproto containing mappings from the hashes of the
6405# dictionary contents (which are also stored in the dex files on the
6406# devices) to the filename of the proguard dictionary, which will allow
6407# finding the appropriate dictionary to deobfuscate a stack trace frame.
Ying Wangae9115a2013-08-22 20:52:47 -07006408#
Colin Crossac7febc2022-04-06 01:11:20 +00006409
6410# The path to the zip file containing proguard dictionaries.
Ying Wangc62c92c2013-08-28 18:38:25 -07006411PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Crossac7febc2022-04-06 01:11:20 +00006412# The path to the zip file containing mappings from dictionary hashes to filenames.
6413PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping-$(FILE_NAME_TAG).textproto
6414.KATI_READONLY := PROGUARD_DICT_ZIP PROGUARD_DICT_MAPPING
Colin Cross114e8df2019-09-05 17:19:35 -07006415# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01006416ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09006417$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07006418endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006419$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
Colin Crossac7febc2022-04-06 01:11:20 +00006420$(PROGUARD_DICT_ZIP): PRIVATE_MAPPING_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_mapping)
6421$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_dictionary_filelist)/filelist
6422$(PROGUARD_DICT_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP)
Ying Wangae9115a2013-08-22 20:52:47 -07006423 @echo "Packaging Proguard obfuscation dictionary files."
Colin Crossac7febc2022-04-06 01:11:20 +00006424 rm -rf $@ $(PRIVATE_LIST_FILE)
6425 mkdir -p $(PRIVATE_PACKAGING_DIR) $(PRIVATE_MAPPING_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6426 # Zip all of the files in the proguard dictionary directory.
6427 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -D $(PRIVATE_PACKAGING_DIR)
6428 # Find all of the files in the proguard dictionary mapping directory and merge them into the mapping textproto.
6429 # Strip the PRIVATE_PACKAGING_DIR off the filenames to match soong_zip's -C argument.
6430 $(hide) find -L $(PRIVATE_MAPPING_PACKAGING_DIR) -type f | sort >$(PRIVATE_LIST_FILE)
6431 $(SYMBOLS_MAP) -merge $(PROGUARD_DICT_MAPPING) -strip_prefix $(PRIVATE_PACKAGING_DIR)/ -ignore_missing_files @$(PRIVATE_LIST_FILE)
6432$(PROGUARD_DICT_ZIP): .KATI_IMPLICIT_OUTPUTS := $(PROGUARD_DICT_MAPPING)
Ying Wangae9115a2013-08-22 20:52:47 -07006433
Bob Badour5acd4362022-04-12 18:31:35 -07006434$(call declare-1p-container,$(PROGUARD_DICT_ZIP),)
6435ifeq (,$(TARGET_BUILD_UNBUNDLED))
6436$(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
6437endif
6438
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006439#------------------------------------------------------------------
6440# A zip of Proguard usage files.
6441#
6442PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
6443# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
6444ifeq (,$(TARGET_BUILD_UNBUNDLED))
6445$(PROGUARD_USAGE_ZIP): \
6446 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6447 $(INSTALLED_RAMDISK_TARGET) \
6448 $(INSTALLED_BOOTIMAGE_TARGET) \
Devin Moore380d9e42021-11-04 19:01:19 +00006449 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006450 $(INSTALLED_USERDATAIMAGE_TARGET) \
6451 $(INSTALLED_VENDORIMAGE_TARGET) \
6452 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6453 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6454 $(INSTALLED_ODMIMAGE_TARGET) \
6455 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6456 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Ramji Jiyani13a41372022-01-27 07:05:08 +00006457 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006458 $(updater_dep)
6459endif
Colin Cross330b1fe2021-04-06 18:04:06 -07006460$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
6461$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006462$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
6463 @echo "Packaging Proguard usage files."
Colin Cross330b1fe2021-04-06 18:04:06 -07006464 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
6465 find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07006466 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07006467
Bob Badour5acd4362022-04-12 18:31:35 -07006468$(call declare-1p-container,$(PROGUARD_USAGE_ZIP),)
6469ifeq (,$(TARGET_BUILD_UNBUNDLED))
6470$(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(INSTALLED_SYSTEMIMAGE_TARGET) \
6471 $(INSTALLED_RAMDISK_TARGET) \
6472 $(INSTALLED_BOOTIMAGE_TARGET) \
6473 $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
6474 $(INSTALLED_USERDATAIMAGE_TARGET) \
6475 $(INSTALLED_VENDORIMAGE_TARGET) \
6476 $(INSTALLED_PRODUCTIMAGE_TARGET) \
6477 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
6478 $(INSTALLED_ODMIMAGE_TARGET) \
6479 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
6480 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
6481 $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
6482 $(updater_dep),$(PROGUARD_USAGE_ZIP):/)
6483endif
6484
Tao Bao48a2feb2019-06-28 11:00:05 -07006485ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
6486
6487# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
6488# $(1): output file
6489define dump-super-image-info
6490 $(call dump-dynamic-partitions-info,$(1))
6491 $(if $(filter true,$(AB_OTA_UPDATER)), \
6492 echo "ab_update=true" >> $(1))
6493endef
6494
6495endif # PRODUCT_USE_DYNAMIC_PARTITIONS
6496
The Android Open Source Project88b60792009-03-03 19:28:42 -08006497# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07006498# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08006499
6500ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6501
6502# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
6503ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6504
6505ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07006506
6507# For real devices and for dist builds, build super image from target files to an intermediate directory.
6508INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
6509$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
6510$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
6511 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08006512 PATH=$(dir $(LPMAKE)):$$PATH \
6513 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07006514
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006515# Skip packing it in dist package because it is in update package.
6516ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07006517$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006518endif
Yifan Hongacd862a2019-04-16 15:44:30 -07006519
6520.PHONY: superimage_dist
6521superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07006522
6523endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07006524endif # BOARD_SUPER_PARTITION_SIZE != ""
6525endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08006526
Yifan Hongacd862a2019-04-16 15:44:30 -07006527# -----------------------------------------------------------------
6528# super partition image for development
6529
6530ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
6531ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
6532ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
6533
6534# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
6535# $(1): built image path
6536# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
6537define build-superimage-target
6538 mkdir -p $(dir $(2))
6539 rm -rf $(2)
6540 $(call dump-super-image-info,$(2))
6541 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
6542 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09006543 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
6544 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07006545 mkdir -p $(dir $(1))
6546 PATH=$(dir $(LPMAKE)):$$PATH \
6547 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
6548endef
6549
6550INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
6551INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
6552 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
6553
changho.shina8f9f112019-10-15 13:26:19 +09006554ifdef BUILDING_SYSTEM_OTHER_IMAGE
6555ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
6556INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
6557endif
6558endif
6559
Yifan Hongacd862a2019-04-16 15:44:30 -07006560$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6561 $(call pretty,"Target super fs image for debug: $@")
6562 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08006563 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006564
Yifan Hongacd862a2019-04-16 15:44:30 -07006565# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
6566.PHONY: superimage
6567superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08006568
Peter Collingbourne683c4932022-07-06 15:49:20 -07006569# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
6570# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
6571# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
6572# virtual devices.
6573ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
6574droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
6575
Isaac Chen52cc60c2019-08-14 18:52:13 +08006576$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07006577endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
6578
6579# Build $(PRODUCT_OUT)/super.img without dependencies.
6580.PHONY: superimage-nodeps supernod
6581superimage-nodeps supernod: intermediates :=
6582superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
6583 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
6584 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
6585 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
6586
6587endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
6588endif # BOARD_SUPER_PARTITION_SIZE != ""
6589endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
6590
6591# -----------------------------------------------------------------
6592# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00006593ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006594
Yifan Hong8b79d162018-11-29 12:32:00 -08006595INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
6596$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
6597$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
6598 $(call pretty,"Target empty super fs image: $@")
6599 mkdir -p $(intermediates)
6600 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07006601 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08006602 PATH=$(dir $(LPMAKE)):$$PATH \
6603 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08006604
6605$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6606
Bob Badourebdefc02022-02-12 15:39:22 -08006607$(call declare-0p-target,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
6608
Yo Chiange86bab42021-03-25 10:12:28 +00006609endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08006610
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006611
6612# -----------------------------------------------------------------
6613# The update package
6614
6615name := $(TARGET_PRODUCT)
6616ifeq ($(TARGET_BUILD_TYPE),debug)
6617 name := $(name)_debug
6618endif
6619name := $(name)-img-$(FILE_NAME_TAG)
6620
6621INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6622
Tao Bao57f8ed62019-08-14 23:08:18 -07006623$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
6624 $(call pretty,"Package: $@")
6625 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
6626 $(IMG_FROM_TARGET_FILES) \
6627 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
6628 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006629
Bob Badour5acd4362022-04-12 18:31:35 -07006630$(call declare-1p-container,$(INTERNAL_UPDATE_PACKAGE_TARGET),)
6631$(call declare-container-license-deps,$(INTERNAL_UPDATE_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES),$(PRODUCT_OUT)/:/)
6632
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006633.PHONY: updatepackage
6634updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07006635$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07006636
6637
Yifan Hong2b891ac2018-11-29 12:06:31 -08006638# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006639# dalvik something
6640.PHONY: dalvikfiles
6641dalvikfiles: $(INTERNAL_DALVIK_MODULES)
6642
Bo Huf0d50bb2017-08-01 19:02:09 +00006643ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00006644MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08006645MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00006646SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08006647
6648ifdef INSTALLED_SYSTEMIMAGE_TARGET
6649INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08006650INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
6651$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
6652 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
6653 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08006654$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08006655 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
6656 @echo Create system-qemu.img now
6657 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08006658 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00006659
6660systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006661droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08006662endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006663ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00006664INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006665$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00006666 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006667 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00006668
6669vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006670droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
Bo Huf0d50bb2017-08-01 19:02:09 +00006671endif
bohu8fd437c2020-03-30 20:16:13 -07006672
6673ifdef INSTALLED_RAMDISK_TARGET
6674ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
6675ifdef INTERNAL_VENDOR_RAMDISK_TARGET
6676INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
6677$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
6678 @echo Create ramdisk-qemu.img
6679 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
6680
Bill Peckham315b98a2021-06-15 19:35:06 -07006681droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
bohu8fd437c2020-03-30 20:16:13 -07006682endif
6683endif
6684endif
6685
Anton Hansson32c76fe2018-12-13 14:34:18 +00006686ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006687INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00006688$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006689 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006690 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006691
6692productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006693droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09006694endif
Justin Yun6151e3f2019-06-25 15:58:13 +09006695ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
6696INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
6697$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
6698 @echo Create system_ext-qemu.img
6699 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01006700
Justin Yun6151e3f2019-06-25 15:58:13 +09006701systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006702droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01006703endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00006704ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006705INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
6706$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6707 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08006708 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006709
6710odmimage: $(INSTALLED_QEMU_ODMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006711droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08006712endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006713
Yifan Hongcfb917a2020-05-07 14:58:20 -07006714ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
6715INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
6716$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6717 @echo Create vendor_dlkm-qemu.img
6718 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
6719
6720vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006721droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07006722endif
6723
Yifan Hongf496f1b2020-07-15 16:52:59 -07006724ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
6725INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
6726$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6727 @echo Create odm_dlkm-qemu.img
6728 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
6729
6730odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07006731droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07006732endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07006733
Ramji Jiyani13a41372022-01-27 07:05:08 +00006734ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
6735INSTALLED_QEMU_SYSTEM_DLKMIMAGE := $(PRODUCT_OUT)/system_dlkm-qemu.img
6736$(INSTALLED_QEMU_SYSTEM_DLKMIMAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
6737 @echo Create system_dlkm-qemu.img
6738 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET))
6739
6740system_dlkmimage: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6741droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
6742endif
6743
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006744QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08006745$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
6746 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006747 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08006748 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
6749 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07006750
6751systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
Bill Peckham315b98a2021-06-15 19:35:06 -07006752droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08006753
Bo Huf0d50bb2017-08-01 19:02:09 +00006754endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006755# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08006756# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07006757ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006758INTERNAL_EMULATOR_PACKAGE_FILES += \
6759 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006760 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07006761 $(INSTALLED_SYSTEMIMAGE_TARGET) \
6762 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006763
6764name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
6765
6766INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
6767
Ying Wang5d887702015-11-04 10:06:25 -08006768$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006769 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07006770 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006771
Ying Wang7d8c5352012-07-26 10:15:21 -07006772endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08006773
The Android Open Source Project88b60792009-03-03 19:28:42 -08006774
6775# -----------------------------------------------------------------
6776# The SDK
6777
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006778ifneq ($(filter sdk,$(MAKECMDGOALS)),)
6779
The Android Open Source Project88b60792009-03-03 19:28:42 -08006780# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07006781sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006782
6783# Build a name that looks like:
6784#
6785# linux-x86 --> android-sdk_12345_linux-x86
6786# darwin-x86 --> android-sdk_12345_mac-x86
6787# windows-x86 --> android-sdk_12345_windows
6788#
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006789ifneq ($(HOST_OS),linux)
6790 $(error Building the monolithic SDK is only supported on Linux)
6791endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08006792sdk_name := android-sdk_$(FILE_NAME_TAG)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006793INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH)
Joe Onorato03fbe402009-04-13 08:31:16 -07006794sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006795
6796sdk_dep_file := $(sdk_dir)/sdk_deps.mk
6797
6798ATREE_FILES :=
6799-include $(sdk_dep_file)
6800
6801# if we don't have a real list, then use "everything"
6802ifeq ($(strip $(ATREE_FILES)),)
6803ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006804 $(ALL_DOCS) \
6805 $(ALL_SDK_FILES)
6806endif
6807
6808atree_dir := development/build
6809
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01006810
Dan Willemsen53c98f72021-10-16 16:49:06 -07006811sdk_atree_files := $(atree_dir)/sdk.exclude.atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08006812
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02006813# development/build/sdk-android-<abi>.atree is used to differentiate
6814# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
6815# files like the kernel image. We use TARGET_CPU_ABI because we don't
6816# have a better way to distinguish between CPU models.
6817ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
6818 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
6819endif
6820
Anton Hansson8dab0a62019-03-28 15:45:40 +00006821ifneq ($(PRODUCT_SDK_ATREE_FILES),)
6822sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08006823else
6824sdk_atree_files += $(atree_dir)/sdk.atree
6825endif
6826
The Android Open Source Project88b60792009-03-03 19:28:42 -08006827deps := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006828 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01006829 $(SDK_METADATA_FILES) \
Anton Hansson55a8f022022-05-12 08:45:29 +00006830 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006831 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08006832 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006833 $(HOST_OUT_EXECUTABLES)/atree \
Jerome Gaillardcf713d42019-10-23 11:43:26 +01006834 $(HOST_OUT_EXECUTABLES)/line_endings
The Android Open Source Project88b60792009-03-03 19:28:42 -08006835
Anton Hansson874dbe72022-10-26 15:00:55 +00006836# The name of the subdir within the platforms dir of the sdk. One of:
6837# - android-<SDK_INT> (stable base dessert SDKs)
6838# - android-<CODENAME> (stable extension SDKs)
6839# - android-<SDK_INT>-ext<EXT_INT> (codename SDKs)
6840sdk_platform_dir_name := $(strip \
6841 $(if $(filter REL,$(PLATFORM_VERSION_CODENAME)), \
6842 $(if $(filter $(PLATFORM_SDK_EXTENSION_VERSION),$(PLATFORM_BASE_SDK_EXTENSION_VERSION)), \
6843 android-$(PLATFORM_SDK_VERSION), \
6844 android-$(PLATFORM_SDK_VERSION)-ext$(PLATFORM_SDK_EXTENSION_VERSION) \
6845 ), \
6846 android-$(PLATFORM_VERSION_CODENAME) \
6847 ) \
6848)
6849
The Android Open Source Project88b60792009-03-03 19:28:42 -08006850INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
6851$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
6852$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
6853$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
6854$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
Anton Hansson874dbe72022-10-26 15:00:55 +00006855$(INTERNAL_SDK_TARGET): PRIVATE_PLATFORM_NAME := $(sdk_platform_dir_name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006856# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
6857#
6858#SDK_GNU_ERROR := true
6859
Ying Wang5d887702015-11-04 10:06:25 -08006860$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006861 @echo "Package SDK: $@"
6862 $(hide) rm -rf $(PRIVATE_DIR) $@
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07006863 $(hide) for f in $(strip $(target_gnu_MODULES)); do \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006864 if [ -f $$f ]; then \
6865 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
6866 including GNU target $$f >&2; \
6867 FAIL=$(SDK_GNU_ERROR); \
6868 fi; \
6869 done; \
6870 if [ $$FAIL ]; then exit 1; fi
6871 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00006872 ATREE_STRIP="$(HOST_STRIP) -x" \
6873 $(HOST_OUT_EXECUTABLES)/atree \
6874 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
6875 -m $(PRIVATE_DEP_FILE) \
6876 -I . \
6877 -I $(PRODUCT_OUT) \
6878 -I $(HOST_OUT) \
6879 -I $(TARGET_COMMON_OUT_ROOT) \
Anton Hansson874dbe72022-10-26 15:00:55 +00006880 -v "PLATFORM_NAME=$(PRIVATE_PLATFORM_NAME)" \
Anton Hansson6d814982018-11-26 18:12:05 +00006881 -v "OUT_DIR=$(OUT_DIR)" \
6882 -v "HOST_OUT=$(HOST_OUT)" \
6883 -v "TARGET_ARCH=$(TARGET_ARCH)" \
6884 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
6885 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
Anton Hansson6d814982018-11-26 18:12:05 +00006886 -o $(PRIVATE_DIR) && \
Anton Hansson6d814982018-11-26 18:12:05 +00006887 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
6888 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
6889 chmod -R ug+rwX $(PRIVATE_DIR) && \
6890 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006891 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
6892
Raphaelc4d47312011-02-15 16:09:36 -08006893MAIN_SDK_DIR := $(sdk_dir)
6894MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Dan Willemsen39b81cd2021-09-16 14:23:07 -07006895
6896endif # sdk in MAKECMDGOALS
Raphael3d224a02010-04-16 17:50:09 -07006897
The Android Open Source Project88b60792009-03-03 19:28:42 -08006898# -----------------------------------------------------------------
6899# Findbugs
6900INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
6901INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
6902$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
6903 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006904 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08006905 > $@
6906$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
6907 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09006908 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07006909 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08006910
6911# -----------------------------------------------------------------
6912# Findbugs
6913
6914# -----------------------------------------------------------------
6915# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07006916ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006917include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01006918-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07006919-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006920-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07006921# Also the project-specific tasks
6922-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
6923-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006924-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07006925# Also add test specifc tasks
6926include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07006927include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07006928endif
Raphaelc4d47312011-02-15 16:09:36 -08006929
Ying Wang67132ba2015-10-28 16:42:39 -07006930include $(BUILD_SYSTEM)/product-graph.mk
6931
Raphaelc4d47312011-02-15 16:09:36 -08006932# -----------------------------------------------------------------
6933# Create SDK repository packages. Must be done after tasks/* since
6934# we need the addon rules defined.
6935ifneq ($(sdk_repo_goal),)
6936include $(TOPDIR)development/build/tools/sdk_repo.mk
6937endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07006938
6939# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07006940# Soong generates the list of all shared libraries that are depended on by fuzz
6941# targets. It saves this list as a source:destination pair to
6942# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
6943# build of the unstripped shared library, and the destination is the
6944# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
6945# where fuzz target shared libraries are to be "reinstalled". The
6946# copy-many-files below generates the rules to copy the unstripped shared
6947# libraries to the device or host "reinstallation" directory. These rules are
6948# depended on by each module in soong_cc_prebuilt.mk, where the module will have
6949# a dependency on each shared library that it needs to be "reinstalled".
6950FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
6951
6952# -----------------------------------------------------------------
hamzeh5dfe7a22021-04-29 12:44:16 -07006953# The rule to build all fuzz targets for C++ and Rust, and package them.
Mitch Phillipsceefc442019-09-26 16:37:59 -07006954# Note: The packages are created in Soong, and in a perfect world,
6955# we'd be able to create the phony rule there. But, if we want to
6956# have dist goals for the fuzz target, we need to have the PHONY
6957# target defined in make. MakeVarsContext.DistForGoal doesn't take
6958# into account that a PHONY rule create by Soong won't be available
6959# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08006960# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07006961# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08006962.PHONY: haiku
6963haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
6964$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00006965$(call dist-for-goals,haiku,$(PRODUCT_OUT)/module-info.json)
hamzeh5dfe7a22021-04-29 12:44:16 -07006966
Muhammad Haseeb Ahmade3a89402022-10-13 21:19:06 +00006967.PHONY: haiku-java-device
6968haiku-java-device: $(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_DEVICE_TARGETS)
6969$(call dist-for-goals,haiku-java-device,$(SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES))
6970$(call dist-for-goals,haiku-java-device,$(PRODUCT_OUT)/module-info.json)
6971
6972.PHONY: haiku-java-host
6973haiku-java-host: $(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_HOST_TARGETS)
6974$(call dist-for-goals,haiku-java-host,$(SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES))
6975$(call dist-for-goals,haiku-java-host,$(PRODUCT_OUT)/module-info.json)
Muhammad Haseeb Ahmadcced1362022-01-13 03:17:39 +00006976
hamzeh5dfe7a22021-04-29 12:44:16 -07006977.PHONY: haiku-rust
6978haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
6979$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))
Markf7ffdac2022-10-04 20:09:44 +00006980$(call dist-for-goals,haiku-rust,$(PRODUCT_OUT)/module-info.json)
Jerome Gaillardcf713d42019-10-23 11:43:26 +01006981
6982# -----------------------------------------------------------------
6983# Extract platform fonts used in Layoutlib
6984include $(BUILD_SYSTEM)/layoutlib_fonts.mk
Bob Badourebdefc02022-02-12 15:39:22 -08006985
6986
6987# -----------------------------------------------------------------
6988# OS Licensing
6989
6990include $(BUILD_SYSTEM)/os_licensing.mk
6991
6992# When appending new code to this file, please insert above OS Licensing