blob: e1f20f015ab696de9fb1f5a525d7f853f6fb3998 [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
The Android Open Source Project88b60792009-03-03 19:28:42 -08007# -----------------------------------------------------------------
8# Define rules to copy PRODUCT_COPY_FILES defined by the product.
Ying Wang4b0486b2012-09-20 16:35:36 -07009# PRODUCT_COPY_FILES contains words like <source file>:<dest file>[:<owner>].
The Android Open Source Project88b60792009-03-03 19:28:42 -080010# <dest file> is relative to $(PRODUCT_OUT), so it should look like,
11# e.g., "system/etc/file.xml".
Jean-Baptiste Queru518ce572010-03-01 16:18:59 -080012# The filter part means "only eval the copy-one-file rule if this
Ying Wang462d26b2010-11-02 21:31:47 -070013# src:dest pair is the first one to match the same dest"
Ying Wang68864102011-09-29 13:23:25 -070014#$(1): the src:dest pair
Dan Willemsen7d957c92018-04-30 16:01:33 -070015#$(2): the dest
Ying Wang68864102011-09-29 13:23:25 -070016define check-product-copy-files
Dan Willemsen7d957c92018-04-30 16:01:33 -070017$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
18 $(if $(filter %.apk, $(2)),$(error \
Yifan Hong5e57a772020-01-09 16:15:11 -080019 Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
20$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
21 $(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
22 $(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
23 $(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
24 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
25 $(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
26 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
27 use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
28 $(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
29 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
30 use vintf_compatibility_matrix / vintf_fragments instead!)) \
31 $(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
32 $(TARGET_COPY_OUT_VENDOR)/manifest.xml \
33 $(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
34 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
35 use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
36 $(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
37 $(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
38 $(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
39 use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
40)
Ying Wang68864102011-09-29 13:23:25 -070041endef
Yo Chiang0b49c032020-03-17 17:49:49 +080042
Yo Chiang336883a2020-05-14 17:17:29 +080043# Phony target to check PRODUCT_COPY_FILES copy pairs don't contain ELF files
44.PHONY: check-elf-prebuilt-product-copy-files
45check-elf-prebuilt-product-copy-files:
46
Yo Chiang0b49c032020-03-17 17:49:49 +080047check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080048ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
49check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080050endif
51check_elf_prebuilt_product_copy_files_hint := \
52 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
53
Ying Wang619fccf2012-09-05 18:08:29 -070054# filter out the duplicate <source file>:<dest file> pairs.
55unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080056$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070057 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
58 $(eval unique_product_copy_files_pairs += $(cf))))
59unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080060product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070061$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070062 $(eval _src := $(call word-colon,1,$(cf))) \
63 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070064 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080065 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080066 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070067 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070068 $(if $(filter %.xml,$(_dest)),\
69 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010070 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
71 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070072 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
73 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080074 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
75 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
76 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
77 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070078 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080079
80# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070081pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
82$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
83$(pcf_ignored_file):
84 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080085
Bill Peckham315b98a2021-06-15 19:35:06 -070086$(call dist-for-goals,droidcore-unbundled,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
Dan Willemsen7537fd02018-10-16 23:15:08 -070087
88pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080089product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070090unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070091unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080092
93# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080094# Returns the max allowed size for an image suitable for hash verification
95# (e.g., boot.img, recovery.img, etc).
96# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
97# $(1): partition size to flash the image
98define get-hash-image-max-size
99$(if $(1), \
100 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
101 $(eval _hash_meta_size := 69632), \
102 $(eval _hash_meta_size := 0)) \
103 $(1)-$(_hash_meta_size))
104endef
105
106# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800107# Define rules to copy headers defined in copy_headers.mk
108# If more than one makefile declared a header, print a warning,
109# then copy the last one defined. This matches the previous make
110# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700111has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800112$(foreach dest,$(ALL_COPIED_HEADERS), \
113 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800114 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800115 $(if $(call streq,$(_src),$(_srcs)),, \
116 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800117 $(warning _ Using $(_src)) \
118 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
119 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
120 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
121 $(warning _ Ignoring $(src)) \
122 $(warning __ from $(firstword $(_makefiles))) \
123 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
124 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800125 $(eval $(call copy-one-header,$(_src),$(dest))))
126all_copied_headers: $(ALL_COPIED_HEADERS)
127
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700128ifdef has_dup_copy_headers
129 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700130 $(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 -0700131endif
132
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800133$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
134
Dan Willemsen6f60f022016-02-23 13:40:07 -0800135# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800136# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100137ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800138gen := $(OUT_DOCS)/index.html
139ALL_DOCS += $(gen)
140$(gen): frameworks/base/docs/docs-redirect-index.html
141 @mkdir -p $(dir $@)
142 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700143endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800144
Dan Albert303e6032017-10-04 10:20:20 -0700145ndk_doxygen_out := $(OUT_NDK_DOCS)
146ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
147ndk_docs_src_dir := frameworks/native/docs
148ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
149ifneq ($(wildcard $(ndk_docs_src_dir)),)
150ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
151 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
152$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
153 @mkdir -p $(ndk_doxygen_out)
154 @echo "Generating NDK docs to $(ndk_doxygen_out)"
155 @( cat $(ndk_doxyfile); \
156 echo "INPUT=$(ndk_headers)"; \
157 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
158 ) | doxygen -
159
160# Note: Not a part of the docs target because we don't have doxygen available.
161# You can run this target locally if you have doxygen installed.
162ndk-docs: $(ndk_doxygen_out)/index.html
163.PHONY: ndk-docs
164endif
165
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700166ifeq ($(HOST_OS),linux)
Colin Crossd60401a2019-04-18 14:46:48 -0700167$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700168endif
Dan Willemsenad6a1542018-12-14 01:04:19 -0800169
Andres Moralesb8876e12015-05-06 20:44:22 -0700170INSTALLED_RECOVERYIMAGE_TARGET :=
Yifan Hong881df392020-10-09 14:29:39 -0700171# Build recovery image if
172# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
173# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
174# with recovery resources.
175# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
176# but not the final recovery image.
Chris Grossa784ef12019-04-22 11:09:57 -0700177ifdef BUILDING_RECOVERY_IMAGE
178ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong881df392020-10-09 14:29:39 -0700179ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -0700180INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
181endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700182endif
Yifan Hong881df392020-10-09 14:29:39 -0700183endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700184
Jiyong Parke1346862020-05-18 14:31:30 +0900185include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100186
187# ----------------------------------------------------------------
188
189# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800190# sdk-build.prop
191#
192# There are certain things in build.prop that we don't want to
193# ship with the sdk; remove them.
194
195# This must be a list of entire property keys followed by
196# "=" characters, without any internal spaces.
197sdk_build_prop_remove := \
198 ro.build.user= \
199 ro.build.host= \
200 ro.product.brand= \
201 ro.product.manufacturer= \
202 ro.product.device=
203# TODO: Remove this soon-to-be obsolete property
204sdk_build_prop_remove += ro.build.product=
205INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
206$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
207 @echo SDK buildinfo: $@
208 @mkdir -p $(dir $@)
209 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000210 $(sdk_build_prop_remove)))" $< > $@.tmp
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700211 $(hide) for x in $(strip $(sdk_build_prop_remove)); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000212 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800213 $(hide) mv $@.tmp $@
214
215# -----------------------------------------------------------------
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800216# declare recovery ramdisk files
217ifeq ($(BUILDING_RECOVERY_IMAGE),true)
218INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
219endif
220
221# -----------------------------------------------------------------
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800222# Declare vendor ramdisk fragments
223INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
224
Yi-Yo Chiang12f92442021-04-04 16:12:25 +0800225ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
226 ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
227 $(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \
228 BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set)
229 endif
230 INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery
231 VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT)
232 VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
233 BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY
234 .KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR
235endif
236
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800237# Validation check and assign default --ramdisk_type.
238$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
239 $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
240 $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
241 $(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))) \
242 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
243 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
244 $(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
245 $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
246 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
247)
248
249# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
250$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
251 $(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
252 $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
253 $(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)) \
254 $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
255 ) \
256)
257INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
258
Yi-Yo Chiang378b7792021-04-09 20:09:13 +0800259# Strip the list in case of any whitespace.
260INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \
261 $(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS))
262
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800263# Assign --ramdisk_name for each vendor ramdisk fragment.
264$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
265 $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
266 $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
267 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
268 $(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
269)
270
271# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700272# kernel modules
273
274# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
275DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
276
J. Avilaa2ceec62020-05-12 23:40:02 +0000277define copy-and-strip-kernel-module
278$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000279 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000280endef
281
Colin Cross4f60e362019-06-05 11:53:43 -0700282# $(1): modules list
283# $(2): output dir
284# $(3): mount point
285# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700286# $(5): module load list
287# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800288# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000289# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700290# $(9): module directory name
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800291# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700292define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700293 $(if $(9), \
294 $(eval _dir := $(9)/), \
295 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000296 $(foreach module,$(1), \
297 $(eval _src := $(module)) \
298 $(if $(8), \
299 $(eval _src := $(8)/$(notdir $(module))) \
300 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700301 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700302 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700303 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
304 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
305 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
306 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700307endef
308
309# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700310# $(2): mount point
311# $(3): staging dir
312# $(4): module load list
313# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800314# $(6): module archive
315# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700316# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800317# TODO(b/144844424): If a module archive is being used, this step (which
318# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
319# the output directory. This should be moved to a module with a
320# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
321# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700322define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700323$(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 -0700324$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700325$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
Steve Muckle474e4d02019-06-19 12:56:48 -0700326$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700327$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700328$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -0700329$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
Steve Muckle474e4d02019-06-19 12:56:48 -0700330$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800331$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
332$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
333$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700334 @echo depmod $$(PRIVATE_STAGING_DIR)
335 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700336 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800337 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700338 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800339 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700340 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800341 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
342 )
343 $(if $(1),\
344 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
345 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
346 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
347 done; \
348 )
Colin Cross4f60e362019-06-05 11:53:43 -0700349 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
350 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700351 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
352 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700353endef
354
Steve Muckle474e4d02019-06-19 12:56:48 -0700355# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700356# $(2): modules list
357# $(3): module load list
358# $(4): module load list filename
359# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700360define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700361 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
362 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700363endef
364
365# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700366# $(2): modules list
367# $(3): module load list
368# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700369define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700370$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
371$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
372 @echo load-list $$(@)
373 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700374endef
375
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800376# $(1): source options file
377# $(2): destination pathname
378# Returns a build rule that checks the syntax of and installs a kernel modules
379# options file. Strip and squeeze any extra space and blank lines.
380# For use via $(eval).
381define build-image-kernel-modules-options-file
382$(2): $(1)
383 @echo "libmodprobe options $$(@)"
384 $(hide) mkdir -p "$$(dir $$@)"
385 $(hide) rm -f "$$@"
386 $(hide) awk <"$$<" >"$$@" \
387 '/^#/ { print; next } \
388 NF == 0 { next } \
389 NF < 2 || $$$$1 != "options" \
390 { print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
391 exit_status = 1; next } \
392 { $$$$1 = $$$$1; print } \
393 END { exit exit_status }'
394endef
395
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800396# $(1): source blocklist file
397# $(2): destination pathname
398# Returns a build rule that checks the syntax of and installs a kernel modules
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800399# blocklist file. Strip and squeeze any extra space and blank lines.
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800400# For use via $(eval).
401define build-image-kernel-modules-blocklist-file
402$(2): $(1)
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800403 @echo "libmodprobe blocklist $$(@)"
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800404 $(hide) mkdir -p "$$(dir $$@)"
405 $(hide) rm -f "$$@"
406 $(hide) awk <"$$<" >"$$@" \
407 '/^#/ { print; next } \
408 NF == 0 { next } \
409 NF != 2 || $$$$1 != "blocklist" \
410 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
411 exit_status = 1; next } \
412 { $$$$1 = $$$$1; print } \
413 END { exit exit_status }'
414endef
415
Steve Muckle2335d762020-05-28 18:39:38 -0700416# $(1): image name
417# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
418# $(3): mount point
419# $(4): module load filename
420# $(5): stripped staging directory
421# $(6): kernel module directory name (top is an out of band value for no directory)
422define build-image-kernel-modules-dir
423$(if $(filter top,$(6)),\
424 $(eval _kver :=)$(eval _sep :=),\
425 $(eval _kver := $(6))$(eval _sep :=_))\
426$(if $(5),\
427 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
428 $(eval _stripped_staging_dir :=))\
429$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
430 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
431 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800432 $(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 +0800433$(if $(_kver), \
434 $(eval _dir := $(_kver)/), \
435 $(eval _dir :=)) \
436$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
437 $(eval $(call build-image-kernel-modules-options-file, \
438 $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
439 $(2)/lib/modules/$(_dir)modules.options)) \
440 $(2)/lib/modules/$(_dir)modules.options) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800441$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
442 $(eval $(call build-image-kernel-modules-blocklist-file, \
443 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
Yi-Yo Chiang6c7e02e2021-04-04 21:30:48 +0800444 $(2)/lib/modules/$(_dir)modules.blocklist)) \
445 $(2)/lib/modules/$(_dir)modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700446endef
447
448# $(1): kernel module directory name (top is an out of band value for no directory)
449define build-recovery-as-boot-load
450$(if $(filter top,$(1)),\
451 $(eval _kver :=)$(eval _sep :=),\
452 $(eval _kver := $(1))$(eval _sep :=_))\
453 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
454 $(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))))
455endef
456
457# $(1): kernel module directory name (top is an out of band value for no directory)
458define build-vendor-ramdisk-recovery-load
459$(if $(filter top,$(1)),\
460 $(eval _kver :=)$(eval _sep :=),\
461 $(eval _kver := $(1))$(eval _sep :=_))\
462 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
463 $(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))))
464endef
465
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700466# $(1): kernel module directory name (top is an out of band value for no directory)
467define build-vendor-charger-load
468$(if $(filter top,$(1)),\
469 $(eval _kver :=)$(eval _sep :=),\
470 $(eval _kver := $(1))$(eval _sep :=_))\
471 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
472 $(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))))
473endef
474
Steve Mucklee1b10862019-07-10 10:49:37 -0700475ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
476 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
477 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700478 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700479 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
480endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700481
Steve Muckle69280d22019-07-11 12:23:38 -0700482ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
483 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700484endif
485
Steve Mucklee1b10862019-07-10 10:49:37 -0700486ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700487 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700488 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700489 endif
490endif
491
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800492ifneq ($(BOARD_DO_NOT_STRIP_RECOVERY_MODULES),true)
493 RECOVERY_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery_stripped)
494else
495 RECOVERY_STRIPPED_MODULE_STAGING_DIR :=
496endif
497
J. Avilaa2ceec62020-05-12 23:40:02 +0000498ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
499 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
500else
501 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
502endif
Colin Cross4f60e362019-06-05 11:53:43 -0700503
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700504ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
505 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
506else
507 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
508endif
509
Steve Muckle2335d762020-05-28 18:39:38 -0700510BOARD_KERNEL_MODULE_DIRS += top
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800511$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
Mark-PK Tsai8c543962021-08-23 18:01:51 +0800512 $(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 +0800513 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800514 $(if $(vendor_ramdisk_fragment), \
515 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
516 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
517 $(eval ### else ###), \
518 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
519 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800520 $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
521 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
522 $(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))) \
523 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
524 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(kmd))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700525 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800526 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
527 $(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 -0700528
529# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800530# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700531# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900532# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700533# $2 certificate
534# $3 private key
535# $4 compressed
536# $5 partition tag
537# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100538define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700539$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
540$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
541$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
542$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700543
544endef
545
Jaewoong Jung704b4542020-06-29 19:37:53 -0700546# -----------------------------------------------------------------
547# Merge an individual apkcerts output into the final apkcerts.txt output.
548# Use a macro to make it compatible with _apkcerts_write_line
549# $1 apkcerts file to be merged
550# $2 output file
551define _apkcerts_merge
552$(hide) cat $1 >> $2
553
554endef
555
The Android Open Source Project88b60792009-03-03 19:28:42 -0800556name := $(TARGET_PRODUCT)
557ifeq ($(TARGET_BUILD_TYPE),debug)
558 name := $(name)_debug
559endif
560name := $(name)-apkcerts-$(FILE_NAME_TAG)
561intermediates := \
562 $(call intermediates-dir-for,PACKAGING,apkcerts)
563APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700564all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
565$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800566# We don't need to really build all the modules.
567# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700568$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800569 @echo APK certs list: $@
570 @mkdir -p $(dir $@)
571 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700572 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700573 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
574 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
575 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700576 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700577 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
Ying Wangd9a88d52012-10-26 09:21:28 -0700578 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700579 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800580
581.PHONY: apkcerts-list
582apkcerts-list: $(APKCERTS_FILE)
583
Ying Wang15e487a2011-02-15 10:56:18 -0800584ifneq (,$(TARGET_BUILD_APPS))
585 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900586 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800587endif
Ying Wangefb21682010-07-23 16:42:13 -0700588
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900589
The Android Open Source Project88b60792009-03-03 19:28:42 -0800590# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700591# build system stats
592BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
593$(BUILD_SYSTEM_STATS):
594 @rm -f $@
595 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
596 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
Bill Peckham315b98a2021-06-15 19:35:06 -0700597$(call dist-for-goals,droidcore-unbundled,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700598
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700599# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800600# build /product/etc/security/avb/system_other.avbpubkey if needed
601ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800602ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800603INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
604ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800605endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800606endif # BUILDING_SYSTEM_OTHER_IMAGE
607
608# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700609# Modules ready to be converted to Soong, ordered by how many
610# modules depend on them.
611SOONG_CONV := $(sort $(SOONG_CONV))
612SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
613$(SOONG_CONV_DATA):
614 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700615 @$(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 -0700616
Colin Crossfdea8932017-12-06 14:38:40 -0800617SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700618SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
619$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
620 @rm -f $@
621 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
Bill Peckham315b98a2021-06-15 19:35:06 -0700622$(call dist-for-goals,droidcore-unbundled,$(SOONG_TO_CONVERT))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700623
Joe Onorato02fb89a2020-06-27 00:10:23 -0700624MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
625MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
626$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
627$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
628 @rm -f $@
629 $(hide) $(MK2BP_CATALOG_SCRIPT) \
630 --device=$(TARGET_DEVICE) \
631 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
632 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
633 --out_dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700634 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700635 > $@
Bill Peckham315b98a2021-06-15 19:35:06 -0700636$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_HTML))
Joe Onorato02fb89a2020-06-27 00:10:23 -0700637
Joe Onorato31986072020-08-10 09:58:49 -0700638MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
639$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
640 @rm -f $@
641 $(hide) $(MK2BP_CATALOG_SCRIPT) \
642 --device=$(TARGET_DEVICE) \
643 --out_dir="$(OUT_DIR)" \
644 --mode=csv \
645 > $@
Bill Peckham315b98a2021-06-15 19:35:06 -0700646$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_CSV))
Joe Onorato31986072020-08-10 09:58:49 -0700647
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700648# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800649# Modules use -Wno-error, or added default -Wall -Werror
650WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
651$(WALL_WERROR):
652 @rm -f $@
653 echo "# Modules using -Wno-error" >> $@
654 for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800655 echo "# Modules added default -Wall" >> $@
656 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
657
Bill Peckham315b98a2021-06-15 19:35:06 -0700658$(call dist-for-goals,droidcore-unbundled,$(WALL_WERROR))
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800659
660# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700661# C/C++ flag information for modules
Bill Peckham315b98a2021-06-15 19:35:06 -0700662$(call dist-for-goals,droidcore-unbundled,$(SOONG_MODULES_CFLAG_ARTIFACTS))
Jesse Paid0046922019-09-13 17:02:32 -0700663
664# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800665# Modules missing profile files
666PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
667$(PGO_PROFILE_MISSING):
668 @rm -f $@
669 echo "# Modules missing PGO profile files" >> $@
670 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
671
672$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
673
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000674CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
675$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
676 rm -f $@
677 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
678$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
679
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800680# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700681# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700682# for future OTA packages installed by this system. Actual product
683# deliverables will be re-signed by hand. We expect this file to
684# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700685DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700686
687
Jeff Browne33ba4c2011-07-11 22:11:46 -0700688# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800689# if they don't do anything.
690.PHONY: systemimage
691systemimage:
692
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800693# -----------------------------------------------------------------
694
695.PHONY: event-log-tags
696
Joe Onoratob7510532010-07-14 10:22:54 -0700697# Produce an event logs tag file for everything we know about, in order
698# to properly allocate numbers. Then produce a file that's filtered
699# for what's going to be installed.
700
701all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
702
Colin Crossdc8f8e42012-04-12 13:25:54 -0700703event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
704
Joe Onoratob7510532010-07-14 10:22:54 -0700705# Include tags from all packages that we know about
706all_event_log_tags_src := \
707 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
708
Dan Willemsena3f66322020-05-28 15:46:33 -0700709$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
710$(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 -0700711 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900712 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700713
Doug Zongkera34fa952011-02-23 12:17:29 -0800714# Include tags from all packages included in this product, plus all
715# tags that are part of the system (ie, not in a vendor/ or device/
716# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800717event_log_tags_src := \
718 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800719 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800720 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800721 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
722 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800723
Dan Willemsena3f66322020-05-28 15:46:33 -0700724$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700725$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700726$(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 -0800727 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900728 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800729
730event-log-tags: $(event_log_tags_file)
731
732ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
733
Joe Onoratob7510532010-07-14 10:22:54 -0700734
The Android Open Source Project88b60792009-03-03 19:28:42 -0800735# #################################################################
736# Targets for boot/OS images
737# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800738ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
739 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000740 ifdef BOARD_PREBUILT_BOOTLOADER
741 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
742 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
743 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800744 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
745 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
746 else
747 INSTALLED_2NDBOOTLOADER_TARGET :=
748 endif
749else
750 INSTALLED_BOOTLOADER_MODULE :=
751 INSTALLED_2NDBOOTLOADER_TARGET :=
752endif # TARGET_NO_BOOTLOADER
753ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700754 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
755 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
756 $(PRODUCT_OUT)/$(k))
757 else
758 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
759 endif
Ying Wangc6349742014-01-13 16:14:20 -0800760else
761 INSTALLED_KERNEL_TARGET :=
762endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800763
764# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700765# the root dir
766INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800767 $(ALL_GENERATED_SOURCES) \
768 $(ALL_DEFAULT_INSTALLED_MODULES))
769
Luis Hector Chavezff489932018-07-03 15:41:40 -0700770INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
771INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
772$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700773$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700774 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800775 mkdir -p $(dir $@)
776 rm -f $@
777 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
778 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700779
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700780ifeq ($(HOST_OS),linux)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700781$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700782endif
Luis Hector Chavezff489932018-07-03 15:41:40 -0700783
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800784#------------------------------------------------------------------
785# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700786ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800787INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700788ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800789$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800790 cat $^ > $@
791endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700792endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800793
Tom Cherryd14b8952018-08-09 14:26:00 -0700794# -----------------------------------------------------------------
795# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800796ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700797INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
798 $(ALL_GENERATED_SOURCES) \
799 $(ALL_DEFAULT_INSTALLED_MODULES))
800
801INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
802INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
803$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700804$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700805 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800806 mkdir -p $(TARGET_RAMDISK_OUT)
807 mkdir -p $(dir $@)
808 rm -f $@
809 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
810 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700811
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700812ifeq ($(HOST_OS),linux)
Tom Cherryd14b8952018-08-09 14:26:00 -0700813$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Dan Willemsen616e7fd2021-09-16 14:50:08 -0700814endif
Joe Onorato64d85d02009-04-09 19:31:12 -0700815BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
816
J. Avila3f6560e2020-05-11 20:20:03 +0000817ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
818# -l enables the legacy format used by the Linux kernel
819COMPRESSION_COMMAND_DEPS := $(LZ4)
820COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
821RAMDISK_EXT := .lz4
822else
823COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
824COMPRESSION_COMMAND := $(MINIGZIP)
825RAMDISK_EXT := .gz
826endif
827
Joe Onorato64d85d02009-04-09 19:31:12 -0700828# We just build this directly to the install location.
829INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900830$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
J. Avila3f6560e2020-05-11 20:20:03 +0000831$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800832 $(call pretty,"Target ramdisk: $@")
Inseob Kimadcdb2f2021-06-11 12:55:10 +0900833 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
834ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
835 $(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
836endif
J. Avila3f6560e2020-05-11 20:20:03 +0000837 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800838
Ying Wangad7fd292013-08-08 16:34:29 -0700839.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000840ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700841 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000842 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800843
Dan Willemsen67495202019-01-16 12:42:05 -0800844endif # BUILDING_RAMDISK_IMAGE
845
The Android Open Source Project88b60792009-03-03 19:28:42 -0800846# -----------------------------------------------------------------
847# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700848
849# This is defined here since we may be building recovery as boot
850# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700851ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
852 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
853else
854 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
855endif
856
Yifan Hong0674a6e2020-10-22 14:37:01 -0700857INTERNAL_PREBUILT_BOOTIMAGE :=
858
859my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
860ifdef my_installed_prebuilt_gki_apex
861 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
862 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
863 endif # len(my_installed_prebuilt_gki_apex) > 1
864
865 ifdef BOARD_PREBUILT_BOOTIMAGE
866 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
867 endif # BOARD_PREBUILT_BOOTIMAGE defined
868
869 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
870 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
871 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
872
873 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
874
875else # my_installed_prebuilt_gki_apex not defined
876
Steve Muckle04b6f052020-08-09 14:36:56 -0700877# $1: boot image target
878# returns the kernel used to make the bootimage
879define bootimage-to-kernel
880 $(if $(BOARD_KERNEL_BINARIES),\
881 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
882 $(INSTALLED_KERNEL_TARGET))
883endef
884
Steve Muckle903a1ca2020-05-07 17:32:10 -0700885ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
886 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
887endif
888
889# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800890# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700891define get-bootimage-partition-size
892 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
893endef
Chris Grossa784ef12019-04-22 11:09:57 -0700894
895ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800896INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700897 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700898
899ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
900INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
901endif
902
Steve Mucklee1b10862019-07-10 10:49:37 -0700903ifndef BUILDING_VENDOR_BOOT_IMAGE
904ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
905 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
906endif
907endif
908
The Android Open Source Project88b60792009-03-03 19:28:42 -0800909INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
910
Anton Hansson8dab0a62019-03-28 15:45:40 +0000911ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700912ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000913VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700914 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
915endif
916endif
917
Anton Hansson72e36f02019-02-26 17:36:30 +0000918INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700919
Yifan Hong46aff092020-10-28 13:50:47 -0700920# kernel cmdline/base/pagesize in boot.
921# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
922# device-specific.
923# - If not using GKI:
924# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
925# - Otherwise, put them in boot.
926ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -0700927 ifdef GENERIC_KERNEL_CMDLINE
928 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
929 endif
Yifan Hong46aff092020-10-28 13:50:47 -0700930else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
931 ifdef INTERNAL_KERNEL_CMDLINE
932 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
933 endif
934 ifdef BOARD_KERNEL_BASE
935 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
936 endif
937 ifdef BOARD_KERNEL_PAGESIZE
938 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
939 endif
940endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700941
Sami Tolvanen3303d902016-03-15 16:49:30 +0000942INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -0700943 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +0000944 --os_patch_level $(PLATFORM_SECURITY_PATCH)
945
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800946ifdef BOARD_GKI_SIGNING_KEY_PATH
947ifndef BOARD_GKI_SIGNING_ALGORITHM
948$(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
949endif
950INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS := \
951 --gki_signing_key $(BOARD_GKI_SIGNING_KEY_PATH) \
952 --gki_signing_algorithm $(BOARD_GKI_SIGNING_ALGORITHM) \
953 --gki_signing_avbtool_path $(AVBTOOL)
954endif
955
956# Using double quote to pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string
957# to MKBOOTIMG, although it may contain multiple args.
958ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
959INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS += \
960 --gki_signing_signature_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
961endif
962
Chris Grossa784ef12019-04-22 11:09:57 -0700963# Define these only if we are building boot
964ifdef BUILDING_BOOT_IMAGE
965INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
966
The Android Open Source Project88b60792009-03-03 19:28:42 -0800967ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800968$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700969endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -0400970
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700971$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
972
973ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -0400974
Steve Muckle04b6f052020-08-09 14:36:56 -0700975# $1: boot image target
976define build_boot_board_avb_enabled
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800977 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
978 $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700979 $(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 -0700980 $(AVBTOOL) add_hash_footer \
981 --image $(1) \
Yifan Hongebe65f82020-10-15 14:48:07 -0700982 --partition_size $(call get-bootimage-partition-size,$(1),boot) \
Steve Muckle04b6f052020-08-09 14:36:56 -0700983 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
984 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
985endef
986
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800987$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(BOARD_GKI_SIGNING_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400988 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700989 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400990
991.PHONY: bootimage-nodeps
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800992bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(BOARD_GKI_SIGNING_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400993 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700994 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400995
Anton Hansson8dab0a62019-03-28 15:45:40 +0000996else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700997
Steve Muckle04b6f052020-08-09 14:36:56 -0700998# $1: boot image target
999define build_boot_supports_boot_signer
1000 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
1001 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -07001002 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001003endef
1004
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001005$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -07001006 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001007 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -07001008
1009.PHONY: bootimage-nodeps
1010bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
1011 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001012 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -07001013
Anton Hansson8dab0a62019-03-28 15:45:40 +00001014else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -08001015
Steve Muckle04b6f052020-08-09 14:36:56 -07001016# $1: boot image target
1017define build_boot_supports_vboot
1018 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
1019 $(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 -07001020 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001021endef
1022
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001023$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001024 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001025 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -08001026
1027.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -08001028bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -08001029 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001030 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -08001031
1032else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -08001033
Steve Muckle04b6f052020-08-09 14:36:56 -07001034# $1: boot image target
1035define build_boot_novboot
1036 $(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 -07001037 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -07001038endef
1039
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001040$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001041 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -07001042 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -07001043
1044.PHONY: bootimage-nodeps
1045bootimage-nodeps: $(MKBOOTIMG)
1046 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -07001047 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -07001048
Yifan Hong3e0b5d02020-09-29 21:18:20 -07001049endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -07001050endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08001051
Tao Baob1a2e352018-08-14 16:17:12 -07001052else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -07001053ifdef BOARD_PREBUILT_BOOTIMAGE
Yifan Hong0674a6e2020-10-22 14:37:01 -07001054INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +09001055INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Bowgo Tsaib23656d2021-05-20 00:14:42 +08001056
1057ifeq ($(BOARD_AVB_ENABLE),true)
1058$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
1059 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1060 $(AVBTOOL) add_hash_footer \
1061 --image $@ \
1062 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
1063 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
1064 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
1065else
1066$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
1067 cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
1068endif # BOARD_AVB_ENABLE
1069
Tao Baob1a2e352018-08-14 16:17:12 -07001070else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -07001071INSTALLED_BOOTIMAGE_TARGET :=
1072endif # BOARD_PREBUILT_BOOTIMAGE
1073endif # TARGET_NO_KERNEL
Yifan Hong0674a6e2020-10-22 14:37:01 -07001074endif # my_installed_prebuilt_gki_apex not defined
1075
1076my_apex_extracted_boot_image :=
1077my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001078
1079# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001080# vendor boot image
1081ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1082
1083ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
1084 $(error vboot 1.0 does not support vendor_boot partition)
1085endif
1086
1087INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
1088 $(ALL_GENERATED_SOURCES) \
1089 $(ALL_DEFAULT_INSTALLED_MODULES))
1090
Petri Gynther6a6d6212021-03-06 00:45:53 -08001091INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001092
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001093# Exclude recovery files in the default vendor ramdisk if including a standalone
1094# recovery ramdisk in vendor_boot.
Yifan Hong881df392020-10-09 14:29:39 -07001095ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001096ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
Yifan Hong881df392020-10-09 14:29:39 -07001097$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1098$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1099endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08001100endif
Yifan Hong881df392020-10-09 14:29:39 -07001101
J. Avila3f6560e2020-05-11 20:20:03 +00001102$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001103 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001104
Petri Gynther828828b2021-03-04 11:04:03 -08001105INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1106$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08001107 @echo "Target vendor ramdisk: $@"
Petri Gynther828828b2021-03-04 11:04:03 -08001108 $(copy-file-to-target)
Petri Gynther828828b2021-03-04 11:04:03 -08001109
Petri Gynther6ff52012020-11-20 11:59:41 -08001110INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1111INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1112$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1113$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1114$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001115 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001116 mkdir -p $(dir $@)
1117 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001118 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1119 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001120
Steve Mucklee1b10862019-07-10 10:49:37 -07001121ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1122 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1123endif
1124ifdef BOARD_KERNEL_BASE
1125 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1126endif
1127ifdef BOARD_KERNEL_PAGESIZE
1128 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1129endif
1130ifdef INTERNAL_KERNEL_CMDLINE
1131 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1132endif
1133
Devin Moore50509012021-01-13 10:45:04 -08001134ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001135 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1136 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001137 rm -f $@
1138 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1139 printf "%s\n" $(param) >> $@;)
1140 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1141endif
1142
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001143# $(1): Build target name
1144# $(2): Staging dir to be compressed
1145# $(3): Build dependencies
1146define build-vendor-ramdisk-fragment-target
1147$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1148 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1149endef
1150
1151# $(1): Ramdisk name
1152define build-vendor-ramdisk-fragment
1153$(strip \
1154 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1155 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1156 $(build_target) \
1157)
1158endef
1159
1160# $(1): Ramdisk name
1161# $(2): Prebuilt file path
1162define build-prebuilt-vendor-ramdisk-fragment
1163$(strip \
1164 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1165 $(eval $(call copy-one-file,$(2),$(build_target))) \
1166 $(build_target) \
1167)
1168endef
1169
1170INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1171INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1172
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001173$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001174 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1175 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1176 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1177 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001178 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001179 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1180 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1181)
1182
Steve Mucklee1b10862019-07-10 10:49:37 -07001183INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1184$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001185$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001186ifeq ($(BOARD_AVB_ENABLE),true)
1187$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1188 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001189 $(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 -07001190 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1191 $(AVBTOOL) add_hash_footer \
1192 --image $@ \
1193 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
1194 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1195 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1196else
1197$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1198 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001199 $(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 -07001200 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1201endif
1202endif # BUILDING_VENDOR_BOOT_IMAGE
1203
1204# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001205# NOTICE files
1206#
Steve Blockd14d3b42012-03-01 11:34:41 +00001207# We are required to publish the licenses for all code under BSD, GPL and
1208# Apache licenses (and possibly other more exotic ones as well). We err on the
1209# side of caution, so the licenses for other third-party code are included here
1210# too.
1211#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001212# This needs to be before the systemimage rules, because it adds to
1213# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1214# go into the systemimage.
1215
Steve Block495e5852012-02-29 19:18:08 +00001216.PHONY: notice_files
1217
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001218# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -07001219# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
1220# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
1221# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
1222# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001223# $(2) - Plain text output file
1224# $(3) - HTML/XML output file
1225# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -07001226# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -08001227# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001228# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -08001229# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -08001230#
1231# The algorithm here is that we go collect a hash for each of the notice
1232# files and write the names of the files that match that hash. Then
1233# to generate the real files, we go print out all of the files and their
1234# hashes.
1235#
1236# These rules are fairly complex, so they depend on this makefile so if
1237# it changes, they'll run again.
1238#
1239# TODO: We could clean this up so that we just record the locations of the
1240# original notice files instead of making rules to copy them somwehere.
1241# Then we could traverse that without quite as much bash drama.
1242define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -07001243$(2): PRIVATE_MESSAGE := $(4)
1244$(2): PRIVATE_DIR := $(5)
1245$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
1246$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -08001247 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -07001248 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
1249 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm -e odm_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +00001250 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001251 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001252 $(if $(filter $(1),xml_system),-i system --xml-output, \
1253 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001254 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001255 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
1256 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -07001257 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001258notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001259endef
1260
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001261# Notice file logic isn't relevant for TARGET_BUILD_APPS
1262ifndef TARGET_BUILD_APPS
1263
The Android Open Source Project88b60792009-03-03 19:28:42 -08001264# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1265# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1266# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001267target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001268tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001269tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001270kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1271winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001272
Bob Badour4b25c902020-01-28 13:23:39 -08001273# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1274# reasons--not to be flashed onto any device. Targets under these directories
1275# need no associated notice file on the device UI.
1276exclude_target_dirs := apex
1277
Steven Morelandae69e572017-12-15 14:49:55 -08001278# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001279ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1280target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1281target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1282installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1283$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001284 $(target_notice_file_txt), \
1285 $(target_notice_file_html), \
1286 "Notices for files contained in the filesystem images in this directory:", \
1287 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -07001288 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -08001289 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001290$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1291 $(hide) $(MINIGZIP) -9 < $< > $@
1292$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1293 $(copy-file-to-target)
1294else
1295target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1296target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001297installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1298
1299target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1300target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1301target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1302installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001303
1304target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1305target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1306target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1307installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001308
Justin Yun6151e3f2019-06-25 15:58:13 +09001309target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1310target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1311target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1312installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001313
Chris Gross15d96552019-07-16 14:38:43 -07001314target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1315target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1316target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1317installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1318
Yifan Hong3d3f0302020-05-11 18:35:11 -07001319target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1320target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1321target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1322installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1323
Yifan Hongc83f9e92020-07-15 16:57:47 -07001324target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1325target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1326target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1327installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1328
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001329# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1330# being built. A notice xml file must depend on all modules that could potentially
1331# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001332license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001333# Only files copied to a system image need system image notices.
1334license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001335# Phonys/fakes don't have notice files (though their deps might)
1336license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001337# testcases are not relevant to the system image.
1338license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001339# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001340license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001341# system_other is relevant to system partition.
1342license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001343license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1344license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001345license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001346license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001347license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001348license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001349license_modules_agg := $(license_modules_system) \
1350 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001351 $(license_modules_product) \
1352 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001353 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001354 $(license_modules_vendor_dlkm) \
1355 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001356# targets used for debug symbols only and do not get copied to the device
1357license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1358
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001359license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001360license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1361
1362# Identify the other targets we expect to have notices for:
1363# targets copied to the device but are not readable by the UI (e.g. must boot
1364# into a different partition to read or don't have an associated /etc
1365# directory) must have their notices built somewhere readable.
1366license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1367license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1368license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1369license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1370license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1371license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001372license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001373license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1374license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1375license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1376license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1377license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1378license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1379
1380# after removing targets in system images, targets reported in system images, and
1381# targets used for debug symbols that do not need notices, nothing must remain.
1382license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1383$(call maybe-print-list-and-error, $(license_modules_rest), \
1384 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001385
Chris Grossaad39b32019-06-13 09:43:26 -07001386# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1387# update its notice file, so include those notices in the system partition instead
1388ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001389license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001390system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1391system_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 -07001392else
Bob Badour4b25c902020-01-28 13:23:39 -08001393license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001394system_xml_directories := xml_system
1395system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001396endif
1397
1398$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001399 $(target_notice_file_txt), \
1400 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001401 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001402 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001403 $(license_modules_system), \
1404 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001405$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001406 $(target_vendor_notice_file_txt), \
1407 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001408 "Notices for files contained in all filesystem images except system/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001409 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001410 $(license_modules_vendor), \
1411 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001412$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001413 $(target_product_notice_file_txt), \
1414 $(target_product_notice_file_xml), \
1415 "Notices for files contained in the product filesystem image in this directory:", \
1416 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001417 $(license_modules_product), \
1418 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001419$(eval $(call combine-notice-files, xml_system_ext, \
1420 $(target_system_ext_notice_file_txt), \
1421 $(target_system_ext_notice_file_xml), \
1422 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001423 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001424 $(license_modules_system_ext), \
1425 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001426$(eval $(call combine-notice-files, xml_odm, \
1427 $(target_odm_notice_file_txt), \
1428 $(target_odm_notice_file_xml), \
1429 "Notices for files contained in the odm filesystem image in this directory:", \
1430 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001431 $(license_modules_odm), \
1432 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001433$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1434 $(target_vendor_dlkm_notice_file_txt), \
1435 $(target_vendor_dlkm_notice_file_xml), \
1436 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1437 $(TARGET_OUT_NOTICE_FILES), \
1438 $(license_modules_vendor_dlkm), \
1439 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001440$(eval $(call combine-notice-files, xml_odm_dlkm, \
1441 $(target_odm_dlkm_notice_file_txt), \
1442 $(target_odm_dlkm_notice_file_xml), \
1443 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1444 $(TARGET_OUT_NOTICE_FILES), \
1445 $(license_modules_odm_dlkm), \
1446 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001447
1448$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1449 $(hide) $(MINIGZIP) -9 < $< > $@
1450$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1451 $(hide) $(MINIGZIP) -9 < $< > $@
1452$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1453 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001454$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001455 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001456$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1457 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001458$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1459 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001460$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1461 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001462$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1463 $(copy-file-to-target)
1464$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1465 $(copy-file-to-target)
1466$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1467 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001468$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001469 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001470$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1471 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001472$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1473 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001474$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1475 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001476
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001477ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1478ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1479ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1480ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1481ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001482ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001483ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001484endif # PRODUCT_NOTICE_SPLIT
1485
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001486ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001487
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001488$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001489 $(tools_notice_file_txt), \
1490 $(tools_notice_file_html), \
1491 "Notices for files contained in the tools directory:", \
1492 $(HOST_OUT_NOTICE_FILES), \
1493 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001494 $(winpthreads_notice_file), \
1495 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001496
Ying Wang62c81f82013-08-22 20:02:03 -07001497endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001498
1499# The kernel isn't really a module, so to get its module file in there, we
1500# make the target NOTICE files depend on this particular file too, which will
1501# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001502$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001503
Dan Willemsen288bedf2019-05-28 15:36:47 -07001504$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001505
Doug Zongker8678df42009-06-15 14:30:14 -07001506
The Android Open Source Project88b60792009-03-03 19:28:42 -08001507# #################################################################
1508# Targets for user images
1509# #################################################################
1510
Ying Wang933abf12010-06-16 14:31:34 -07001511INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001512ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001513INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1514else
1515ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001516INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1517else
1518ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001519INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1520endif
1521endif
1522endif
1523
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001524# These options tell the recovery updater/installer how to mount the partitions writebale.
1525# <fstype>=<fstype_opts>[|<fstype_opts>]...
1526# fstype_opts := <opt>[,<opt>]...
1527# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001528# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1529DEFAULT_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 -07001530
Ying Wang542903a2010-11-17 15:40:38 -08001531ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1532 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1533endif
Gao Xiang961041a2020-06-17 13:59:16 +08001534ifneq (true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED))
1535 INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG := -s
1536endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001537ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1538 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1539endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001540ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1541 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1542endif
Tao Baodba635a2019-06-24 10:39:54 -07001543
1544INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001545 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001546 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001547 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001548
1549ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1550INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001551endif
1552
Yifan Hongcfb917a2020-05-07 14:58:20 -07001553ifneq ($(filter \
1554 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1555 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1556 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1557 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1558 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1559 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001560 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001561 ,erofs),)
1562INTERNAL_USERIMAGES_DEPS += $(MKEROFSUSERIMG)
1563endif
1564
1565ifneq ($(filter \
1566 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1567 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1568 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1569 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1570 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1571 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1572 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001573 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001574INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1575endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001576
Anton Hansson8dab0a62019-03-28 15:45:40 +00001577ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001578INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001579ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001580INTERNAL_USERIMAGES_DEPS += $(FEC)
1581endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001582endif
1583
Tao Baodba635a2019-06-24 10:39:54 -07001584ifeq ($(BOARD_AVB_ENABLE),true)
1585INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1586endif
1587
1588# Get a colon-separated list of search paths.
1589INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1590
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001591# Collects file_contexts files from modules to be installed
1592$(call merge-fc-files, \
1593 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1594 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1595
Alex Klyubin092c9022017-03-13 13:28:34 -07001596SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001597
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001598INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1599
Yifan Hongc5c01242018-11-09 10:27:23 -08001600ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001601
Anton Hansson8dab0a62019-03-28 15:45:40 +00001602ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001603 $(error vboot 1.0 doesn't support logical partition)
1604endif
1605
Yifan Hongc5c01242018-11-09 10:27:23 -08001606endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001607
David Anderson707e6f52021-09-21 22:24:43 -07001608# $(1) the partition name (eg system)
1609# $(2) the image prop file
1610define add-common-flags-to-image-props
1611$(eval _var := $(call to-upper,$(1)))
1612$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
1613$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
1614endef
1615
1616# $(1) the partition name (eg system)
1617# $(2) the image prop file
1618define add-common-ro-flags-to-image-props
1619$(eval _var := $(call to-upper,$(1)))
David Anderson64b351b2021-10-13 00:20:43 -07001620$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
1621$(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 -07001622$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
1623$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
1624$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
1625$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
1626$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
1627$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
1628$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
1629$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
1630$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
1631$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
1632$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
1633$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
1634$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
1635$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
1636$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
1637$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
1638$(call add-common-flags-to-image-props,$(1),$(2))
David Anderson9e95a022021-08-31 21:32:45 -07001639endef
1640
Ying Wangbd93d422011-10-28 17:02:30 -07001641# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001642# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001643# $(3): additional "key=value" pairs to append to the dictionary file.
1644define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001645$(if $(filter $(2),system),\
Bowgo Tsai867ab662019-01-29 13:30:18 +08001646 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001647 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001648 $(call add-common-ro-flags-to-image-props,system,$(1))
Chris Gross203191b2020-05-30 02:39:12 +00001649)
1650$(if $(filter $(2),system_other),\
1651 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
David Anderson9e95a022021-08-31 21:32:45 -07001652 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
1653 $(hide) echo "system_other_disable_sparse=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001654)
Yifan Hong760d3c02018-05-30 11:16:46 -07001655$(if $(filter $(2),userdata),\
1656 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1657 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001658 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1659 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kim55c16dd2020-10-12 19:50:05 -07001660 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001661 $(call add-common-flags-to-image-props,userdata,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001662)
Yifan Hong760d3c02018-05-30 11:16:46 -07001663$(if $(filter $(2),cache),\
1664 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1665 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
David Anderson707e6f52021-09-21 22:24:43 -07001666 $(call add-common-flags-to-image-props,cache,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001667)
1668$(if $(filter $(2),vendor),\
David Anderson707e6f52021-09-21 22:24:43 -07001669 $(call add-common-ro-flags-to-image-props,vendor,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001670)
1671$(if $(filter $(2),product),\
David Anderson707e6f52021-09-21 22:24:43 -07001672 $(call add-common-ro-flags-to-image-props,product,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001673)
Justin Yun6151e3f2019-06-25 15:58:13 +09001674$(if $(filter $(2),system_ext),\
David Anderson707e6f52021-09-21 22:24:43 -07001675 $(call add-common-ro-flags-to-image-props,system_ext,$(1))
Dario Freni5f681e12018-05-29 13:09:01 +01001676)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001677$(if $(filter $(2),odm),\
David Anderson707e6f52021-09-21 22:24:43 -07001678 $(call add-common-ro-flags-to-image-props,odm,$(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001679)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001680$(if $(filter $(2),vendor_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001681 $(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001682)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001683$(if $(filter $(2),odm_dlkm),\
David Anderson707e6f52021-09-21 22:24:43 -07001684 $(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001685)
Yifan Hong760d3c02018-05-30 11:16:46 -07001686$(if $(filter $(2),oem),\
1687 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1688 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1689 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1690 $(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 -07001691 $(call add-common-flags-to-image-props,oem,$(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001692)
Tao Bao3602eca2018-07-10 10:53:55 -07001693$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001694
Tao Bao3602eca2018-07-10 10:53:55 -07001695$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001696$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Gao Xiang961041a2020-06-17 13:59:16 +08001697$(if $(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG),$(hide) echo "erofs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001698$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001699$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
David Anderson40a821f2021-09-22 18:02:01 -07001700$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
David Anderson64b351b2021-10-13 00:20:43 -07001701$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
1702$(if $(BOARD_EROFS_SHARE_DUP_BLOCKS),$(hide) echo "erofs_share_dup_blocks=$(BOARD_EROFS_SHARE_DUP_BLOCKS)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001703$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1704$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1705$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001706$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1707$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1708$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1709$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1710$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001711$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001712$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1713$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1714$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001715$(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 -07001716$(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 -07001717$(if $(PRODUCT_ODM_DLKM_VERITY_PARTITION),$(hide) echo "odm_dlkm_verity_block_device=$(PRODUCT_ODM_DLKM_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001718$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1719$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1720$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1721$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1722$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001723$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001724$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1725$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1726$(if $(BOARD_AVB_ENABLE),\
1727 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1728 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1729 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1730 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001731$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1732$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1733$(if $(BOARD_AVB_ENABLE),\
1734 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1735 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001736 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001737$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1738$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1739$(if $(BOARD_AVB_ENABLE),\
1740 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1741 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1742 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1743 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001744$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1745$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1746$(if $(BOARD_AVB_ENABLE),\
1747 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1748 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1749 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1750 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001751$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001752$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001753 $(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 +01001754$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001755 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1756 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1757 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1758 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001759$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1760$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1761$(if $(BOARD_AVB_ENABLE),\
1762 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1763 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1764 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1765 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001766$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1767$(if $(BOARD_AVB_ENABLE),\
1768 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1769$(if $(BOARD_AVB_ENABLE),\
1770 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1771 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1772 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1773 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001774$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1775$(if $(BOARD_AVB_ENABLE),\
1776 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1777$(if $(BOARD_AVB_ENABLE),\
1778 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1779 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1780 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1781 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001782$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1783 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001784$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001785 $(hide) echo "system_root_image=true" >> $(1))
1786$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001787$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1788 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001789$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1790endef
1791
1792# $(1): the path of the output dictionary file
1793# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001794PROP_DICTIONARY_IMAGES := oem
1795ifdef BUILDING_CACHE_IMAGE
1796 PROP_DICTIONARY_IMAGES += cache
1797endif
1798ifdef BUILDING_SYSTEM_IMAGE
1799 PROP_DICTIONARY_IMAGES += system
1800endif
Chris Gross203191b2020-05-30 02:39:12 +00001801ifdef BUILDING_SYSTEM_OTHER_IMAGE
1802 PROP_DICTIONARY_IMAGES += system_other
1803endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001804ifdef BUILDING_USERDATA_IMAGE
1805 PROP_DICTIONARY_IMAGES += userdata
1806endif
1807ifdef BUILDING_VENDOR_IMAGE
1808 PROP_DICTIONARY_IMAGES += vendor
1809endif
1810ifdef BUILDING_PRODUCT_IMAGE
1811 PROP_DICTIONARY_IMAGES += product
1812endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001813ifdef BUILDING_SYSTEM_EXT_IMAGE
1814 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001815endif
1816ifdef BUILDING_ODM_IMAGE
1817 PROP_DICTIONARY_IMAGES += odm
1818endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001819ifdef BUILDING_VENDOR_DLKM_IMAGE
1820 PROP_DICTIONARY_IMAGES += vendor_dlkm
1821endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001822ifdef BUILDING_ODM_DLKM_IMAGE
1823 PROP_DICTIONARY_IMAGES += odm_dlkm
1824endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001825define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001826 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001827endef
1828
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001829# $(1): the path of the input dictionary file, where each line has the format key=value
1830# $(2): the key to look up
1831define read-image-prop-dictionary
1832$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1833endef
1834
The Android Open Source Project88b60792009-03-03 19:28:42 -08001835# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001836# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001837
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001838# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001839ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001840
Ying Wang37526142015-03-10 12:02:57 -07001841INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1842 $(ALL_DEFAULT_INSTALLED_MODULES))
1843
Tao Bao10fc9492018-08-14 12:17:48 -07001844INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1845INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1846
Colin Cross359f4212020-12-02 15:14:04 -08001847ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1848INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1849endif
1850
Tao Bao10fc9492018-08-14 12:17:48 -07001851# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1852# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1853# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1854# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08001855$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07001856
1857$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001858$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001859 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001860 mkdir -p $(dir $@)
1861 rm -f $@
1862 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
1863 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001864
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001865recovery_sepolicy := \
1866 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001867 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001868 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001869 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1870 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1871 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001872 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001873 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001874 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1875 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1876 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001877
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001878# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1879# SELinux files
1880IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1881
Steve Muckle04b6f052020-08-09 14:36:56 -07001882# if building multiple boot images from multiple kernels, use the first kernel listed
1883# for the recovery image
1884recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001885recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001886recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001887
Anton Hansson45a40da2019-01-18 14:06:34 +00001888# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1889# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1890# which get remapped to a bucket.
1891recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001892ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1893recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001894# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001895# ------160------240------320----------480------------640------
1896# mdpi hdpi xhdpi xxhdpi xxxhdpi
1897recovery_density := $(strip \
1898 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1899 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1900 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1901 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001902endif
1903
1904ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1905recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1906else
Doug Zongker25d55f82014-04-04 13:51:15 -07001907recovery_resources_common := $(recovery_resources_common)-xhdpi
1908endif
1909
Tao Baoe1e829e2018-08-29 20:36:00 -07001910# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1911# Note that the font selected here can be overridden for a particular device by putting a font.png
1912# in its private recovery resources.
1913ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001914recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001915else
Dan Willemsen97672232020-05-27 00:09:16 -07001916recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001917endif
1918
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001919
1920# We will only generate the recovery background text images if the variable
1921# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1922# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1923# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1924# BoardConfig in order to use this feature.
1925ifeq ($(recovery_density),xxxhdpi)
1926TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1927else ifeq ($(recovery_density),xxhdpi)
1928TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1929endif
1930
1931ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1932# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1933ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1934 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1935else
1936 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1937endif
1938
1939
Dan Willemsen97672232020-05-27 00:09:16 -07001940RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001941RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1942RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1943RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1944RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1945
xunchangcc57d312018-12-07 12:12:17 -08001946RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1947RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1948RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1949RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1950RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1951
1952generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001953 $(RECOVERY_INSTALLING_TEXT_FILE) \
1954 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1955 $(RECOVERY_ERASING_TEXT_FILE) \
1956 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001957 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1958 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1959 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1960 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1961 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1962 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001963
Dan Willemsen97672232020-05-27 00:09:16 -07001964resource_dir := bootable/recovery/tools/recovery_l10n/res/
1965resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001966image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001967zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001968$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001969$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001970$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1971$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001972$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001973$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001974$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001975 recovery_installing \
1976 recovery_installing_security \
1977 recovery_erasing \
1978 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001979 recovery_no_command
1980$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001981 recovery_cancel_wipe_data \
1982 recovery_factory_data_reset \
1983 recovery_try_again \
1984 recovery_wipe_data_menu_header \
1985 recovery_wipe_data_confirmation
1986$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001987$(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 -08001988 # Prepares the font directory.
1989 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1990 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001991 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001992 @rm -rf $(dir $@)
1993 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001994 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001995 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001996 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001997 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1998 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1999 --text_name $(text_name) \
2000 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
2001 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08002002 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08002003 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002004else
2005RECOVERY_INSTALLING_TEXT_FILE :=
2006RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
2007RECOVERY_ERASING_TEXT_FILE :=
2008RECOVERY_ERROR_TEXT_FILE :=
2009RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08002010RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
2011RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
2012RECOVERY_TRY_AGAIN_TEXT_FILE :=
2013RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
2014RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002015endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
2016
Ying Wang9a175682015-08-06 11:47:47 -07002017ifndef TARGET_PRIVATE_RES_DIRS
2018TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
2019endif
Doug Zongker4647f122009-07-02 09:00:54 -07002020recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002021 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002022recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002023
2024
Andrew Boiefa61ff02012-09-28 09:33:45 -07002025ifdef TARGET_RECOVERY_FSTAB
2026recovery_fstab := $(TARGET_RECOVERY_FSTAB)
2027else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002028recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002029endif
Tao Baoc3c17532016-06-10 10:11:54 -07002030ifdef TARGET_RECOVERY_WIPE
2031recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002032else
Tao Baoc3c17532016-06-10 10:11:54 -07002033recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002034endif
Tao Bao8beab692015-07-22 12:33:18 -07002035
Tao Bao6d5d6232018-03-09 17:04:42 -08002036# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002037# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002038# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2039# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002040#
2041# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002042# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002043# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002044# b) We build a single image that contains boot and recovery both - no recovery image to install
2045# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07002046# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08002047# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002048# d) We include the recovery DTBO image within recovery - not needing the resource file as we
2049# do bsdiff because boot and recovery will contain different number of entries
2050# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002051# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
2052# do bsdiff because boot and recovery will contain different number of entries
2053# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yifan Hongef7a9712020-10-20 13:17:42 -07002054# f) We build a single image that contains vendor_boot and recovery both - no recovery image to
2055# install
2056# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002057
Tom Cherry2929cad2018-09-20 11:04:37 -07002058ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002059 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
2060 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002061# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002062RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2063ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002064else
Tao Bao8beab692015-07-22 12:33:18 -07002065RECOVERY_RESOURCE_ZIP :=
2066endif
Doug Zongker4647f122009-07-02 09:00:54 -07002067
Tao Bao139c7272018-07-31 13:26:54 -07002068INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2069
2070$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002071 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2072 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2073 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2074 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2075 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2076 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2077 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2078 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2079
2080# Parses the given list of build variables and writes their values as build properties if defined.
2081# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2082# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2083# $(1): Map from the build variable names to property names
2084# $(2): Output file
2085define append-recovery-ui-properties
2086echo "#" >> $(2)
2087echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2088echo "#" >> $(2)
2089$(foreach prop,$(1), \
2090 $(eval _varname := $(call word-colon,1,$(prop))) \
2091 $(eval _propname := $(call word-colon,2,$(prop))) \
2092 $(eval _value := $($(_varname))) \
2093 $(if $(_value), \
2094 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2095endef
2096
2097$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002098 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002099 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2100 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2101 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002102 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002103 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002104 $(hide) mkdir -p $(dir $@)
2105 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002106 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002107 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002108 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002109 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002110 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002111 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2112
Yifan Hong33fd5d42020-09-24 18:18:26 -07002113# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2114# On device with dedicated recovery partition, the file should come from the boot
2115# ramdisk.
2116ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2117INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2118$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2119 $(copy-file-to-target)
2120endif
2121
Yifan Hongc56931c2020-10-28 16:35:19 -07002122INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002123
Yifan Hong78860162020-10-28 14:15:21 -07002124ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002125INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002126# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002127ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002128ifdef INTERNAL_KERNEL_CMDLINE
2129 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002130endif # INTERNAL_KERNEL_CMDLINE != ""
2131endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002132ifdef BOARD_KERNEL_BASE
2133 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2134endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002135ifdef BOARD_KERNEL_PAGESIZE
2136 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2137endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002138ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002139ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2140 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2141else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002142 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2143endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002144endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002145ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2146 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2147endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002148ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2149 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2150endif
Yifan Hong3941a872020-10-28 16:33:06 -07002151endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002152ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2153 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2154endif
Doug Zongker4647f122009-07-02 09:00:54 -07002155
Yifan Hong881df392020-10-09 14:29:39 -07002156$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002157 $(INTERNAL_ROOT_FILES) \
2158 $(INSTALLED_RAMDISK_TARGET) \
2159 $(INTERNAL_RECOVERYIMAGE_FILES) \
2160 $(recovery_sepolicy) \
2161 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2162 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002163 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002164 $(recovery_resource_deps) \
2165 $(recovery_fstab)
2166 # Making recovery image
2167 mkdir -p $(TARGET_RECOVERY_OUT)
2168 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2169 # Copying baseline ramdisk...
2170 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2171 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2172 # Modifying ramdisk contents...
2173 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2174 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
2175 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2176 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2177 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2178 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2179 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2180 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2181 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2182 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2183 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2184 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2185 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2186 $(foreach item,$(recovery_fstab), \
2187 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2188 $(if $(strip $(recovery_wipe)), \
2189 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2190 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2191 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002192 $(hide) touch $@
2193
2194$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002195 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002196
Ying Wang747b9f12015-01-30 14:05:22 -08002197# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002198# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002199define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002200 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002201 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002202 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002203 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002204 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002205 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) \
2206 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002207 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002208 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002209 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2210 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002211 )\
2212 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002213 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2214 $(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 +08002215 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002216 $(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 -07002217 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002218 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2219 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002220 $(AVBTOOL) add_hash_footer --image $(1) --partition_size $(call get-bootimage-partition-size,$(1),boot) --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS),\
Steve Muckleb3dda772020-03-11 16:03:07 -07002221 $(AVBTOOL) add_hash_footer --image $(1) --partition_size $(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 -08002222endef
2223
Dan Willemsend120ac62020-06-12 02:39:34 +00002224recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002225ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00002226 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002227endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002228ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002229 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002230endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002231ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002232 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002233endif
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002234ifdef BOARD_GKI_SIGNING_KEY_PATH
2235 recoveryimage-deps += $(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
2236endif
Tao Baof4866c72018-08-22 14:35:09 -07002237ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002238 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2239 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2240 else
2241 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2242 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002243endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002244ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002245 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002246endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002247ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002248 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002249endif
Tao Baof4866c72018-08-22 14:35:09 -07002250
Dan Willemsend120ac62020-06-12 02:39:34 +00002251ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002252$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002253$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002254 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002255 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07002256endif # BOARD_USES_RECOVERY_AS_BOOT
2257
Dan Willemsend120ac62020-06-12 02:39:34 +00002258$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002259 $(call build-recoveryimage-target, $@, \
2260 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002261
Tao Bao4594d0e2015-12-22 09:47:46 -08002262ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002263$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002264 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002265 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2266 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002267endif
Doug Zongker56588872012-08-20 15:38:58 -07002268
Ying Wang747b9f12015-01-30 14:05:22 -08002269.PHONY: recoveryimage-nodeps
2270recoveryimage-nodeps:
2271 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002272 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2273 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002274
Chris Grossa784ef12019-04-22 11:09:57 -07002275else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002276RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002277endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002278
2279.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002280recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002281
Jiyong Park03eb0612017-10-04 21:22:41 +09002282ifneq ($(BOARD_NAND_PAGE_SIZE),)
2283$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002284endif
2285
Jiyong Park03eb0612017-10-04 21:22:41 +09002286ifneq ($(BOARD_NAND_SPARE_SIZE),)
2287$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002288endif
2289
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002290
Doug Zongker4647f122009-07-02 09:00:54 -07002291# -----------------------------------------------------------------
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002292# Build debug ramdisk and debug boot image.
2293ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
2294
2295# ramdisk-debug.img will merge the content from either ramdisk.img or
2296# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
2297# is set or not.
2298# INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP would ensure INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR is created.
2299ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2300 INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
2301 INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP := $(recovery_ramdisk)
2302else # BOARD_USES_RECOVERY_AS_BOOT == true
2303 INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR := $(TARGET_RAMDISK_OUT)
2304 INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP := $(INSTALLED_RAMDISK_TARGET)
2305endif # BOARD_USES_RECOVERY_AS_BOOT != true
2306
2307# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002308# the debug ramdisk, which is the original ramdisk plus additional
2309# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2310# When /force_debuggable is present, /init will load userdebug sepolicy
2311# and property files to allow adb root, if the device is unlocked.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002312INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
Bowgo Tsai0013f552019-03-20 17:59:52 +08002313
2314INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2315 $(ALL_GENERATED_SOURCES) \
2316 $(ALL_DEFAULT_INSTALLED_MODULES))
2317
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002318# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
Bowgo Tsai0013f552019-03-20 17:59:52 +08002319INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2320INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2321$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002322$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002323$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08002324 @echo Installed file list: $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002325 mkdir -p $(dir $@)
2326 rm -f $@
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002327 $(FILESLIST) $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002328 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002329
Bowgo Tsai610286a2021-04-23 11:31:32 +08002330$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002331$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP)
J. Avila3f6560e2020-05-11 20:20:03 +00002332$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002333 $(call pretty,"Target debug ramdisk: $@")
Bowgo Tsai0013f552019-03-20 17:59:52 +08002334 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2335 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002336 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002337
2338.PHONY: ramdisk_debug-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002339ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002340 echo "make $@: ignoring dependencies"
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002341 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002342 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002343 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002344
2345# -----------------------------------------------------------------
2346# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2347#
2348# Note: it's intentional to skip signing for boot-debug.img, because it
2349# can only be used if the device is unlocked with verification error.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002350ifdef BUILDING_DEBUG_BOOT_IMAGE
2351
Steve Muckleb3dda772020-03-11 16:03:07 -07002352ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
Bowgo Tsaia2a5db42021-09-23 15:46:33 +08002353 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,$(DEBUG_RAMDISK_BOOT_IMAGE_NAME),$(BOARD_KERNEL_BINARIES)), \
Steve Muckleb3dda772020-03-11 16:03:07 -07002354 $(PRODUCT_OUT)/$(k).img)
2355else
Bowgo Tsaia2a5db42021-09-23 15:46:33 +08002356 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/$(DEBUG_RAMDISK_BOOT_IMAGE_NAME).img
Steve Muckleb3dda772020-03-11 16:03:07 -07002357endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002358
2359# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002360$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002361ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002362 INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_RECOVERYIMAGE_ARGS))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002363else
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002364 INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_BOOTIMAGE_ARGS))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002365endif
2366
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002367# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2368# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2369# Using a test key to sign boot-debug.img to continue booting with the mismatched
2370# public key, if the device is unlocked.
2371ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002372$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002373endif
2374
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002375BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2376INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2377# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002378# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002379define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002380$(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 +08002381$(AVBTOOL) add_hash_footer \
2382 --image $(1) \
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002383 --partition_size $(call get-bootimage-partition-size,$(1),$(2))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002384 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2385 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002386$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002387endef
2388
Steve Muckleb3dda772020-03-11 16:03:07 -07002389# $(1): output file
2390define build-debug-bootimage-target
Bowgo Tsaia2a5db42021-09-23 15:46:33 +08002391 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst $(DEBUG_RAMDISK_BOOT_IMAGE_NAME),kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002392 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
2393 $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
Bowgo Tsaia2a5db42021-09-23 15:46:33 +08002394 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,$(DEBUG_RAMDISK_BOOT_IMAGE_NAME)))
Steve Muckleb3dda772020-03-11 16:03:07 -07002395endef
2396
Bowgo Tsai0013f552019-03-20 17:59:52 +08002397# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002398$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002399 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002400 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002401
2402.PHONY: bootimage_debug-nodeps
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002403bootimage_debug-nodeps: $(MKBOOTIMG) $(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002404 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002405 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002406
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002407endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai0013f552019-03-20 17:59:52 +08002408
Bowgo Tsai6a683672020-02-14 19:00:15 +08002409# -----------------------------------------------------------------
2410# vendor debug ramdisk
2411# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002412ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2413
Bowgo Tsai610286a2021-04-23 11:31:32 +08002414INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2415 $(ALL_GENERATED_SOURCES) \
2416 $(ALL_DEFAULT_INSTALLED_MODULES))
2417
2418INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2419INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2420$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2421$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2422$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2423 @echo Installed file list: $@
2424 mkdir -p $(dir $@)
2425 rm -f $@
2426 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) # The dir might not be created if no modules are installed here.
2427 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) > $(@:.txt=.json)
2428 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2429
Petri Gynther6a6d6212021-03-06 00:45:53 -08002430INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002431
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002432# Exclude recovery files in the default vendor ramdisk if including a standalone
2433# recovery ramdisk in vendor_boot.
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002434ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002435ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2436$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002437$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002438endif
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08002439endif
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002440
Bowgo Tsai610286a2021-04-23 11:31:32 +08002441# The vendor debug ramdisk combines vendor ramdisk and debug ramdisk.
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002442$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai610286a2021-04-23 11:31:32 +08002443$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002444$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002445 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
Bowgo Tsai610286a2021-04-23 11:31:32 +08002446 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002447
Petri Gyntherd7946d12021-03-10 12:38:15 -08002448INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2449$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002450 @echo "Target debug vendor ramdisk: $@"
Petri Gyntherd7946d12021-03-10 12:38:15 -08002451 $(copy-file-to-target)
Petri Gyntherd7946d12021-03-10 12:38:15 -08002452
Bowgo Tsai6a683672020-02-14 19:00:15 +08002453# -----------------------------------------------------------------
2454# vendor_boot-debug.img.
2455INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2456
2457# The util to sign vendor_boot-debug.img with a test key.
2458BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2459INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2460# $(1): the vendor bootimage to sign
2461define test-key-sign-vendor-bootimage
2462$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2463$(AVBTOOL) add_hash_footer \
2464 --image $(1) \
2465 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2466 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2467 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2468$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2469endef
2470
2471ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2472$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2473endif
2474
2475# 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 +08002476$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002477$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002478 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002479 $(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 +08002480 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2481 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2482
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002483endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai6a683672020-02-14 19:00:15 +08002484
Bowgo Tsai0013f552019-03-20 17:59:52 +08002485# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002486# The test harness ramdisk, which is based off debug_ramdisk, plus a
2487# few additional test-harness-specific properties in adb_debug.prop.
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002488INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002489
Bowgo Tsai610286a2021-04-23 11:31:32 +08002490# Appends a few test harness specific properties into the adb_debug.prop.
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002491TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2492ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2493ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2494
2495# $(1): a list of key=value pairs for additional property assignments
2496# $(2): the target .prop file to append the properties from $(1)
2497define append-test-harness-props
2498 echo "#" >> $(2); \
2499 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2500 echo "#" >> $(2);
2501 $(foreach line,$(1), echo "$(line)" >> $(2);)
2502endef
2503
Bowgo Tsai610286a2021-04-23 11:31:32 +08002504INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
2505 $(ALL_GENERATED_SOURCES) \
2506 $(ALL_DEFAULT_INSTALLED_MODULES))
2507
Bowgo Tsai610286a2021-04-23 11:31:32 +08002508# The test harness ramdisk will rsync the files from the debug ramdisk, then appends some props.
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002509$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002510$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DEP)
J. Avila3f6560e2020-05-11 20:20:03 +00002511$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002512 $(call pretty,"Target test harness ramdisk: $@")
Bowgo Tsai610286a2021-04-23 11:31:32 +08002513 rsync --chmod=u+w -a $(TARGET_DEBUG_RAMDISK_OUT)/ $(TARGET_TEST_HARNESS_RAMDISK_OUT)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002514 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002515 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_TEST_HARNESS_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002516
2517.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002518ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002519 echo "make $@: ignoring dependencies"
Bowgo Tsai610286a2021-04-23 11:31:32 +08002520 rsync --chmod=u+w -a $(TARGET_DEBUG_RAMDISK_OUT)/ $(TARGET_TEST_HARNESS_RAMDISK_OUT)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002521 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002522 mkdir -p $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR)
2523 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_TEST_HARNESS_RAMDISK_OUT) $(INTERNAL_DEBUG_RAMDISK_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002524
2525# -----------------------------------------------------------------
2526# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2527#
2528# Note: it's intentional to skip signing for boot-test-harness.img, because it
2529# can only be used if the device is unlocked with verification error.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002530ifdef BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002531
Steve Muckle4866bd62020-04-02 11:31:08 -07002532ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2533 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2534 $(PRODUCT_OUT)/$(k).img)
2535else
2536 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2537endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002538
2539# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2540INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2541
2542# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2543# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2544# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2545# public key, if the device is unlocked.
2546ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2547$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2548endif
2549
Steve Muckle4866bd62020-04-02 11:31:08 -07002550# $(1): output file
2551define build-boot-test-harness-target
2552 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002553 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
2554 $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002555 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002556endef
2557
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002558# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002559$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
2560$(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002561 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002562 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002563
2564.PHONY: bootimage_test_harness-nodeps
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002565bootimage_test_harness-nodeps: $(MKBOOTIMG) $(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002566 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002567 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002568
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002569endif # BUILDING_DEBUG_BOOT_IMAGE
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002570
Bowgo Tsai87f60012021-07-29 23:35:33 +08002571# -----------------------------------------------------------------
2572# vendor test harness ramdisk, which is a vendor ramdisk combined with
2573# a test harness ramdisk.
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002574ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
Bowgo Tsai87f60012021-07-29 23:35:33 +08002575
2576INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
2577
2578# Exclude recovery files in the default vendor ramdisk if including a standalone
2579# recovery ramdisk in vendor_boot.
2580ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
2581ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
2582$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
2583$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
2584endif
2585endif
2586
2587# The vendor test harness ramdisk combines vendor ramdisk and test harness ramdisk.
2588$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2589$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
2590 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(TARGET_TEST_HARNESS_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
2591
Yi-Yo Chiang870ea162021-10-01 18:01:44 +08002592INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
2593$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2594 @echo "Target test harness vendor ramdisk: $@"
2595 $(copy-file-to-target)
2596
Bowgo Tsai87f60012021-07-29 23:35:33 +08002597# -----------------------------------------------------------------
2598# vendor_boot-test-harness.img.
2599INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
2600
2601ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2602$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2603endif
2604
2605# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
2606$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
2607$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
2608$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
2609 $(call pretty,"Target vendor_boot test harness image: $@")
2610 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
2611 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2612 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2613
Yi-Yo Chiang4d7c6132021-09-29 19:41:11 +08002614endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2615
Yi-Yo Chiang6c51a432021-10-01 18:11:26 +08002616endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
2617
Bowgo Tsai87f60012021-07-29 23:35:33 +08002618
Colin Crossbd382142020-08-26 15:08:57 -07002619# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2620# $1: from location (e.g $(TARGET_OUT)/vendor)
2621# $2: destination location (e.g. /vendor)
2622# $3: partition image name (e.g. vendor.img)
2623define create-partition-compat-symlink
2624$(eval \
2625$1:
2626 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2627 mkdir -p $(dir $1)
2628 if [ -d $1 ] && [ ! -h $1 ]; then \
2629 echo 'Non-symlink $1 detected!' 1>&2; \
2630 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2631 exit 1; \
2632 fi
2633 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002634$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002635)
2636$1
2637endef
2638
2639
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002640# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002641# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002642
Dan Willemsen37a19862018-10-31 16:31:46 -07002643INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002644 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002645 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002646
Colin Crossbd382142020-08-26 15:08:57 -07002647# Create symlink /system/vendor to /vendor if necessary.
2648ifdef BOARD_USES_VENDORIMAGE
2649 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2650endif
2651
2652# Create symlink /system/product to /product if necessary.
2653ifdef BOARD_USES_PRODUCTIMAGE
2654 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2655endif
2656
2657# Create symlink /system/system_ext to /system_ext if necessary.
2658ifdef BOARD_USES_SYSTEM_EXTIMAGE
2659 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2660endif
2661
Ying Wang82cceba2012-08-13 15:03:00 -07002662FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002663
2664# ASAN libraries in the system image - add dependency.
2665ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002666ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002667 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2668 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2669 endif
2670endif
2671
Tom Cherryd14b8952018-08-09 14:26:00 -07002672FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002673
Ying Wange5e8c5f2011-09-09 16:35:53 -07002674# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002675ifdef BUILDING_SYSTEM_IMAGE
2676
Kiyoung Kim36481e02020-11-16 10:50:05 +09002677# Install system linker configuration
2678# Collect all available stub libraries installed in system and install with predefined linker configuration
2679SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
2680$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(LINKER_CONFIG_PATH_system_linker_config) | conv_linker_config
2681 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(LINKER_CONFIG_PATH_system_linker_config)\
2682 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
2683
2684FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
2685
Ying Wange5e8c5f2011-09-09 16:35:53 -07002686# installed file list
2687# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2688# We put installed-files.txt ahead of image itself in the dependency graph
2689# so that we can get the size stat even if the build fails due to too large
2690# system image.
2691INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002692INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2693$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002694$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002695 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002696 mkdir -p $(dir $@)
2697 rm -f $@
2698 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
2699 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002700
2701.PHONY: installed-file-list
2702installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002703
Dan Willemsen616e7fd2021-09-16 14:50:08 -07002704ifeq ($(HOST_OS),linux)
Ying Wang534fcd72013-03-01 16:45:35 -08002705$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07002706endif
Ying Wange5e8c5f2011-09-09 16:35:53 -07002707
2708systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002709 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002710BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2711
The Android Open Source Project88b60792009-03-03 19:28:42 -08002712# $(1): output file
2713define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002714 @echo "Target system fs image: $(1)"
2715 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002716 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002717 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002718 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002719 $(BUILD_IMAGE) \
2720 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2721 || ( mkdir -p $${DIST_DIR}; \
2722 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2723 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002724endef
2725
Dan Willemsen6b72c732019-06-12 21:33:38 +00002726ifeq ($(BOARD_AVB_ENABLE),true)
2727$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2728endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002729$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002730 $(call build-systemimage-target,$@)
2731
Tao Baoe9d61b02018-08-20 21:09:07 -07002732INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002733SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002734
Tao Baoe9d61b02018-08-20 21:09:07 -07002735# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2736# compatibility, in case device-specific Makefiles still refer to the old name.
2737INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2738
Doug Zongker73ef8252009-07-23 15:12:53 -07002739# The system partition needs room for the recovery image as well. We
2740# now store the recovery image as a binary patch using the boot image
2741# as the source (since they are very similar). Generate the patch so
2742# we can see how big it's going to be, and include that in the system
2743# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002744ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002745ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002746ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002747ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002748diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2749else
2750diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2751endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002752intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2753RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002754$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2755$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002756 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002757 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002758 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002759 @echo "Construct recovery from boot"
2760 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002761 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002762else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2763RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002764endif # BOARD_USES_FULL_RECOVERY_IMAGE
2765endif # INSTALLED_RECOVERYIMAGE_TARGET
2766endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002767
Yifan Hong9a3cad92020-04-27 19:06:59 -07002768$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002769 @echo "Install system fs image: $@"
2770 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002771 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002772
Tao Baoe9d61b02018-08-20 21:09:07 -07002773systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002774
2775.PHONY: systemimage-nodeps snod
2776systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002777 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002778 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002779 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002780 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002781ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002782 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002783endif
2784
Dan Willemsen67495202019-01-16 12:42:05 -08002785endif # BUILDING_SYSTEM_IMAGE
2786
Anton Hansson30e061b2018-11-12 13:36:46 +00002787.PHONY: sync syncsys
2788sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002789
Ying Wang3a61eeb2016-03-11 10:32:01 -08002790# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002791# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002792.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002793platform:
2794 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002795
2796.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002797platform-java:
2798 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002799
Ying Wang3a61eeb2016-03-11 10:32:01 -08002800# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002801# data partition image
2802INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002803 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002804
Dan Willemsen67495202019-01-16 12:42:05 -08002805ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002806userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002807 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002808BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2809
Ying Wangbd93d422011-10-28 17:02:30 -07002810define build-userdataimage-target
2811 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2812 @mkdir -p $(TARGET_OUT_DATA)
2813 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002814 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002815 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002816 $(BUILD_IMAGE) \
2817 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2818 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2819 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002820endef
2821
Joe Onorato64d85d02009-04-09 19:31:12 -07002822# We just build this directly to the install location.
2823INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002824INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2825 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002826 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002827$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002828 $(build-userdataimage-target)
2829
2830.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002831userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002832 $(build-userdataimage-target)
2833
Dan Willemsen67495202019-01-16 12:42:05 -08002834endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002835
Andreas Gampe039b5c72017-03-24 16:06:31 -07002836# ASAN libraries in the system image - build rule.
2837ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2838 $(TARGET_OUT_SHARED_LIBRARIES) \
2839 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2840 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2841 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002842# Extra options: Enforce the system user for the files to avoid having to change ownership.
2843ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002844# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2845# enough space.
2846$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002847 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 -07002848
The Android Open Source Project88b60792009-03-03 19:28:42 -08002849# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002850# partition table image
2851ifdef BOARD_BPT_INPUT_FILES
2852
2853BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002854BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002855
2856INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2857 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002858 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002859 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2860
2861ifdef BOARD_BPT_DISK_SIZE
2862INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2863endif
2864
2865define build-bptimage-target
2866 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2867 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2868endef
2869
2870INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002871$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2872 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2873
David Zeuthen25328622016-04-08 15:08:03 -04002874$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2875 $(build-bptimage-target)
2876
2877.PHONY: bptimage-nodeps
2878bptimage-nodeps:
2879 $(build-bptimage-target)
2880
2881endif # BOARD_BPT_INPUT_FILES
2882
2883# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002884# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002885ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002886INTERNAL_CACHEIMAGE_FILES := \
2887 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2888
2889cacheimage_intermediates := \
2890 $(call intermediates-dir-for,PACKAGING,cache)
2891BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2892
2893define build-cacheimage-target
2894 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2895 @mkdir -p $(TARGET_OUT_CACHE)
2896 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002897 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002898 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002899 $(BUILD_IMAGE) \
2900 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2901 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2902 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002903endef
2904
2905# We just build this directly to the install location.
2906INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002907$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002908 $(build-cacheimage-target)
2909
2910.PHONY: cacheimage-nodeps
2911cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2912 $(build-cacheimage-target)
2913
Dan Willemsen67495202019-01-16 12:42:05 -08002914else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002915# we need to ignore the broken cache link when doing the rsync
2916IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002917endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002918
David Zeuthen0eb10972016-09-28 17:55:27 -04002919# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002920# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002921ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002922ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002923# Marker file to identify that odex files are installed
2924INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2925ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2926$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2927 $(hide) touch $@
2928endif
2929
Alex Light4e358ab2016-06-16 14:47:10 -07002930INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2931 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002932 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002933
Colin Cross6db5b0e2018-11-16 21:26:33 -08002934# system_other dex files are installed as a side-effect of installing system image files
2935INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2936
Alex Light4e358ab2016-06-16 14:47:10 -07002937INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002938INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2939$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002940$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002941 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002942 mkdir -p $(dir $@)
2943 rm -f $@
2944 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
2945 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002946
Bowgo Tsai867ab662019-01-29 13:30:18 +08002947# Determines partition size for system_other.img.
2948ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2949ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2950INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2951endif
2952endif
2953
2954ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2955INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2956endif
2957
Alex Light4e358ab2016-06-16 14:47:10 -07002958systemotherimage_intermediates := \
2959 $(call intermediates-dir-for,PACKAGING,system_other)
2960BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2961
2962# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2963define build-systemotherimage-target
2964 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2965 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2966 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002967 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002968 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002969 $(BUILD_IMAGE) \
2970 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2971 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2972 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002973endef
2974
2975# We just build this directly to the install location.
2976INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002977ifneq (true,$(SANITIZE_LITE))
2978# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002979$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2980 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002981endif
Alex Light4e358ab2016-06-16 14:47:10 -07002982
2983.PHONY: systemotherimage-nodeps
2984systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2985 $(build-systemotherimage-target)
2986
Dan Willemsen67495202019-01-16 12:42:05 -08002987endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002988
2989
2990# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002991# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002992ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002993INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002994 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002995 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002996
Ying Wang8da19e32015-09-15 14:22:12 -07002997
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002998# Create symlink /vendor/odm to /odm if necessary.
2999ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003000 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07003001endif
3002
Yifan Honge51dff22020-06-23 17:26:57 -07003003# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
3004# /vendor/lib/modules -> /vendor_dlkm/lib/modules
3005#
3006# On devices with a vendor_dlkm partition,
3007# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
3008# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
3009# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3010# are hidden.
3011# On devices without a vendor_dlkm partition,
3012# - /vendor/lib/modules stores vendor DLKMs directly.
3013# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
3014# See system/core/rootdir/Android.mk for a list of created symlinks.
3015# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
3016# are not guaranteed to exist on all devices.
3017ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07003018 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 -07003019endif
3020
Colin Crossbd382142020-08-26 15:08:57 -07003021INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
3022INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
3023$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
3024$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3025 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003026 mkdir -p $(dir $@)
3027 rm -f $@
3028 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
3029 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07003030
Ying Wanga0febe52013-03-20 11:02:05 -07003031vendorimage_intermediates := \
3032 $(call intermediates-dir-for,PACKAGING,vendor)
3033BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003034define build-vendorimage-target
3035 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3036 @mkdir -p $(TARGET_OUT_VENDOR)
3037 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003038 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003039 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003040 $(BUILD_IMAGE) \
3041 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3042 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003043 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003044endef
3045
3046# We just build this directly to the install location.
3047INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003048$(INSTALLED_VENDORIMAGE_TARGET): \
3049 $(INTERNAL_USERIMAGES_DEPS) \
3050 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003051 $(INSTALLED_FILES_FILE_VENDOR) \
3052 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003053 $(build-vendorimage-target)
3054
Steven Morelanda2e734d2017-03-07 12:10:09 -08003055.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003056vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003057 $(build-vendorimage-target)
3058
Colin Cross91a52272017-06-20 16:57:52 -07003059sync: $(INTERNAL_VENDORIMAGE_FILES)
3060
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003061else ifdef BOARD_PREBUILT_VENDORIMAGE
3062INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3063$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
3064endif
Ying Wanga0febe52013-03-20 11:02:05 -07003065
Ying Wang9f8e8db2011-11-04 11:37:01 -07003066# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003067# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003068ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003069INTERNAL_PRODUCTIMAGE_FILES := \
3070 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003071 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003072
3073INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003074INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3075$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003076$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003077 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003078 mkdir -p $(dir $@)
3079 rm -f $@
3080 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3081 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003082
3083productimage_intermediates := \
3084 $(call intermediates-dir-for,PACKAGING,product)
3085BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3086define build-productimage-target
3087 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3088 @mkdir -p $(TARGET_OUT_PRODUCT)
3089 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003090 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003091 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003092 $(BUILD_IMAGE) \
3093 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3094 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3095 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003096endef
3097
3098# We just build this directly to the install location.
3099INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003100$(INSTALLED_PRODUCTIMAGE_TARGET): \
3101 $(INTERNAL_USERIMAGES_DEPS) \
3102 $(INTERNAL_PRODUCTIMAGE_FILES) \
3103 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003104 $(build-productimage-target)
3105
3106.PHONY: productimage-nodeps pnod
3107productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3108 $(build-productimage-target)
3109
3110sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3111
3112else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3113INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3114$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3115endif
3116
3117# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003118# system_ext partition image
3119ifdef BUILDING_SYSTEM_EXT_IMAGE
3120INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3121 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003122 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003123
Justin Yun6151e3f2019-06-25 15:58:13 +09003124INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3125INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3126$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3127$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003128 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003129 mkdir -p $(dir $@)
3130 rm -f $@
3131 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3132 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003133
Justin Yun6151e3f2019-06-25 15:58:13 +09003134system_extimage_intermediates := \
3135 $(call intermediates-dir-for,PACKAGING,system_ext)
3136BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3137define build-system_extimage-target
3138 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3139 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3140 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3141 $(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 -07003142 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003143 $(BUILD_IMAGE) \
3144 $(TARGET_OUT_SYSTEM_EXT) \
3145 $(system_extimage_intermediates)/system_ext_image_info.txt \
3146 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3147 $(TARGET_OUT)
3148 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003149endef
3150
3151# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003152INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003153$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3154 $(INTERNAL_USERIMAGES_DEPS) \
3155 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3156 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003157 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003158
Justin Yun6151e3f2019-06-25 15:58:13 +09003159.PHONY: systemextimage-nodeps senod
3160systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3161 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003162
Justin Yun6151e3f2019-06-25 15:58:13 +09003163sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003164
Justin Yun6151e3f2019-06-25 15:58:13 +09003165else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3166INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3167$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003168endif
3169
3170# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003171# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003172ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003173INTERNAL_ODMIMAGE_FILES := \
3174 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003175 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003176
Colin Crossbd382142020-08-26 15:08:57 -07003177# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3178# /odm/lib/modules -> /odm_dlkm/lib/modules
3179#
3180# On devices with a odm_dlkm partition,
3181# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3182# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3183# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3184# are hidden.
3185# On devices without a odm_dlkm partition,
3186# - /odm/lib/modules stores odm DLKMs directly.
3187# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3188# See system/core/rootdir/Android.mk for a list of created symlinks.
3189# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3190# are not guaranteed to exist on all devices.
3191ifdef BOARD_USES_ODM_DLKMIMAGE
3192 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3193endif
3194
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003195INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3196INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3197$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003198$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003199 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003200 mkdir -p $(dir $@)
3201 rm -f $@
3202 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3203 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003204
3205odmimage_intermediates := \
3206 $(call intermediates-dir-for,PACKAGING,odm)
3207BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3208define build-odmimage-target
3209 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3210 @mkdir -p $(TARGET_OUT_ODM)
3211 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003212 $(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
3213 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003214 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003215 $(BUILD_IMAGE) \
3216 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3217 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3218 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003219endef
3220
3221# We just build this directly to the install location.
3222INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003223$(INSTALLED_ODMIMAGE_TARGET): \
3224 $(INTERNAL_USERIMAGES_DEPS) \
3225 $(INTERNAL_ODMIMAGE_FILES) \
3226 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003227 $(build-odmimage-target)
3228
3229.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003230odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003231 $(build-odmimage-target)
3232
3233sync: $(INTERNAL_ODMIMAGE_FILES)
3234
3235else ifdef BOARD_PREBUILT_ODMIMAGE
3236INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3237$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3238endif
3239
3240# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003241# vendor_dlkm partition image
3242ifdef BUILDING_VENDOR_DLKM_IMAGE
3243INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3244 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003245 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003246
3247INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3248INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3249$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3250$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3251 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003252 mkdir -p $(dir $@)
3253 rm -f $@
3254 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3255 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003256
3257vendor_dlkmimage_intermediates := \
3258 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3259BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3260define build-vendor_dlkmimage-target
3261 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3262 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3263 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003264 $(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
3265 vendor_dlkm, skip_fsck=true)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003266 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3267 $(BUILD_IMAGE) \
3268 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3269 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3270 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3271endef
3272
3273# We just build this directly to the install location.
3274INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3275$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3276 $(INTERNAL_USERIMAGES_DEPS) \
3277 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3278 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3279 $(build-vendor_dlkmimage-target)
3280
3281.PHONY: vendor_dlkmimage-nodeps vdnod
3282vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3283 $(build-vendor_dlkmimage-target)
3284
3285sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3286
3287else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3288INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3289$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3290endif
3291
3292# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003293# odm_dlkm partition image
3294ifdef BUILDING_ODM_DLKM_IMAGE
3295INTERNAL_ODM_DLKMIMAGE_FILES := \
3296 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003297 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003298
3299INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3300INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3301$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3302$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3303 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003304 mkdir -p $(dir $@)
3305 rm -f $@
3306 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3307 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003308
3309odm_dlkmimage_intermediates := \
3310 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3311BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3312define build-odm_dlkmimage-target
3313 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3314 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3315 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
David Anderson17063cf2021-08-27 16:43:09 -07003316 $(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
3317 odm_dlkm, skip_fsck=true)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003318 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3319 $(BUILD_IMAGE) \
3320 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3321 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3322 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3323endef
3324
3325# We just build this directly to the install location.
3326INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3327$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3328 $(INTERNAL_USERIMAGES_DEPS) \
3329 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3330 $(INSTALLED_FILES_FILE_ODM_DLKM)
3331 $(build-odm_dlkmimage-target)
3332
3333.PHONY: odm_dlkmimage-nodeps odnod
3334odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3335 $(build-odm_dlkmimage-target)
3336
3337sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3338
3339else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3340INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3341$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3342endif
3343
3344
3345# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003346# dtbo image
3347ifdef BOARD_PREBUILT_DTBOIMAGE
3348INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3349
3350ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003351$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003352 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3353 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003354 --image $@ \
3355 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3356 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3357 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003358else
3359$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3360 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3361endif
3362
Tao Bao0da43472018-08-22 22:53:41 -07003363endif # BOARD_PREBUILT_DTBOIMAGE
3364
Andrew Scull9b103e42020-11-29 14:04:28 +00003365# -----------------------------------------------------------------
3366# Protected VM firmware image
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003367ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00003368INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
Pierre-Clément Tosi3bda0d62021-09-21 13:49:35 +02003369INTERNAL_PREBUILT_PVMFWIMAGE := packages/modules/Virtualization/pvmfw/pvmfw.img
Andrew Scull9b103e42020-11-29 14:04:28 +00003370
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003371ifdef BOARD_PREBUILT_PVMFWIMAGE
3372BUILT_PVMFWIMAGE_TARGET := $(BOARD_PREBUILT_PVMFWIMAGE)
Pierre-Clément Tosi3bda0d62021-09-21 13:49:35 +02003373else ifeq ($(BUILDING_PVMFW_IMAGE),true)
3374BUILT_PVMFWIMAGE_TARGET := $(INTERNAL_PREBUILT_PVMFWIMAGE)
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003375endif
Andrew Scull9b103e42020-11-29 14:04:28 +00003376
3377ifeq ($(BOARD_AVB_ENABLE),true)
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003378$(INSTALLED_PVMFWIMAGE_TARGET): $(BUILT_PVMFWIMAGE_TARGET) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH)
3379 cp $(BUILT_PVMFWIMAGE_TARGET) $@
Andrew Scull9b103e42020-11-29 14:04:28 +00003380 $(AVBTOOL) add_hash_footer \
3381 --image $@ \
3382 --partition_size $(BOARD_PVMFWIMG_PARTITION_SIZE) \
3383 --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \
3384 $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)
3385else
Pierre-Clément Tosifa8193c2021-09-24 15:49:00 +02003386$(eval $(call copy-one-file,$(BUILT_PVMFWIMAGE_TARGET),$(INSTALLED_PVMFWIMAGE_TARGET)))
Andrew Scull9b103e42020-11-29 14:04:28 +00003387endif
3388
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02003389endif # BOARD_USES_PVMFWIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00003390
Tao Bao0da43472018-08-22 22:53:41 -07003391# Returns a list of image targets corresponding to the given list of partitions. For example, it
3392# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3393# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003394# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003395define images-for-partitions
Tianjie16bcac12021-05-13 15:44:43 -07003396$(strip $(foreach item,$(1),$(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET))))
Tao Bao0da43472018-08-22 22:53:41 -07003397endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003398
3399# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003400# custom images
3401INSTALLED_CUSTOMIMAGES_TARGET :=
3402
3403ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3404INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3405
3406# Sign custom image.
3407# $(1): the prebuilt custom image.
3408# $(2): the mount point of the prebuilt custom image.
3409# $(3): the signed custom image target.
3410define sign_custom_image
3411$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3412 @echo Target custom image: $(3)
3413 mkdir -p $(dir $(3))
3414 cp $(1) $(3)
3415ifeq ($(BOARD_AVB_ENABLE),true)
3416 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3417 $(AVBTOOL) add_hashtree_footer \
3418 --image $(3) \
3419 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3420 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3421 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3422 --partition_name $(2) \
3423 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3424 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3425endif
3426INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3427endef
3428
3429$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3430 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3431 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3432endif
3433
3434# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003435# vbmeta image
3436ifeq ($(BOARD_AVB_ENABLE),true)
3437
3438BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003439AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003440
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003441ifdef BOARD_AVB_KEY_PATH
3442$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3443else
3444# If key path isn't specified, use the 4096-bit test key.
3445BOARD_AVB_ALGORITHM := SHA256_RSA4096
3446BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3447endif
3448
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003449# AVB signing for system_other.img.
3450ifdef BUILDING_SYSTEM_OTHER_IMAGE
3451ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3452$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3453else
3454# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3455BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3456BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3457endif
3458
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003459$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3460 @echo Extracting system_other avb key: $@
3461 @rm -f $@
3462 @mkdir -p $(dir $@)
3463 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003464
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003465ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3466BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3467endif
3468
3469BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3470endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3471
Tao Bao744c4c72018-08-20 21:09:07 -07003472INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003473 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003474 $(BOARD_AVB_VBMETA_VENDOR)
3475
3476# Not allowing the same partition to appear in multiple groups.
3477ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003478 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003479endif
3480
cfig1aeef722019-09-20 22:45:06 +08003481# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3482# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3483# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003484ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003485ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3486$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003487 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003488 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3489endif
3490endif
3491
Bowgo Tsai9b548012019-05-14 16:57:03 +08003492# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003493
3494BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003495 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003496 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003497 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3498
3499BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003500 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003501 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003502 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3503
Justin Yun6151e3f2019-06-25 15:58:13 +09003504BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003505 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003506 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003507 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003508
Bowgo Tsai9b548012019-05-14 16:57:03 +08003509BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003510 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003511 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003512
Tao Bao19b02fe2019-10-09 00:04:28 -07003513BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3514 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3515
3516BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3517 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3518
Bowgo Tsai9b548012019-05-14 16:57:03 +08003519BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003520 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003521 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003522
3523BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003524 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003525 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003526
Yifan Hongcfb917a2020-05-07 14:58:20 -07003527BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3528 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3529 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3530
Yifan Hongf496f1b2020-07-15 16:52:59 -07003531BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3532 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3533 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3534
Tao Bao19b02fe2019-10-09 00:04:28 -07003535BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3536 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3537
Andrew Scull9b103e42020-11-29 14:04:28 +00003538BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3539 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3540
Bowgo Tsai9b548012019-05-14 16:57:03 +08003541# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003542ifdef BOOT_SECURITY_PATCH
3543BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3544 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3545endif
3546
3547ifdef VENDOR_SECURITY_PATCH
3548BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3549 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3550endif
3551
3552ifdef ODM_SECURITY_PATCH
3553BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3554 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3555endif
3556
Yifan Hongcfb917a2020-05-07 14:58:20 -07003557ifdef VENDOR_DLKM_SECURITY_PATCH
3558BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3559 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3560endif
3561
Yifan Hongf496f1b2020-07-15 16:52:59 -07003562ifdef ODM_DLKM_SECURITY_PATCH
3563BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3564 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3565endif
3566
Andrew Scull9b103e42020-11-29 14:04:28 +00003567ifdef PVMFW_SECURITY_PATCH
3568BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3569 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
3570endif
3571
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003572BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003573VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003574DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00003575PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003576SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3577VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003578RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003579PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003580SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003581ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003582VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003583ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003584
Tao Bao0da43472018-08-22 22:53:41 -07003585# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003586# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003587define _check-and-set-avb-chain-args
3588$(eval part := $(1))
3589$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003590
3591$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3592$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3593$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3594$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3595$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3596$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3597$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3598$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3599
3600# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3601$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3602$(eval $(_signing_args) := \
3603 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3604
cfig1aeef722019-09-20 22:45:06 +08003605# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3606# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003607$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003608 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3609 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003610
Tao Bao744c4c72018-08-20 21:09:07 -07003611# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003612# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003613$(if $(filter $(part),$(part:vbmeta_%=%)),\
3614 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3615 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003616endef
3617
Tao Bao0da43472018-08-22 22:53:41 -07003618# Checks and sets the required build variables for an AVB partition. The partition will be
3619# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003620# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3621# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003622# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3623# but vbmeta would capture the image descriptor of only the first boot
3624# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003625# $(1): Partition name, e.g. boot or system.
3626define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003627$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003628$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003629 $(if $(_in_chained_vbmeta),\
3630 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003631 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003632 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003633 $(if $(filter boot,$(1)),\
3634 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3635 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3636 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3637 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003638endef
3639
Hongguang Chenf23364d2020-04-27 18:36:36 -07003640# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3641# $(1): the custom partition to enable AVB chain.
3642define check-and-set-custom-avb-chain-args
3643$(eval part := $(1))
3644$(eval PART=$(call to-upper,$(part)))
3645$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3646$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3647
3648INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3649 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3650endef
3651
Tao Baob1a2e352018-08-14 16:17:12 -07003652ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003653$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003654endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003655
Steve Mucklee1b10862019-07-10 10:49:37 -07003656ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3657$(eval $(call check-and-set-avb-args,vendor_boot))
3658endif
3659
Tao Bao0da43472018-08-22 22:53:41 -07003660$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003661
3662ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003663$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003664endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003665
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003666ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003667$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003668endif
3669
Justin Yun6151e3f2019-06-25 15:58:13 +09003670ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3671$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003672endif
3673
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003674ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003675$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003676endif
3677
Yifan Hongcfb917a2020-05-07 14:58:20 -07003678ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3679$(eval $(call check-and-set-avb-args,vendor_dlkm))
3680endif
3681
Yifan Hongf496f1b2020-07-15 16:52:59 -07003682ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3683$(eval $(call check-and-set-avb-args,odm_dlkm))
3684endif
3685
Yueyao Zhu211c9012017-04-27 00:34:50 -07003686ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003687$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003688endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003689
Andrew Scull9b103e42020-11-29 14:04:28 +00003690ifdef INSTALLED_PVMFWIMAGE_TARGET
3691$(eval $(call check-and-set-avb-args,pvmfw))
3692endif
3693
David Zeuthen8fecb282017-12-01 16:24:01 -05003694ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003695$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003696endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003697
David Anderson7709ab22018-10-15 14:41:34 -07003698# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3699ifdef BOARD_AVB_VBMETA_SYSTEM
3700$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003701endif
3702
3703ifdef BOARD_AVB_VBMETA_VENDOR
3704$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3705endif
3706
Hongguang Chenf23364d2020-04-27 18:36:36 -07003707ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3708$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3709 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3710endif
3711
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003712# Add kernel cmdline descriptor for kernel to mount system.img as root with
3713# dm-verity. This works when system.img is either chained or not-chained:
3714# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3715# cmdline descriptor to system.img
3716# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3717# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003718ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003719ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003720BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003721endif
David Anderson8916a2a2018-09-18 15:46:59 -07003722endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003723
Tao Bao0da43472018-08-22 22:53:41 -07003724BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003725BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003726BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3727
3728ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003729# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003730BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003731endif
Tao Bao0da43472018-08-22 22:53:41 -07003732
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003733ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003734BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003735endif
3736
David Anderson7709ab22018-10-15 14:41:34 -07003737ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3738BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3739 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003740endif
3741
3742ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3743BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3744 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003745endif
3746
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003747# $(1): the directory to extract public keys to
3748define extract-avb-chain-public-keys
3749 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3750 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3751 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003752 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3753 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3754 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003755 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3756 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3757 --output $(1)/system.avbpubkey)
3758 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3759 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3760 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003761 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3762 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3763 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003764 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3765 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3766 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003767 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3768 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3769 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003770 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3771 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3772 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003773 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3774 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3775 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003776 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3777 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3778 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00003779 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
3780 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
3781 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003782 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3783 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3784 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003785 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3786 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3787 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003788 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3789 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3790 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003791 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3792 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3793 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3794 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003795endef
3796
Tao Bao744c4c72018-08-20 21:09:07 -07003797# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3798# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003799# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003800# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3801# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003802# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003803# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003804# $(2): Output filename.
3805define build-chained-vbmeta-image
3806 $(call pretty,"Target chained vbmeta image: $@")
3807 $(hide) $(AVBTOOL) make_vbmeta_image \
3808 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3809 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3810 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3811 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3812 --output $@
3813endef
3814
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003815ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003816ifdef BOARD_AVB_VBMETA_SYSTEM
3817INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3818$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003819 $(AVBTOOL) \
3820 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3821 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003822 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003823endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003824endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003825
3826ifdef BOARD_AVB_VBMETA_VENDOR
3827INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3828$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003829 $(AVBTOOL) \
3830 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3831 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003832 $(call build-chained-vbmeta-image,vbmeta_vendor)
3833endif
3834
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003835define build-vbmetaimage-target
3836 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003837 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3838 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003839 $(hide) $(AVBTOOL) make_vbmeta_image \
3840 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003841 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003842 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3843 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003844 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003845endef
3846
Paul Trautrim4e143232019-08-13 16:30:57 +09003847ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003848INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003849$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3850 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3851
David Zeuthen8fecb282017-12-01 16:24:01 -05003852$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003853 $(AVBTOOL) \
3854 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003855 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003856 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3857 $(INSTALLED_VENDORIMAGE_TARGET) \
3858 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003859 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003860 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003861 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003862 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003863 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00003864 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003865 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003866 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3867 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3868 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3869 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3870 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3871 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003872 $(build-vbmetaimage-target)
3873
3874.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003875vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3876 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003877vbmetaimage-nodeps:
3878 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003879endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003880
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003881endif # BOARD_AVB_ENABLE
3882
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003883# List of files from all images
3884INTERNAL_ALLIMAGES_FILES := \
3885 $(FULL_SYSTEMIMAGE_DEPS) \
3886 $(INTERNAL_RAMDISK_FILES) \
3887 $(INTERNAL_USERDATAIMAGE_FILES) \
3888 $(INTERNAL_VENDORIMAGE_FILES) \
3889 $(INTERNAL_PRODUCTIMAGE_FILES) \
3890 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3891 $(INTERNAL_ODMIMAGE_FILES) \
3892 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3893 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3894
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003895# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003896# Check VINTF of build
3897
Yifan Hongc08cbf02020-09-15 19:07:39 +00003898# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003899ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003900
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003901intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3902check_vintf_all_deps :=
3903
Yifan Hongaf9b0702020-01-21 12:46:57 -08003904# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3905# because they are only used for prebuilt images.
3906check_vintf_common_srcs_patterns := \
3907 $(TARGET_OUT)/etc/vintf/% \
3908 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3909 $(TARGET_OUT_ODM)/etc/vintf/% \
3910 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3911 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3912
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003913check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08003914check_vintf_common_srcs_patterns :=
3915
3916check_vintf_has_system :=
3917check_vintf_has_vendor :=
3918
Yifan Hong28ffd732020-03-13 13:11:10 -07003919ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3920$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3921endif
3922ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3923$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3924endif
3925
Yifan Hong605ea042020-01-14 21:36:00 +00003926# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003927check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3928ifneq ($(check_vintf_system_deps),)
3929check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00003930
Yifan Hongfd150d32021-03-09 12:19:11 -08003931check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00003932check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003933$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003934 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3935check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00003936
Yifan Hongfd150d32021-03-09 12:19:11 -08003937vintffm_log := $(intermediates)/vintffm.log
Yifan Hong7a157b02020-10-20 17:08:11 +00003938check_vintf_all_deps += $(vintffm_log)
3939$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
3940 @( $< --check --dirmap /system:$(TARGET_OUT) \
3941 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3942
Yifan Hongaf9b0702020-01-21 12:46:57 -08003943endif # check_vintf_system_deps
3944check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003945
3946# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003947check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3948ifneq ($(check_vintf_vendor_deps),)
3949check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08003950check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00003951check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003952# Check vendor SKU=(empty) case when:
3953# - DEVICE_MANIFEST_FILE is not empty; OR
3954# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003955$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003956 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3957 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003958 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003959$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003960 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3961 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3962 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3963 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003964check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003965endif # check_vintf_vendor_deps
3966check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003967
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003968# -- Kernel version and configurations.
3969ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3970
Yifan Hong605ea042020-01-14 21:36:00 +00003971BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3972BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3973
3974my_board_extracted_kernel :=
3975
3976# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3977# from INSTALLED_KERNEL_TARGET.
3978ifdef BOARD_KERNEL_CONFIG_FILE
3979ifdef BOARD_KERNEL_VERSION
3980$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3981 cp $< $@
3982$(BUILT_KERNEL_VERSION_FILE):
3983 echo $(BOARD_KERNEL_VERSION) > $@
3984
3985my_board_extracted_kernel := true
3986endif # BOARD_KERNEL_VERSION
3987endif # BOARD_KERNEL_CONFIG_FILE
3988
3989ifneq ($(my_board_extracted_kernel),true)
Yifan Hong605ea042020-01-14 21:36:00 +00003990# Tools for decompression that is not in PATH.
3991# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3992# Algorithms that are in the script but not in this list will be found in PATH.
3993my_decompress_tools := \
3994 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3995
Yifan Hongb1627772021-07-14 15:01:50 -07003996endif # my_board_extracted_kernel
3997
3998ifneq ($(my_board_extracted_kernel),true)
3999ifdef INSTALLED_KERNEL_TARGET
Yifan Hong605ea042020-01-14 21:36:00 +00004000$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4001$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4002$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07004003$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
4004 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00004005 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08004006 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00004007
Yifan Hongb1627772021-07-14 15:01:50 -07004008my_board_extracted_kernel := true
Yifan Hong605ea042020-01-14 21:36:00 +00004009endif # INSTALLED_KERNEL_TARGET
Yifan Hongb1627772021-07-14 15:01:50 -07004010endif # my_board_extracted_kernel
4011
4012ifneq ($(my_board_extracted_kernel),true)
4013ifdef INSTALLED_BOOTIMAGE_TARGET
4014$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
4015$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
4016$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
4017$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
4018$(BUILT_KERNEL_CONFIGS_FILE): \
4019 $(HOST_OUT_EXECUTABLES)/unpack_bootimg \
4020 $(EXTRACT_KERNEL) \
4021 $(INSTALLED_BOOTIMAGE_TARGET)
4022 $(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
4023 $(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
4024 --output-configs $@ \
4025 --output-release $(BUILT_KERNEL_VERSION_FILE)
4026
4027my_board_extracted_kernel := true
4028endif # INSTALLED_BOOTIMAGE_TARGET
4029endif # my_board_extracted_kernel
4030
4031ifneq ($(my_board_extracted_kernel),true)
4032$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
4033 PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
4034 cannot be built into OTA update package. You can fix this by: \
4035 (1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
4036 so that kernel information will be extracted from the built kernel; or \
4037 (2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
4038 (3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
4039 BOARD_KERNEL_VERSION manually; or \
4040 (4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
4041# Clear their values to indicate that these two files does not exist.
4042BUILT_KERNEL_CONFIGS_FILE :=
4043BUILT_KERNEL_VERSION_FILE :=
4044endif
4045
4046my_decompress_tools :=
4047my_board_extracted_kernel :=
Yifan Hong605ea042020-01-14 21:36:00 +00004048
Yifan Hongc0f904e2021-03-17 11:25:31 -07004049endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4050
4051# -- Check VINTF compatibility of build.
4052# Skip partial builds; only check full builds. Only check if:
4053# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
4054# - system / vendor VINTF metadata exists
4055# - Building product / system_ext / odm images if board has product / system_ext / odm images
4056ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4057ifeq ($(check_vintf_has_system),true)
4058ifeq ($(check_vintf_has_vendor),true)
4059ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
4060ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
4061ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
4062
4063check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
4064check_vintf_all_deps += $(check_vintf_compatible_log)
4065
4066check_vintf_compatible_args :=
4067check_vintf_compatible_deps := $(check_vintf_common_srcs)
4068
4069ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004070ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004071check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004072check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004073endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004074endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4075
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004076check_vintf_compatible_args += \
4077 --dirmap /system:$(TARGET_OUT) \
4078 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4079 --dirmap /odm:$(TARGET_OUT_ODM) \
4080 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4081 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
4082
4083ifdef PRODUCT_SHIPPING_API_LEVEL
4084check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4085endif # PRODUCT_SHIPPING_API_LEVEL
4086
4087$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4088$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004089# Check ODM SKU=(empty) case when:
4090# - ODM_MANIFEST_FILES is not empty; OR
4091# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004092$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004093 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
4094 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004095 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07004096# Check vendor SKU=(empty) case when:
4097# - DEVICE_MANIFEST_FILE is not empty; OR
4098# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004099$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004100 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4101 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004102 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004103$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08004104 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
4105 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004106 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
4107 @echo -n -e 'Args: \n ' >> $@
4108 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07004109 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4110 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004111 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004112 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
4113 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4114 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004115
4116check_vintf_compatible_log :=
4117check_vintf_compatible_args :=
4118check_vintf_compatible_deps :=
4119
4120endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4121endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4122endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004123endif # check_vintf_has_vendor
4124endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004125endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4126
4127# Add all logs of VINTF checks to dist builds
4128droid_targets: $(check_vintf_all_deps)
4129$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4130
4131# Helper alias to check all VINTF of current build.
4132.PHONY: check-vintf-all
4133check-vintf-all: $(check_vintf_all_deps)
4134 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4135
Yifan Hongaf9b0702020-01-21 12:46:57 -08004136check_vintf_has_vendor :=
4137check_vintf_has_system :=
4138check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004139check_vintf_all_deps :=
4140intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004141endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004142
4143# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004144# Check image sizes <= size of super partition
4145
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004146ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004147
4148ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004149
Tianjie16bcac12021-05-13 15:44:43 -07004150PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
4151
4152# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
4153ifdef BUILDING_SYSTEM_OTHER_IMAGE
4154PARTITIONS_AND_OTHER_IN_SUPER += system_other
4155endif # BUILDING_SYSTEM_OTHER_IMAGE
4156
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004157# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004158# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004159define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004160 mkdir -p $(dir $(1))
4161 rm -f $(1)
4162 $(call dump-super-image-info, $(1))
Tianjie16bcac12021-05-13 15:44:43 -07004163 $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004164 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004165 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004166endef
4167
Yifan Hongd11953c2021-03-11 14:47:48 -08004168check_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 -07004169droid_targets: $(check_all_partition_sizes_log)
4170$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004171
Yifan Hong30910932019-10-25 20:36:55 -07004172$(check_all_partition_sizes_log): \
4173 $(CHECK_PARTITION_SIZES) \
Tianjie16bcac12021-05-13 15:44:43 -07004174 $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
Yifan Hong30910932019-10-25 20:36:55 -07004175 $(call check-all-partition-sizes-target, \
4176 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4177 $@)
4178
4179.PHONY: check-all-partition-sizes
4180check-all-partition-sizes: $(check_all_partition_sizes_log)
4181
4182.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004183check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004184 $(call check-all-partition-sizes-target, \
4185 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004186
Yifan Hong2dae5722018-07-31 12:47:27 -07004187endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004188
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004189endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004190
4191# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004192# bring in the installer image generation defines if necessary
4193ifeq ($(TARGET_USE_DISKINSTALLER),true)
4194include bootable/diskinstaller/config.mk
4195endif
4196
4197# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004198# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004199
Ying Wangbd2d0242015-09-22 11:17:52 -07004200ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004201 build_ota_package := false
4202 build_otatools_package := false
4203else
Tao Bao9be20c72019-04-08 21:11:59 -07004204 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004205 build_ota_package := true
4206 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4207 build_ota_package := false
4208 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004209 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004210 build_ota_package := false
4211 endif
4212 ifeq ($(TARGET_PRODUCT),sdk)
4213 build_ota_package := false
4214 endif
Yifan Hongf32f65c2021-07-14 14:19:12 -07004215 # A target without a kernel may be one of the following:
Yifan Hong8c1e5262021-07-19 16:35:05 +00004216 # - A generic target. In this case, the OTA package usually isn't built.
4217 # PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
4218 # generation.
4219 # - A real device target, with TARGET_NO_KERNEL set to true and
4220 # BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
4221 # an OTA package.
Tao Bao9be20c72019-04-08 21:11:59 -07004222 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4223 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4224 build_ota_package := false
4225 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004226 ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4227 ifeq ($(TARGET_NO_KERNEL),true)
4228 build_ota_package := false
4229 endif
Yifan Hong8c1e5262021-07-19 16:35:05 +00004230 endif # INSTALLED_BOOTIMAGE_TARGET == ""
Yifan Hongbf777872021-07-19 16:28:49 +00004231 ifeq ($(recovery_fstab),)
4232 build_ota_package := false
4233 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004234 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004235
Tao Bao9be20c72019-04-08 21:11:59 -07004236 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004237 build_otatools_package := true
4238 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4239 build_otatools_package := false
4240 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004241endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004242
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004243ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004244
4245INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004246 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004247 add_img_to_target_files \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004248 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004249 append2simg \
4250 avbtool \
4251 blk_alloc_to_base_fs \
4252 boot_signer \
4253 brillo_update_payload \
4254 brotli \
4255 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004256 build_image \
4257 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004258 build_verity_metadata \
4259 build_verity_tree \
4260 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004261 check_ota_package_signature \
4262 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004263 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004264 checkvintf \
4265 delta_generator \
4266 e2fsck \
4267 e2fsdroid \
4268 fc_sort \
4269 fec \
Jaegeuk Kim01da65f2021-06-08 18:24:46 -07004270 fsck.f2fs \
Tao Bao96daeeb2019-05-01 21:17:13 -07004271 fs_config \
4272 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08004273 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07004274 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004275 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004276 imgdiff \
4277 libconscrypt_openjdk_jni \
4278 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004279 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07004280 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07004281 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07004282 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07004283 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004284 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004285 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004286 mkbootfs \
4287 mkbootimg \
4288 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004289 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08004290 mkfs.erofs \
4291 mkerofsimage.sh \
Tao Bao96daeeb2019-05-01 21:17:13 -07004292 mkf2fsuserimg.sh \
4293 mksquashfs \
4294 mksquashfsimage.sh \
4295 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07004296 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08004297 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08004298 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07004299 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004300 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004301 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004302 sign_apex \
4303 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07004304 signapk \
4305 simg2img \
4306 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07004307 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07004308 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08004309 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07004310 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07004311 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004312 verity_signer \
4313 verity_verifier \
4314 zipalign \
Kelvin Zhangb673bbf2021-08-20 10:09:20 -07004315 zucchini \
Tao Bao5e04c382017-02-22 16:38:19 -08004316
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004317# Additional tools to unpack and repack the apex file.
4318INTERNAL_OTATOOLS_MODULES += \
4319 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00004320 apex_compression_tool \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004321 deapexer \
4322 debugfs_static \
4323 merge_zips \
4324 resize2fs \
4325 soong_zip \
4326
Anton Hansson8dab0a62019-03-28 15:45:40 +00004327ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004328INTERNAL_OTATOOLS_MODULES += \
4329 futility \
4330 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004331endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004332
Tao Bao96daeeb2019-05-01 21:17:13 -07004333INTERNAL_OTATOOLS_FILES := \
4334 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004335
Ying Wang06898662010-06-17 17:52:18 -07004336.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07004337otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07004338
Tao Bao96daeeb2019-05-01 21:17:13 -07004339# For each module, recursively resolve its host shared library dependencies. Then we have a full
4340# list of modules whose installed files need to be packed.
4341INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
4342 $(sort $(INTERNAL_OTATOOLS_MODULES) \
4343 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004344
Tao Bao96daeeb2019-05-01 21:17:13 -07004345INTERNAL_OTATOOLS_PACKAGE_FILES := \
4346 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
4347
4348INTERNAL_OTATOOLS_PACKAGE_FILES += \
4349 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
4350 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07004351
4352ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07004353INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07004354 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004355 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004356endif
4357ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004358INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004359 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4360 -name "atx_metadata.bin"))
4361endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004362ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004363INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004364 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004365endif
4366
Tao Bao96daeeb2019-05-01 21:17:13 -07004367INTERNAL_OTATOOLS_RELEASETOOLS := \
4368 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4369 \( -type f -o -type l \) -print))
4370
4371BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4372$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4373$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4374$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4375$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004376$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004377 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004378 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4379 mkdir -p $(dir $@)
4380 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4381 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004382 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004383 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004384
4385.PHONY: otatools-package
4386otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4387
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004388endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004389
The Android Open Source Project88b60792009-03-03 19:28:42 -08004390# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004391# misc_info.txt
4392
4393INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4394
4395ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4396# default to common dir for device vendor
4397tool_extensions := $(TARGET_DEVICE_DIR)/../common
4398else
4399tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4400endif
4401.KATI_READONLY := tool_extensions
4402
Steve Muckle903a1ca2020-05-07 17:32:10 -07004403# $1: boot image file name
4404define misc_boot_size
4405$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4406endef
4407
Daniel Normane1e48082019-06-27 13:55:23 -07004408$(INSTALLED_MISC_INFO_TARGET):
4409 rm -f $@
4410 $(call pretty,"Target misc_info.txt: $@")
4411 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4412 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4413ifdef BOARD_FLASH_BLOCK_SIZE
4414 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4415endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004416ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4417 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4418 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004419endif
4420ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4421 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004422else
4423 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004424endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004425ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4426 echo "lz4_ramdisks=true" >> $@
4427endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004428ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4429 echo "vendor_boot=true" >> $@
4430 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4431endif
Daniel Normane1e48082019-06-27 13:55:23 -07004432ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4433 $(hide) echo "no_recovery=true" >> $@
4434endif
4435ifdef BOARD_INCLUDE_RECOVERY_DTBO
4436 $(hide) echo "include_recovery_dtbo=true" >> $@
4437endif
4438ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4439 $(hide) echo "include_recovery_acpio=true" >> $@
4440endif
4441ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4442 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4443endif
4444ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4445 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4446 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4447else
4448 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4449endif
4450 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4451 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4452ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4453 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4454endif
4455 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004456 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004457 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08004458ifdef BOARD_GKI_SIGNING_KEY_PATH
4459 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
4460 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
4461endif
4462ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
4463 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
4464endif
Daniel Normane1e48082019-06-27 13:55:23 -07004465 $(hide) echo "multistage_support=1" >> $@
4466 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4467ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4468 $(hide) echo "build_generic_ota_package=true" >> $@
4469endif
4470ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4471 # OTA scripts are only interested in fingerprint related properties
4472 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4473endif
4474ifneq (,$(filter address, $(SANITIZE_TARGET)))
4475 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4476 $(hide) echo "userdata_img_with_data=true" >> $@
4477endif
4478ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4479 $(hide) echo "full_recovery_image=true" >> $@
4480endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004481ifdef BOARD_USES_VENDORIMAGE
4482 $(hide) echo "board_uses_vendorimage=true" >> $@
4483endif
Daniel Normane1e48082019-06-27 13:55:23 -07004484ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08004485ifeq ($(BUILDING_VBMETA_IMAGE),true)
4486 $(hide) echo "avb_building_vbmeta_image=true" >> $@
4487endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004488 $(hide) echo "avb_enable=true" >> $@
4489 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4490 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4491 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4492 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4493ifdef BOARD_AVB_BOOT_KEY_PATH
4494 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4495 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4496 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4497endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004498 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4499ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4500 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4501 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4502 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4503endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004504 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4505ifdef BOARD_AVB_RECOVERY_KEY_PATH
4506 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4507 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4508 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4509endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004510ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4511 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4512 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4513 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4514 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4515 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4516 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4517 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4518 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4519endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004520ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4521 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4522 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4523 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4524 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4525 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4526endif # BOARD_AVB_VBMETA_SYSTEM
4527ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4528 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4529 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4530 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4531 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4532 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4533endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4534endif # BOARD_AVB_ENABLE
4535ifdef BOARD_BPT_INPUT_FILES
4536 $(hide) echo "board_bpt_enable=true" >> $@
4537 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4538 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4539endif
4540ifdef BOARD_BPT_DISK_SIZE
4541 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4542endif
4543 $(call generate-userimage-prop-dictionary, $@)
4544ifeq ($(AB_OTA_UPDATER),true)
4545 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4546 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4547 $(hide) echo "ab_update=true" >> $@
4548endif
Yifan Hong65afc072020-04-17 10:08:10 -07004549ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4550 $(hide) echo "allow_non_ab=true" >> $@
4551endif
Daniel Normane1e48082019-06-27 13:55:23 -07004552ifdef BOARD_PREBUILT_DTBOIMAGE
4553 $(hide) echo "has_dtbo=true" >> $@
4554ifeq ($(BOARD_AVB_ENABLE),true)
4555 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4556 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4557ifdef BOARD_AVB_DTBO_KEY_PATH
4558 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4559 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4560 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4561endif # BOARD_AVB_DTBO_KEY_PATH
4562endif # BOARD_AVB_ENABLE
4563endif # BOARD_PREBUILT_DTBOIMAGE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02004564ifeq ($(BOARD_USES_PVMFWIMAGE),true)
Andrew Scull9b103e42020-11-29 14:04:28 +00004565 $(hide) echo "has_pvmfw=true" >> $@
4566ifeq ($(BOARD_AVB_ENABLE),true)
4567 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMG_PARTITION_SIZE)" >> $@
4568 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
4569ifdef BOARD_AVB_PVMFW_KEY_PATH
4570 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
4571 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
4572 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
4573endif # BOARD_AVB_PVMFW_KEY_PATH
4574endif # BOARD_AVB_ENABLE
Pierre-Clément Tosi88648d32021-09-24 15:41:13 +02004575endif # BOARD_USES_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004576 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004577 @# VINTF checks
4578ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4579 $(hide) echo "vintf_enforce=true" >> $@
4580endif
4581ifdef ODM_MANIFEST_SKUS
4582 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4583endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004584ifdef ODM_MANIFEST_FILES
4585 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4586endif
4587ifdef DEVICE_MANIFEST_SKUS
4588 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4589endif
4590ifdef DEVICE_MANIFEST_FILE
4591 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4592endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004593ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4594 $(hide) echo "bootloader_in_update_package=true" >> $@
4595endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07004596ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
4597 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
4598endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05004599ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
4600 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
4601endif
Jose Galmes9c8f6eb2021-07-21 09:34:08 -07004602ifeq ($(BUILDING_WITH_VSDK),true)
4603 $(hide) echo "building_with_vsdk=true" >> $@
4604endif
4605ifeq ($(TARGET_FLATTEN_APEX),false)
4606 $(hide) echo "target_flatten_apex=false" >> $@
4607endif
Daniel Normane1e48082019-06-27 13:55:23 -07004608
4609.PHONY: misc_info
4610misc_info: $(INSTALLED_MISC_INFO_TARGET)
4611
Bill Peckham315b98a2021-06-15 19:35:06 -07004612droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
Daniel Normane1e48082019-06-27 13:55:23 -07004613
4614# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004615# A zip of the directories that map to the target filesystem.
4616# This zip can be used to create an OTA package or filesystem image
4617# as a post-build step.
4618#
4619name := $(TARGET_PRODUCT)
4620ifeq ($(TARGET_BUILD_TYPE),debug)
4621 name := $(name)_debug
4622endif
4623name := $(name)-target_files-$(FILE_NAME_TAG)
4624
4625intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4626BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4627$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4628$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004629 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004630
4631# $(1): Directory to copy
4632# $(2): Location to copy it to
4633# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4634define package_files-copy-root
4635 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4636 mkdir -p $(2) && \
4637 $(ACP) -rd $(strip $(1))/* $(2); \
4638 fi
4639endef
4640
Tao Baoa04fca32015-11-30 12:22:24 -08004641built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004642
4643# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004644ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004645built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004646 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004647endif
4648
The Android Open Source Project88b60792009-03-03 19:28:42 -08004649$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4650
Dan Willemsen653bea92017-03-21 15:47:37 -07004651tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004652$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004653
Sen Jiang4438fd92016-03-07 16:51:01 -08004654ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004655updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004656endif
4657
4658# Build OTA tools if non-A/B is allowed
4659ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004660updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004661endif
Yifan Hong65afc072020-04-17 10:08:10 -07004662
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004663$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004664
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004665# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07004666# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004667ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4668$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07004669else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
4670$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004671else
4672$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4673endif
4674
Dan Willemsen653bea92017-03-21 15:47:37 -07004675ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004676 ifdef OSRELEASED_DIRECTORY
4677 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4678 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4679 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4680 endif
Tao Baoa835f382019-07-18 15:55:30 -07004681
4682 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4683 # additionally include radio or bootloader partitions).
4684 ifeq ($(AB_OTA_PARTITIONS),)
4685 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4686 endif
4687endif
4688
4689ifneq ($(AB_OTA_PARTITIONS),)
4690 ifneq ($(AB_OTA_UPDATER),true)
4691 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4692 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004693endif
4694
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004695# Run fs_config while creating the target files package
4696# $1: root directory
4697# $2: add prefix
4698define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004699(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 -08004700endef
4701
Yifan Hong60bfcc42019-11-01 11:39:45 -07004702define filter-out-missing-vendor
4703$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4704endef
Petri Gynther09865a42021-03-10 18:23:39 -08004705define filter-out-missing-vendor_dlkm
4706$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
4707endef
4708define filter-out-missing-odm
4709$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
4710endef
4711define filter-out-missing-odm_dlkm
4712$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
4713endef
4714# Filter out vendor,vendor_dlkm,odm,odm_dlkm from the list for AOSP targets.
4715# $(1): list
4716define filter-out-missing-partitions
4717$(call filter-out-missing-vendor,\
4718 $(call filter-out-missing-vendor_dlkm,\
4719 $(call filter-out-missing-odm,\
4720 $(call filter-out-missing-odm_dlkm,$(1)))))
4721endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07004722
4723# Information related to dynamic partitions and virtual A/B. This information
4724# is needed for building the super image (see dump-super-image-info) and
4725# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004726# $(1): file
4727define dump-dynamic-partitions-info
4728 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4729 echo "use_dynamic_partitions=true" >> $(1))
4730 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4731 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004732 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4733 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4734 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00004735 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
4736 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08004737 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4738 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004739 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4740 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4741 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4742 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4743 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4744 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08004745 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004746 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4747 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4748 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4749 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4750 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08004751 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 -07004752 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4753 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004754 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4755 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004756 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4757 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004758 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4759 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4760 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4761 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4762 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4763 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4764 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4765 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004766 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4767 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05004768 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
4769 echo "virtual_ab_compression=true" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004770 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4771 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004772endef
4773
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004774# By conditionally including the dependency of the target files package on the
4775# full system image deps, we speed up builds that do not build the system
4776# image.
4777ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004778 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4779endif
4780
4781ifdef BUILDING_USERDATA_IMAGE
4782 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4783endif
4784
4785ifdef BUILDING_SYSTEM_OTHER_IMAGE
4786 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4787endif
4788
4789ifdef BUILDING_VENDOR_BOOT_IMAGE
4790 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08004791 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Devin Moore55af5062021-06-09 10:44:44 -07004792 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Colin Crosse6431202021-02-24 11:44:55 -08004793 # The vendor ramdisk may be built from the recovery ramdisk.
4794 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
4795 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
4796 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07004797endif
4798
4799ifdef BUILDING_RECOVERY_IMAGE
4800 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08004801 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07004802 # commands in build-recoveryimage-target, which would touch the files under
4803 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4804 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4805 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4806 else
4807 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4808 endif
4809 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4810endif
4811
4812# Conditionally depend on the image files if the image is being built so the
4813# target-files.zip rule doesn't wait on the image creation rule, or the image
4814# if it is coming from a prebuilt.
4815
4816ifdef BUILDING_VENDOR_IMAGE
4817 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4818else ifdef BOARD_PREBUILT_VENDORIMAGE
4819 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4820endif
4821
4822ifdef BUILDING_PRODUCT_IMAGE
4823 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4824else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4825 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4826endif
4827
4828ifdef BUILDING_SYSTEM_EXT_IMAGE
4829 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4830else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4831 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4832endif
4833
4834ifdef BUILDING_BOOT_IMAGE
4835 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Yifan Hong49968aa2020-11-09 11:52:52 -08004836endif
4837ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07004838 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4839endif
4840
4841ifdef BUILDING_ODM_IMAGE
4842 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4843else ifdef BOARD_PREBUILT_ODMIMAGE
4844 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4845endif
4846
4847ifdef BUILDING_VENDOR_DLKM_IMAGE
4848 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08004849else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004850 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4851endif
4852
4853ifdef BUILDING_ODM_DLKM_IMAGE
4854 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08004855else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004856 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004857endif
4858
Isaac Chen9e09d472019-07-05 17:30:41 +08004859ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004860 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4861 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004862endif
4863
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004864ifdef BOARD_PREBUILT_BOOTLOADER
4865$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Bill Peckham315b98a2021-06-15 19:35:06 -07004866droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004867endif
4868
The Android Open Source Project88b60792009-03-03 19:28:42 -08004869# Depending on the various images guarantees that the underlying
4870# directories are up-to-date.
4871$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004872 $(INSTALLED_RADIOIMAGE_TARGET) \
4873 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004874 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004875 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004876 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004877 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004878 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4879 $(INSTALLED_KERNEL_TARGET) \
Enrico Granatab582e0f2020-10-14 15:17:20 -06004880 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004881 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004882 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4883 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004884 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004885 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004886 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4887 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4888 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004889 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004890 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004891 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004892 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004893 $(LPMAKE) \
4894 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004895 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004896 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004897 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004898 $(SOONG_ZIP) \
4899 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004900 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004901 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004902 $(BUILT_KERNEL_CONFIGS_FILE) \
4903 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004904 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004905 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004906 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004907 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07004908ifneq (,$(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 -08004909 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004910 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08004911# Exclude recovery files in the default vendor ramdisk if including a standalone
4912# recovery ramdisk in vendor_boot.
4913ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004914 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004915 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
Yi-Yo Chiang12f92442021-04-04 16:12:25 +08004916endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004917ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004918ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004919 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07004920else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07004921 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4922endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004923endif
Yifan Hong78860162020-10-28 14:15:21 -07004924ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004925ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004926 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004927endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004928ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004929ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004930 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004931else
Steve Mucklee1b10862019-07-10 10:49:37 -07004932 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004933endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004934endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004935ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004936 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004937endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004938ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004939 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004940endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004941ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004942ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004943 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07004944endif # INTERNAL_KERNEL_CMDLINE != ""
4945endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07004946ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004947 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004948endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004949ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004950 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004951endif
Yifan Hong3941a872020-10-28 16:33:06 -07004952endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004953endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004954 @# Components of the boot image
4955 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004956 $(hide) mkdir -p $(zip_root)/ROOT
4957 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004958 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004959 @# If we are using recovery as boot, this is already done when processing recovery.
4960ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004961ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004962 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004963 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004964endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004965ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004966 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004967endif
Yifan Hong46aff092020-10-28 13:50:47 -07004968ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07004969 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07004970else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07004971 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004972ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004973 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004974endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004975ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004976 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004977endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004978ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004979 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004980endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004981ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004982 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004983endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004984endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07004985endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004986 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4987 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004988 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004989ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4990 mkdir -p $(zip_root)/VENDOR_BOOT
4991 $(call package_files-copy-root, \
4992 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4993ifdef INSTALLED_DTBIMAGE_TARGET
4994 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4995endif
Devin Moore50509012021-01-13 10:45:04 -08004996ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
4997 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
4998endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004999ifdef BOARD_KERNEL_BASE
5000 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
5001endif
5002ifdef BOARD_KERNEL_PAGESIZE
5003 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
5004endif
5005 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005006ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
5007 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
5008 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08005009 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
5010 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
5011 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
5012 $(if $(prebuilt_ramdisk), \
5013 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
5014 $(call package_files-copy-root, \
5015 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
5016 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
5017 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08005018endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07005019endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08005020ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005021 @# Contents of the system image
5022 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005023 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08005024endif
5025ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08005026 @# Contents of the data image
5027 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005028 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08005029endif
5030ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07005031 @# Contents of the vendor image
5032 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005033 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07005034endif
Dan Willemsen67495202019-01-16 12:42:05 -08005035ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005036 @# Contents of the product image
5037 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005038 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005039endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005040ifdef BUILDING_SYSTEM_EXT_IMAGE
5041 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01005042 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09005043 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01005044endif
Dan Willemsen67495202019-01-16 12:42:05 -08005045ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005046 @# Contents of the odm image
5047 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005048 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005049endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005050ifdef BUILDING_VENDOR_DLKM_IMAGE
5051 @# Contents of the vendor_dlkm image
5052 $(hide) $(call package_files-copy-root, \
5053 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
5054endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005055ifdef BUILDING_ODM_DLKM_IMAGE
5056 @# Contents of the odm_dlkm image
5057 $(hide) $(call package_files-copy-root, \
5058 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
5059endif
Dan Willemsen67495202019-01-16 12:42:05 -08005060ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07005061 @# Contents of the system_other image
5062 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00005063 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07005064endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005065 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07005066 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07005067 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granatab582e0f2020-10-14 15:17:20 -06005068ifdef BUILDING_RAMDISK_IMAGE
5069ifeq (true,$(BOARD_IMG_USE_RAMDISK))
5070 @# Contents of the ramdisk image
5071 $(hide) mkdir -p $(zip_root)/IMAGES
5072 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
5073endif
5074endif
Yifan Hong65afc072020-04-17 10:08:10 -07005075ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08005076ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07005077 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07005078 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07005079endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08005080endif
Doug Zongker8678df42009-06-15 14:30:14 -07005081 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08005082 @# build them.
5083 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07005084 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09005085 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005086ifneq ($(tool_extension),)
5087 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
5088endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07005089 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07005090 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07005091 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00005092ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
5093 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5094 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005095endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005096ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
5097 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
5098 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005099endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005100ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
5101 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
5102 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005103endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005104ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
5105 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
5106 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01005107endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005108ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
5109 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
5110 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005111endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005112ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
5113 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
5114 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
5115endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005116ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
5117 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
5118 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
5119endif
Yifan Hong65afc072020-04-17 10:08:10 -07005120ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07005121ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07005122 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07005123 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07005124endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08005125endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005126ifeq ($(AB_OTA_UPDATER),true)
5127 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07005128 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005129 $(hide) for part in $(strip $(AB_OTA_PARTITIONS)); do \
Alex Deymo8925d332015-10-01 17:38:09 -07005130 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
5131 done
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005132 $(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
Sen Jiang8f22e2a2015-11-12 13:53:25 -08005133 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
5134 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005135ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07005136 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
5137 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
5138 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005139endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005140endif
Steve Fungdfbab492015-09-24 18:12:33 -07005141ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07005142 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07005143 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07005144endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07005145ifdef BOARD_PREBUILT_VENDORIMAGE
5146 $(hide) mkdir -p $(zip_root)/IMAGES
5147 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
5148endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005149ifdef BOARD_PREBUILT_PRODUCTIMAGE
5150 $(hide) mkdir -p $(zip_root)/IMAGES
5151 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
5152endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005153ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01005154 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09005155 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01005156endif
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005157ifndef BOARD_PREBUILT_BOOTIMAGE
Yifan Hong49968aa2020-11-09 11:52:52 -08005158ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
5159ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07005160 $(hide) mkdir -p $(zip_root)/IMAGES
5161 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08005162endif # INSTALLED_BOOTIMAGE_TARGET
5163endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaib23656d2021-05-20 00:14:42 +08005164else # BOARD_PREBUILT_BOOTIMAGE is defined
5165 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5166 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5167endif # BOARD_PREBUILT_BOOTIMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005168ifdef BOARD_PREBUILT_ODMIMAGE
5169 $(hide) mkdir -p $(zip_root)/IMAGES
5170 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
5171endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07005172ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07005173 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07005174 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5175endif
5176ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
5177 $(hide) mkdir -p $(zip_root)/IMAGES
5178 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07005179endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07005180ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07005181 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5182 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08005183endif # BOARD_PREBUILT_DTBOIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00005184ifdef BOARD_PREBUILT_PVMFWIMAGE
5185 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5186 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5187endif # BOARD_PREBUILT_PVMFWIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005188ifdef BOARD_PREBUILT_BOOTLOADER
5189 $(hide) mkdir -p $(zip_root)/IMAGES
5190 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
5191endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07005192ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
5193 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5194 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5195 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
5196endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07005197 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
5198 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
5199 @# INSTALLED_RADIOIMAGE_TARGET.
5200 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
5201 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005202 @# Run fs_config on all the system, vendor, boot ramdisk,
5203 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08005204ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005205 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08005206endif
5207ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005208 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
5209endif
Dan Willemsen67495202019-01-16 12:42:05 -08005210ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005211 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
5212endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005213ifdef BUILDING_SYSTEM_EXT_IMAGE
5214 $(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 +01005215endif
Dan Willemsen67495202019-01-16 12:42:05 -08005216ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005217 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
5218endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005219ifdef BUILDING_VENDOR_DLKM_IMAGE
5220 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
5221endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005222ifdef BUILDING_ODM_DLKM_IMAGE
5223 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
5224endif
Tom Cherryd14b8952018-08-09 14:26:00 -07005225 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005226 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005227ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07005228 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005229 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005230endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005231ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5232 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
5233endif
Tom Cherry2929cad2018-09-20 11:04:37 -07005234ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
5235 @# BOOT/RAMDISK also exists and contains the first stage ramdisk if not using BOARD_BUILD_SYSTEM_ROOT_IMAGE.
Tao Baoda01b212018-02-28 21:20:08 -08005236 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
5237endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005238ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5239 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
5240endif
Dan Willemsen67495202019-01-16 12:42:05 -08005241ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005242 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
5243endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07005244 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07005245ifdef BUILT_KERNEL_CONFIGS_FILE
5246 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
5247endif
5248ifdef BUILT_KERNEL_VERSION_FILE
5249 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
5250endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07005251 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
5252ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5253 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
5254endif
Tao Baocbd6d492019-10-07 22:46:02 -07005255 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
5256 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08005257ifeq ($(BUILD_QEMU_IMAGES),true)
5258 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
5259 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
5260endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08005261 @# Zip everything up, preserving symlinks and placing META/ files first to
5262 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005263 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07005264 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08005265 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07005266
Ying Wanga0febe52013-03-20 11:02:05 -07005267.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08005268target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
5269
Ying Wang4709d7c2014-04-14 17:25:43 -07005270$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07005271
Dan Albert4d323332016-10-14 13:23:06 -07005272# -----------------------------------------------------------------
5273# NDK Sysroot Package
5274NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07005275$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07005276 @echo Package NDK sysroot...
5277 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
5278
Dan Willemsen616e7fd2021-09-16 14:50:08 -07005279ifeq ($(HOST_OS),linux)
Dan Albert4d323332016-10-14 13:23:06 -07005280$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
Dan Willemsen616e7fd2021-09-16 14:50:08 -07005281endif
Dan Albert4d323332016-10-14 13:23:06 -07005282
Ying Wang09c4b682015-08-11 11:24:19 -07005283ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07005284# -----------------------------------------------------------------
5285# OTA update package
5286
Yifan Hong50e79542018-11-08 17:44:12 -08005287# $(1): output file
5288# $(2): additional args
5289define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07005290PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07005291 $(OTA_FROM_TARGET_FILES) \
5292 --verbose \
5293 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
5294 --path $(HOST_OUT) \
5295 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
5296 $(2) \
5297 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08005298endef
5299
Tianjie6bd3b1a2020-10-16 18:53:47 -07005300product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07005301ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005302 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07005303endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07005304name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07005305
5306INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08005307INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
5308
Doug Zongker8678df42009-06-15 14:30:14 -07005309$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08005310$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07005311$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07005312 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08005313 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07005314
5315.PHONY: otapackage
5316otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
5317
Tao Bao519d1822018-12-27 12:47:23 -08005318ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005319name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08005320
5321INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08005322$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07005323$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
5324 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07005325 $(OTA_FROM_TARGET_FILES) \
5326 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08005327 @echo "Package OTA (retrofit dynamic partitions): $@"
5328 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
5329
5330.PHONY: otardppackage
5331
5332otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
5333
Tao Bao519d1822018-12-27 12:47:23 -08005334endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08005335
Tianjie6bd3b1a2020-10-16 18:53:47 -07005336ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5337name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
5338
5339INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5340$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
5341$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
5342 @echo "Package partial OTA: $@"
5343 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
5344
5345.PHONY: partialotapackage
5346partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
5347
5348endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
5349
Ying Wang09c4b682015-08-11 11:24:19 -07005350endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07005351
Ying Wang09a00a62010-10-20 14:01:09 -07005352# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01005353# A zip of the appcompat directory containing logs
5354APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
5355# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005356ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07005357$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
5358 $(INTERNAL_RAMDISK_FILES) \
5359 $(INTERNAL_USERDATAIMAGE_FILES) \
5360 $(INTERNAL_VENDORIMAGE_FILES) \
5361 $(INTERNAL_PRODUCTIMAGE_FILES) \
5362 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01005363endif
5364$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
5365$(APPCOMPAT_ZIP): $(SOONG_ZIP)
5366 @echo "appcompat logs: $@"
5367 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5368 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
5369 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
5370 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
5371
Jeongik Cha2522c362021-04-27 23:52:15 +09005372# The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
5373ifeq ($(BUILD_OS),linux)
Jeongik Cha62519de2021-05-13 13:29:39 +09005374ifneq ($(DEX2OAT),)
Jeongik Cha2522c362021-04-27 23:52:15 +09005375dexpreopt_tools_deps := $(DEXPREOPT_GEN_DEPS) $(DEXPREOPT_GEN) $(AAPT2)
5376DEXPREOPT_TOOLS_ZIP := $(PRODUCT_OUT)/dexpreopt_tools.zip
5377$(DEXPREOPT_TOOLS_ZIP): $(dexpreopt_tools_deps)
5378$(DEXPREOPT_TOOLS_ZIP): PRIVATE_DEXPREOPT_TOOLS_DEPS := $(dexpreopt_tools_deps)
5379$(DEXPREOPT_TOOLS_ZIP): $(SOONG_ZIP)
5380 $(hide) mkdir -p $(dir $@)
5381 $(hide) $(SOONG_ZIP) -d -o $@ -j $(addprefix -f ,$(PRIVATE_DEXPREOPT_TOOLS_DEPS)) -f $$(realpath $(DEX2OAT))
Jeongik Cha62519de2021-05-13 13:29:39 +09005382endif # DEX2OAT is set
5383endif # BUILD_OS == linux
Jeongik Cha2522c362021-04-27 23:52:15 +09005384
Jeongik Chaa8056d62021-04-07 23:57:16 +09005385DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
Jeongik Chab26bf582021-06-08 11:31:31 +09005386
5387$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
5388 $(INSTALLED_VENDORIMAGE_TARGET) \
5389 $(INSTALLED_ODMIMAGE_TARGET) \
5390 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5391
5392ifeq (,$(TARGET_BUILD_UNBUNDLED))
5393$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
5394 $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
5395
5396endif
Jeongik Chaa8056d62021-04-07 23:57:16 +09005397
5398$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
5399 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Chab26bf582021-06-08 11:31:31 +09005400
5401ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jeongik Cha35bf6b02021-04-23 19:09:04 +09005402ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09005403 $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09005404endif
5405ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
Jeongik Chaa8056d62021-04-07 23:57:16 +09005406 $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
Jeongik Cha35bf6b02021-04-23 19:09:04 +09005407endif
Jeongik Chab26bf582021-06-08 11:31:31 +09005408endif #!TARGET_BUILD_UNBUNDLED
Jeongik Chaa8056d62021-04-07 23:57:16 +09005409 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
5410
Jeongik Chab26bf582021-06-08 11:31:31 +09005411.PHONY: dexpreopt_config_zip
5412dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
5413
Dario Frenid1011272018-07-23 20:20:15 +01005414# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005415# A zip of the symbols directory. Keep the full paths to make it
5416# more obvious where these files came from.
5417#
5418name := $(TARGET_PRODUCT)
5419ifeq ($(TARGET_BUILD_TYPE),debug)
5420 name := $(name)_debug
5421endif
5422name := $(name)-symbols-$(FILE_NAME_TAG)
5423
5424SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07005425# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005426ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005427$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07005428endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005429$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
5430$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005431 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005432 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5433 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09005434 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07005435 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005436# -----------------------------------------------------------------
5437# A zip of the coverage directory.
5438#
Oliver Nguyene91ab232019-04-30 15:14:44 -07005439name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07005440ifeq ($(TARGET_BUILD_TYPE),debug)
5441name := $(name)_debug
5442endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07005443COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005444ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005445$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005446endif
5447$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
5448$(COVERAGE_ZIP): $(SOONG_ZIP)
5449 @echo "Package coverage: $@"
5450 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5451 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
5452 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
5453 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005454
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08005455#------------------------------------------------------------------
5456# Export the LLVM profile data tool and dependencies for Clang coverage processing
5457#
5458ifeq (true,$(CLANG_COVERAGE))
5459 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
5460 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
5461 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
5462 $(PROFDATA_ZIP): $(SOONG_ZIP)
5463 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
5464
Bill Peckham184524a2021-06-16 14:57:36 -07005465 $(call dist-for-goals,droidcore-unbundled apps_only,$(PROFDATA_ZIP))
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08005466endif
5467
The Android Open Source Project88b60792009-03-03 19:28:42 -08005468# -----------------------------------------------------------------
5469# A zip of the Android Apps. Not keeping full path so that we don't
5470# include product names when distributing
5471#
5472name := $(TARGET_PRODUCT)
5473ifeq ($(TARGET_BUILD_TYPE),debug)
5474 name := $(name)_debug
5475endif
5476name := $(name)-apps-$(FILE_NAME_TAG)
5477
5478APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07005479$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005480 @echo "Package apps: $@"
5481 $(hide) rm -rf $@
5482 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005483 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
5484 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00005485 echo "No apps to zip up. Generating empty apps archive." ; \
5486 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005487 else \
Anton Hansson6d814982018-11-26 18:12:05 +00005488 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005489 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07005490
Ying Wangbc415dd2012-08-15 12:22:44 -07005491ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07005492#------------------------------------------------------------------
5493# An archive of classes for use in generating code-coverage reports
5494# These are the uninstrumented versions of any classes that were
5495# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07005496# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005497
Colin Crossa6bc3a82017-09-27 14:28:41 -07005498JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Colin Cross330b1fe2021-04-06 18:04:06 -07005499$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
5500$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
5501$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
5502$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005503$(JACOCO_REPORT_CLASSES_ALL) :
5504 @echo "Collecting uninstrumented classes"
Colin Cross330b1fe2021-04-06 18:04:06 -07005505 mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
5506 $(SOONG_ZIP) -o $@ -L 0 \
5507 -C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
5508 -C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
5509 -C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
5510 -C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005511
Jiyong Park3c875602021-01-21 12:46:56 +09005512ifeq (,$(TARGET_BUILD_UNBUNDLED))
5513 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
5514endif
Ying Wangbc415dd2012-08-15 12:22:44 -07005515endif # EMMA_INSTRUMENT=true
5516
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005517
Ying Wangae9115a2013-08-22 20:52:47 -07005518#------------------------------------------------------------------
5519# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07005520#
Ying Wangc62c92c2013-08-28 18:38:25 -07005521PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07005522# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005523ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005524$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07005525endif
Colin Cross330b1fe2021-04-06 18:04:06 -07005526$(PROGUARD_DICT_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_dictionary)
Colin Cross114e8df2019-09-05 17:19:35 -07005527$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07005528 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross330b1fe2021-04-06 18:04:06 -07005529 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR)
5530 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(PRIVATE_PACKAGING_DIR) -P out/target/common/obj -D $(PRIVATE_PACKAGING_DIR)
Ying Wangae9115a2013-08-22 20:52:47 -07005531
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005532#------------------------------------------------------------------
5533# A zip of Proguard usage files.
5534#
5535PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
5536# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
5537ifeq (,$(TARGET_BUILD_UNBUNDLED))
5538$(PROGUARD_USAGE_ZIP): \
5539 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5540 $(INSTALLED_RAMDISK_TARGET) \
5541 $(INSTALLED_BOOTIMAGE_TARGET) \
5542 $(INSTALLED_USERDATAIMAGE_TARGET) \
5543 $(INSTALLED_VENDORIMAGE_TARGET) \
5544 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5545 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
5546 $(INSTALLED_ODMIMAGE_TARGET) \
5547 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
5548 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
5549 $(updater_dep)
5550endif
Colin Cross330b1fe2021-04-06 18:04:06 -07005551$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage.zip)/filelist
5552$(PROGUARD_USAGE_ZIP): PRIVATE_PACKAGING_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005553$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
5554 @echo "Packaging Proguard usage files."
Colin Cross330b1fe2021-04-06 18:04:06 -07005555 mkdir -p $(dir $@) $(PRIVATE_PACKAGING_DIR) $(dir $(PRIVATE_LIST_FILE))
5556 find $(PRIVATE_PACKAGING_DIR) -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005557 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07005558
5559ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5560
5561# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
5562# $(1): output file
5563define dump-super-image-info
5564 $(call dump-dynamic-partitions-info,$(1))
5565 $(if $(filter true,$(AB_OTA_UPDATER)), \
5566 echo "ab_update=true" >> $(1))
5567endef
5568
5569endif # PRODUCT_USE_DYNAMIC_PARTITIONS
5570
The Android Open Source Project88b60792009-03-03 19:28:42 -08005571# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005572# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005573
5574ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5575
5576# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5577ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5578
5579ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005580
5581# For real devices and for dist builds, build super image from target files to an intermediate directory.
5582INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5583$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5584$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5585 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005586 PATH=$(dir $(LPMAKE)):$$PATH \
5587 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005588
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005589# Skip packing it in dist package because it is in update package.
5590ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005591$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005592endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005593
5594.PHONY: superimage_dist
5595superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005596
5597endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005598endif # BOARD_SUPER_PARTITION_SIZE != ""
5599endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005600
Yifan Hongacd862a2019-04-16 15:44:30 -07005601# -----------------------------------------------------------------
5602# super partition image for development
5603
5604ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5605ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5606ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5607
5608# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5609# $(1): built image path
5610# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5611define build-superimage-target
5612 mkdir -p $(dir $(2))
5613 rm -rf $(2)
5614 $(call dump-super-image-info,$(2))
5615 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5616 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005617 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5618 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005619 mkdir -p $(dir $(1))
5620 PATH=$(dir $(LPMAKE)):$$PATH \
5621 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5622endef
5623
5624INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5625INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5626 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5627
changho.shina8f9f112019-10-15 13:26:19 +09005628ifdef BUILDING_SYSTEM_OTHER_IMAGE
5629ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5630INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5631endif
5632endif
5633
Yifan Hongacd862a2019-04-16 15:44:30 -07005634# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5635# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5636# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5637# virtual devices.
5638ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5639$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5640 $(call pretty,"Target super fs image for debug: $@")
5641 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005642 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005643
Bill Peckham315b98a2021-06-15 19:35:06 -07005644droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
Yifan Hongacd862a2019-04-16 15:44:30 -07005645
5646# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5647.PHONY: superimage
5648superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005649
5650$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005651endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5652
5653# Build $(PRODUCT_OUT)/super.img without dependencies.
5654.PHONY: superimage-nodeps supernod
5655superimage-nodeps supernod: intermediates :=
5656superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5657 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5658 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5659 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5660
5661endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5662endif # BOARD_SUPER_PARTITION_SIZE != ""
5663endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5664
5665# -----------------------------------------------------------------
5666# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00005667ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08005668
Yifan Hong8b79d162018-11-29 12:32:00 -08005669INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5670$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5671$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5672 $(call pretty,"Target empty super fs image: $@")
5673 mkdir -p $(intermediates)
5674 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005675 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005676 PATH=$(dir $(LPMAKE)):$$PATH \
5677 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005678
5679$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5680
Yo Chiange86bab42021-03-25 10:12:28 +00005681endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08005682
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005683
5684# -----------------------------------------------------------------
5685# The update package
5686
5687name := $(TARGET_PRODUCT)
5688ifeq ($(TARGET_BUILD_TYPE),debug)
5689 name := $(name)_debug
5690endif
5691name := $(name)-img-$(FILE_NAME_TAG)
5692
5693INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5694
Tao Bao57f8ed62019-08-14 23:08:18 -07005695$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5696 $(call pretty,"Package: $@")
5697 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5698 $(IMG_FROM_TARGET_FILES) \
5699 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5700 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005701
5702.PHONY: updatepackage
5703updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005704$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005705
5706
Yifan Hong2b891ac2018-11-29 12:06:31 -08005707# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005708# dalvik something
5709.PHONY: dalvikfiles
5710dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5711
Bo Huf0d50bb2017-08-01 19:02:09 +00005712ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005713MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005714MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005715SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005716
5717ifdef INSTALLED_SYSTEMIMAGE_TARGET
5718INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005719INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5720$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5721 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5722 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005723$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005724 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5725 @echo Create system-qemu.img now
5726 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005727 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005728
5729systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005730droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005731endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005732ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005733INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005734$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005735 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005736 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005737
5738vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005739droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
Bo Huf0d50bb2017-08-01 19:02:09 +00005740endif
bohu8fd437c2020-03-30 20:16:13 -07005741
5742ifdef INSTALLED_RAMDISK_TARGET
5743ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5744ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5745INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5746$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5747 @echo Create ramdisk-qemu.img
5748 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5749
Bill Peckham315b98a2021-06-15 19:35:06 -07005750droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
bohu8fd437c2020-03-30 20:16:13 -07005751endif
5752endif
5753endif
5754
Anton Hansson32c76fe2018-12-13 14:34:18 +00005755ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005756INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005757$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005758 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005759 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005760
5761productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005762droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005763endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005764ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5765INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5766$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5767 @echo Create system_ext-qemu.img
5768 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005769
Justin Yun6151e3f2019-06-25 15:58:13 +09005770systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005771droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005772endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005773ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005774INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5775$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5776 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005777 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005778
5779odmimage: $(INSTALLED_QEMU_ODMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005780droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005781endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005782
Yifan Hongcfb917a2020-05-07 14:58:20 -07005783ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5784INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5785$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5786 @echo Create vendor_dlkm-qemu.img
5787 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5788
5789vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005790droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
Yifan Hongcfb917a2020-05-07 14:58:20 -07005791endif
5792
Yifan Hongf496f1b2020-07-15 16:52:59 -07005793ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5794INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5795$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5796 @echo Create odm_dlkm-qemu.img
5797 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5798
5799odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Bill Peckham315b98a2021-06-15 19:35:06 -07005800droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
Yifan Hongf496f1b2020-07-15 16:52:59 -07005801endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005802
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005803QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005804$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5805 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005806 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005807 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5808 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005809
5810systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
Bill Peckham315b98a2021-06-15 19:35:06 -07005811droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005812
Bo Huf0d50bb2017-08-01 19:02:09 +00005813endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005814# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005815# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005816ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005817INTERNAL_EMULATOR_PACKAGE_FILES += \
5818 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005819 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005820 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005821 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5822 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005823
5824name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5825
5826INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5827
Ying Wang5d887702015-11-04 10:06:25 -08005828$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005829 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005830 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005831
Ying Wang7d8c5352012-07-26 10:15:21 -07005832endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005833
The Android Open Source Project88b60792009-03-03 19:28:42 -08005834
5835# -----------------------------------------------------------------
5836# The SDK
5837
The Android Open Source Project88b60792009-03-03 19:28:42 -08005838# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005839sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005840
5841# Build a name that looks like:
5842#
5843# linux-x86 --> android-sdk_12345_linux-x86
5844# darwin-x86 --> android-sdk_12345_mac-x86
5845# windows-x86 --> android-sdk_12345_windows
5846#
5847sdk_name := android-sdk_$(FILE_NAME_TAG)
5848ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005849 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005850else
Joe Onorato03fbe402009-04-13 08:31:16 -07005851 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005852endif
5853ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005854 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005855endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005856sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005857
5858sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5859
5860ATREE_FILES :=
5861-include $(sdk_dep_file)
5862
5863# if we don't have a real list, then use "everything"
5864ifeq ($(strip $(ATREE_FILES)),)
5865ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005866 $(ALL_DEFAULT_INSTALLED_MODULES) \
5867 $(INSTALLED_RAMDISK_TARGET) \
5868 $(ALL_DOCS) \
5869 $(ALL_SDK_FILES)
5870endif
5871
5872atree_dir := development/build
5873
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005874
The Android Open Source Project88b60792009-03-03 19:28:42 -08005875sdk_atree_files := \
5876 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005877 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005878
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005879# development/build/sdk-android-<abi>.atree is used to differentiate
5880# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5881# files like the kernel image. We use TARGET_CPU_ABI because we don't
5882# have a better way to distinguish between CPU models.
5883ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5884 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5885endif
5886
Anton Hansson8dab0a62019-03-28 15:45:40 +00005887ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5888sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005889else
5890sdk_atree_files += $(atree_dir)/sdk.atree
5891endif
5892
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005893include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005894
The Android Open Source Project88b60792009-03-03 19:28:42 -08005895deps := \
5896 $(target_notice_file_txt) \
5897 $(tools_notice_file_txt) \
5898 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005899 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005900 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005901 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005902 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005903 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005904 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005905 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005906 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005907 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005908 $(INSTALLED_USERDATAIMAGE_TARGET) \
5909 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005910 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005911 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005912 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005913 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005914 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005915 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005916 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005917
5918INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5919$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5920$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5921$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5922$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5923
5924# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5925#
5926#SDK_GNU_ERROR := true
5927
Ying Wang5d887702015-11-04 10:06:25 -08005928$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005929 @echo "Package SDK: $@"
5930 $(hide) rm -rf $(PRIVATE_DIR) $@
Sasha Smundak0e4a5ad2021-05-13 13:37:53 -07005931 $(hide) for f in $(strip $(target_gnu_MODULES)); do \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005932 if [ -f $$f ]; then \
5933 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5934 including GNU target $$f >&2; \
5935 FAIL=$(SDK_GNU_ERROR); \
5936 fi; \
5937 done; \
5938 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005939 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005940 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005941 ATREE_STRIP="$(HOST_STRIP) -x" \
5942 $(HOST_OUT_EXECUTABLES)/atree \
5943 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5944 -m $(PRIVATE_DEP_FILE) \
5945 -I . \
5946 -I $(PRODUCT_OUT) \
5947 -I $(HOST_OUT) \
5948 -I $(TARGET_COMMON_OUT_ROOT) \
5949 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5950 -v "OUT_DIR=$(OUT_DIR)" \
5951 -v "HOST_OUT=$(HOST_OUT)" \
5952 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5953 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5954 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5955 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5956 -o $(PRIVATE_DIR) && \
5957 cp -f $(target_notice_file_txt) \
5958 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5959 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5960 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5961 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5962 chmod -R ug+rwX $(PRIVATE_DIR) && \
5963 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005964 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5965
Raphael3d224a02010-04-16 17:50:09 -07005966
5967# Is a Windows SDK requested? If so, we need some definitions from here
5968# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005969MAIN_SDK_NAME := $(sdk_name)
5970MAIN_SDK_DIR := $(sdk_dir)
5971MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005972ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005973include $(TOPDIR)development/build/tools/windows_sdk.mk
5974endif
5975
The Android Open Source Project88b60792009-03-03 19:28:42 -08005976# -----------------------------------------------------------------
5977# Findbugs
5978INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5979INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5980$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5981 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005982 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005983 > $@
5984$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5985 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005986 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005987 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005988
5989# -----------------------------------------------------------------
5990# Findbugs
5991
5992# -----------------------------------------------------------------
5993# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005994ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005995include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005996-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005997-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005998-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005999# Also the project-specific tasks
6000-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
6001-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07006002-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07006003# Also add test specifc tasks
6004include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07006005include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07006006endif
Raphaelc4d47312011-02-15 16:09:36 -08006007
Ying Wang67132ba2015-10-28 16:42:39 -07006008include $(BUILD_SYSTEM)/product-graph.mk
6009
Raphaelc4d47312011-02-15 16:09:36 -08006010# -----------------------------------------------------------------
6011# Create SDK repository packages. Must be done after tasks/* since
6012# we need the addon rules defined.
6013ifneq ($(sdk_repo_goal),)
6014include $(TOPDIR)development/build/tools/sdk_repo.mk
6015endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07006016
6017# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07006018# Soong generates the list of all shared libraries that are depended on by fuzz
6019# targets. It saves this list as a source:destination pair to
6020# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
6021# build of the unstripped shared library, and the destination is the
6022# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
6023# where fuzz target shared libraries are to be "reinstalled". The
6024# copy-many-files below generates the rules to copy the unstripped shared
6025# libraries to the device or host "reinstallation" directory. These rules are
6026# depended on by each module in soong_cc_prebuilt.mk, where the module will have
6027# a dependency on each shared library that it needs to be "reinstalled".
6028FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
6029
6030# -----------------------------------------------------------------
hamzeh5dfe7a22021-04-29 12:44:16 -07006031# The rule to build all fuzz targets for C++ and Rust, and package them.
Mitch Phillipsceefc442019-09-26 16:37:59 -07006032# Note: The packages are created in Soong, and in a perfect world,
6033# we'd be able to create the phony rule there. But, if we want to
6034# have dist goals for the fuzz target, we need to have the PHONY
6035# target defined in make. MakeVarsContext.DistForGoal doesn't take
6036# into account that a PHONY rule create by Soong won't be available
6037# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08006038# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07006039# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08006040.PHONY: haiku
6041haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
6042$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
hamzeh5dfe7a22021-04-29 12:44:16 -07006043
6044.PHONY: haiku-rust
6045haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
6046$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))