blob: fc9f64e2d62428b3e947f36d411413e5e0950f19 [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
Dan Willemsen7537fd02018-10-16 23:15:08 -070086$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
87
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
Colin Crossd60401a2019-04-18 14:46:48 -0700166$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800167
Andres Moralesb8876e12015-05-06 20:44:22 -0700168INSTALLED_RECOVERYIMAGE_TARGET :=
Yifan Hong881df392020-10-09 14:29:39 -0700169# Build recovery image if
170# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
171# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
172# with recovery resources.
173# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
174# but not the final recovery image.
Chris Grossa784ef12019-04-22 11:09:57 -0700175ifdef BUILDING_RECOVERY_IMAGE
176ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong881df392020-10-09 14:29:39 -0700177ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -0700178INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
179endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700180endif
Yifan Hong881df392020-10-09 14:29:39 -0700181endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700182
Jiyong Parke1346862020-05-18 14:31:30 +0900183include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100184
185# ----------------------------------------------------------------
186
187# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800188# sdk-build.prop
189#
190# There are certain things in build.prop that we don't want to
191# ship with the sdk; remove them.
192
193# This must be a list of entire property keys followed by
194# "=" characters, without any internal spaces.
195sdk_build_prop_remove := \
196 ro.build.user= \
197 ro.build.host= \
198 ro.product.brand= \
199 ro.product.manufacturer= \
200 ro.product.device=
201# TODO: Remove this soon-to-be obsolete property
202sdk_build_prop_remove += ro.build.product=
203INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
204$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
205 @echo SDK buildinfo: $@
206 @mkdir -p $(dir $@)
207 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000208 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800209 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000210 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800211 $(hide) mv $@.tmp $@
212
213# -----------------------------------------------------------------
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800214# Declare vendor ramdisk fragments
215INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
216
217# Validation check and assign default --ramdisk_type.
218$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
219 $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
220 $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
221 $(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))) \
222 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
223 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
224 $(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
225 $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
226 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
227)
228
229# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
230$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
231 $(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
232 $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
233 $(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)) \
234 $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
235 ) \
236)
237INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
238
239# Assign --ramdisk_name for each vendor ramdisk fragment.
240$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
241 $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
242 $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
243 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
244 $(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
245)
246
247# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700248# kernel modules
249
250# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
251DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
252
J. Avilaa2ceec62020-05-12 23:40:02 +0000253define copy-and-strip-kernel-module
254$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000255 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000256endef
257
Colin Cross4f60e362019-06-05 11:53:43 -0700258# $(1): modules list
259# $(2): output dir
260# $(3): mount point
261# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700262# $(5): module load list
263# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800264# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000265# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700266# $(9): module directory name
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800267# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700268define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700269 $(if $(9), \
270 $(eval _dir := $(9)/), \
271 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000272 $(foreach module,$(1), \
273 $(eval _src := $(module)) \
274 $(if $(8), \
275 $(eval _src := $(8)/$(notdir $(module))) \
276 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700277 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700278 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700279 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
280 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
281 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
282 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700283endef
284
285# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700286# $(2): mount point
287# $(3): staging dir
288# $(4): module load list
289# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800290# $(6): module archive
291# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700292# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800293# TODO(b/144844424): If a module archive is being used, this step (which
294# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
295# the output directory. This should be moved to a module with a
296# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
297# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700298define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700299$(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 -0700300$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
301$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
302$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700303$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700304$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
305$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
306$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800307$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
308$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
309$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700310 @echo depmod $$(PRIVATE_STAGING_DIR)
311 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700312 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800313 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700314 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800315 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700316 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800317 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
318 )
319 $(if $(1),\
320 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
321 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
322 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
323 done; \
324 )
Colin Cross4f60e362019-06-05 11:53:43 -0700325 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
326 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700327 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
328 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700329endef
330
Steve Muckle474e4d02019-06-19 12:56:48 -0700331# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700332# $(2): modules list
333# $(3): module load list
334# $(4): module load list filename
335# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700336define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700337 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
338 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700339endef
340
341# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700342# $(2): modules list
343# $(3): module load list
344# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700345define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700346$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
347$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
348 @echo load-list $$(@)
349 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700350endef
351
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800352# $(1): source blocklist file
353# $(2): destination pathname
354# Returns a build rule that checks the syntax of and installs a kernel modules
355# blocklist file. Strip and squeeze any extra space in the blocklist.
356# For use via $(eval).
357define build-image-kernel-modules-blocklist-file
358$(2): $(1)
359 @echo "modprobe blocklist $$(@)"
360 $(hide) mkdir -p "$$(dir $$@)"
361 $(hide) rm -f "$$@"
362 $(hide) awk <"$$<" >"$$@" \
363 '/^#/ { print; next } \
364 NF == 0 { next } \
365 NF != 2 || $$$$1 != "blocklist" \
366 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
367 exit_status = 1; next } \
368 { $$$$1 = $$$$1; print } \
369 END { exit exit_status }'
370endef
371
Steve Muckle2335d762020-05-28 18:39:38 -0700372# $(1): image name
373# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
374# $(3): mount point
375# $(4): module load filename
376# $(5): stripped staging directory
377# $(6): kernel module directory name (top is an out of band value for no directory)
378define build-image-kernel-modules-dir
379$(if $(filter top,$(6)),\
380 $(eval _kver :=)$(eval _sep :=),\
381 $(eval _kver := $(6))$(eval _sep :=_))\
382$(if $(5),\
383 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
384 $(eval _stripped_staging_dir :=))\
385$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
386 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
387 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800388 $(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)))) \
389$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
390 $(eval $(call build-image-kernel-modules-blocklist-file, \
391 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
392 $(2)/lib/modules/modules.blocklist)) \
393 $(2)/lib/modules/modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700394endef
395
396# $(1): kernel module directory name (top is an out of band value for no directory)
397define build-recovery-as-boot-load
398$(if $(filter top,$(1)),\
399 $(eval _kver :=)$(eval _sep :=),\
400 $(eval _kver := $(1))$(eval _sep :=_))\
401 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
402 $(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))))
403endef
404
405# $(1): kernel module directory name (top is an out of band value for no directory)
406define build-vendor-ramdisk-recovery-load
407$(if $(filter top,$(1)),\
408 $(eval _kver :=)$(eval _sep :=),\
409 $(eval _kver := $(1))$(eval _sep :=_))\
410 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
411 $(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))))
412endef
413
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700414# $(1): kernel module directory name (top is an out of band value for no directory)
415define build-vendor-charger-load
416$(if $(filter top,$(1)),\
417 $(eval _kver :=)$(eval _sep :=),\
418 $(eval _kver := $(1))$(eval _sep :=_))\
419 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
420 $(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))))
421endef
422
Steve Mucklee1b10862019-07-10 10:49:37 -0700423ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
424 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
425 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700426 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700427 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
428endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700429
Steve Muckle69280d22019-07-11 12:23:38 -0700430ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
431 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700432endif
433
Steve Mucklee1b10862019-07-10 10:49:37 -0700434ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700435 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700436 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700437 endif
438endif
439
J. Avilaa2ceec62020-05-12 23:40:02 +0000440ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
441 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
442else
443 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
444endif
Colin Cross4f60e362019-06-05 11:53:43 -0700445
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700446ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
447 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
448else
449 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
450endif
451
Steve Muckle2335d762020-05-28 18:39:38 -0700452BOARD_KERNEL_MODULE_DIRS += top
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800453$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
454 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(kmd))) \
455 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800456 $(if $(vendor_ramdisk_fragment), \
457 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
458 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
459 $(eval ### else ###), \
460 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
461 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800462 $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
463 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
464 $(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))) \
465 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
466 $(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 -0700467 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Yi-Yo Chiang1519d432021-04-04 16:03:10 +0800468 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
469 $(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 -0700470
471# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800472# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700473# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900474# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700475# $2 certificate
476# $3 private key
477# $4 compressed
478# $5 partition tag
479# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100480define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700481$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
482$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
483$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
484$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700485
486endef
487
Jaewoong Jung704b4542020-06-29 19:37:53 -0700488# -----------------------------------------------------------------
489# Merge an individual apkcerts output into the final apkcerts.txt output.
490# Use a macro to make it compatible with _apkcerts_write_line
491# $1 apkcerts file to be merged
492# $2 output file
493define _apkcerts_merge
494$(hide) cat $1 >> $2
495
496endef
497
The Android Open Source Project88b60792009-03-03 19:28:42 -0800498name := $(TARGET_PRODUCT)
499ifeq ($(TARGET_BUILD_TYPE),debug)
500 name := $(name)_debug
501endif
502name := $(name)-apkcerts-$(FILE_NAME_TAG)
503intermediates := \
504 $(call intermediates-dir-for,PACKAGING,apkcerts)
505APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700506all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
507$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800508# We don't need to really build all the modules.
509# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700510$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800511 @echo APK certs list: $@
512 @mkdir -p $(dir $@)
513 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700514 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700515 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
516 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
517 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700518 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700519 $(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 -0700520 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700521 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800522
523.PHONY: apkcerts-list
524apkcerts-list: $(APKCERTS_FILE)
525
Ying Wang15e487a2011-02-15 10:56:18 -0800526ifneq (,$(TARGET_BUILD_APPS))
527 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900528 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800529endif
Ying Wangefb21682010-07-23 16:42:13 -0700530
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900531
The Android Open Source Project88b60792009-03-03 19:28:42 -0800532# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700533# build system stats
534BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
535$(BUILD_SYSTEM_STATS):
536 @rm -f $@
537 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
538 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
539$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700540
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700541# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800542# build /product/etc/security/avb/system_other.avbpubkey if needed
543ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800544ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800545INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
546ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800547endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800548endif # BUILDING_SYSTEM_OTHER_IMAGE
549
550# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700551# Modules ready to be converted to Soong, ordered by how many
552# modules depend on them.
553SOONG_CONV := $(sort $(SOONG_CONV))
554SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
555$(SOONG_CONV_DATA):
556 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700557 @$(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 -0700558
Colin Crossfdea8932017-12-06 14:38:40 -0800559SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700560SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
561$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
562 @rm -f $@
563 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
564$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
565
Joe Onorato02fb89a2020-06-27 00:10:23 -0700566MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
567MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
568$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
569$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
570 @rm -f $@
571 $(hide) $(MK2BP_CATALOG_SCRIPT) \
572 --device=$(TARGET_DEVICE) \
573 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
574 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
575 --out_dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700576 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700577 > $@
578$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
579
Joe Onorato31986072020-08-10 09:58:49 -0700580MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
581$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
582 @rm -f $@
583 $(hide) $(MK2BP_CATALOG_SCRIPT) \
584 --device=$(TARGET_DEVICE) \
585 --out_dir="$(OUT_DIR)" \
586 --mode=csv \
587 > $@
588$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_CSV))
589
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700590# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800591# Modules use -Wno-error, or added default -Wall -Werror
592WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
593$(WALL_WERROR):
594 @rm -f $@
595 echo "# Modules using -Wno-error" >> $@
596 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 -0800597 echo "# Modules added default -Wall" >> $@
598 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
599
600$(call dist-for-goals,droidcore,$(WALL_WERROR))
601
602# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700603# C/C++ flag information for modules
604$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
605
606# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800607# Modules missing profile files
608PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
609$(PGO_PROFILE_MISSING):
610 @rm -f $@
611 echo "# Modules missing PGO profile files" >> $@
612 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
613
614$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
615
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000616CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
617$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
618 rm -f $@
619 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
620$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
621
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800622# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700623# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700624# for future OTA packages installed by this system. Actual product
625# deliverables will be re-signed by hand. We expect this file to
626# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700627DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700628
629
Jeff Browne33ba4c2011-07-11 22:11:46 -0700630# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800631# if they don't do anything.
632.PHONY: systemimage
633systemimage:
634
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800635# -----------------------------------------------------------------
636
637.PHONY: event-log-tags
638
Joe Onoratob7510532010-07-14 10:22:54 -0700639# Produce an event logs tag file for everything we know about, in order
640# to properly allocate numbers. Then produce a file that's filtered
641# for what's going to be installed.
642
643all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
644
Colin Crossdc8f8e42012-04-12 13:25:54 -0700645event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
646
Joe Onoratob7510532010-07-14 10:22:54 -0700647# Include tags from all packages that we know about
648all_event_log_tags_src := \
649 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
650
Dan Willemsena3f66322020-05-28 15:46:33 -0700651$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
652$(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 -0700653 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900654 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700655
Doug Zongkera34fa952011-02-23 12:17:29 -0800656# Include tags from all packages included in this product, plus all
657# tags that are part of the system (ie, not in a vendor/ or device/
658# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800659event_log_tags_src := \
660 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800661 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800662 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800663 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
664 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800665
Dan Willemsena3f66322020-05-28 15:46:33 -0700666$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700667$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700668$(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 -0800669 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900670 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800671
672event-log-tags: $(event_log_tags_file)
673
674ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
675
Joe Onoratob7510532010-07-14 10:22:54 -0700676
The Android Open Source Project88b60792009-03-03 19:28:42 -0800677# #################################################################
678# Targets for boot/OS images
679# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800680ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
681 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000682 ifdef BOARD_PREBUILT_BOOTLOADER
683 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
684 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
685 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800686 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
687 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
688 else
689 INSTALLED_2NDBOOTLOADER_TARGET :=
690 endif
691else
692 INSTALLED_BOOTLOADER_MODULE :=
693 INSTALLED_2NDBOOTLOADER_TARGET :=
694endif # TARGET_NO_BOOTLOADER
695ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700696 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
697 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
698 $(PRODUCT_OUT)/$(k))
699 else
700 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
701 endif
Ying Wangc6349742014-01-13 16:14:20 -0800702else
703 INSTALLED_KERNEL_TARGET :=
704endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800705
706# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700707# the root dir
708INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800709 $(ALL_GENERATED_SOURCES) \
710 $(ALL_DEFAULT_INSTALLED_MODULES))
711
Luis Hector Chavezff489932018-07-03 15:41:40 -0700712INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
713INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
714$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700715$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700716 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800717 mkdir -p $(dir $@)
718 rm -f $@
719 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
720 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700721
722$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
723
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800724#------------------------------------------------------------------
725# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700726ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800727INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700728ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800729$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800730 cat $^ > $@
731endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700732endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800733
Tom Cherryd14b8952018-08-09 14:26:00 -0700734# -----------------------------------------------------------------
735# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800736ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700737INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
738 $(ALL_GENERATED_SOURCES) \
739 $(ALL_DEFAULT_INSTALLED_MODULES))
740
741INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
742INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
743$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700744$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700745 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800746 mkdir -p $(TARGET_RAMDISK_OUT)
747 mkdir -p $(dir $@)
748 rm -f $@
749 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
750 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700751
752$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700753BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
754
J. Avila3f6560e2020-05-11 20:20:03 +0000755ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
756# -l enables the legacy format used by the Linux kernel
757COMPRESSION_COMMAND_DEPS := $(LZ4)
758COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
759RAMDISK_EXT := .lz4
760else
761COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
762COMPRESSION_COMMAND := $(MINIGZIP)
763RAMDISK_EXT := .gz
764endif
765
Joe Onorato64d85d02009-04-09 19:31:12 -0700766# We just build this directly to the install location.
767INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000768$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800769 $(call pretty,"Target ramdisk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000770 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800771
Ying Wangad7fd292013-08-08 16:34:29 -0700772.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000773ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700774 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000775 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800776
Dan Willemsen67495202019-01-16 12:42:05 -0800777endif # BUILDING_RAMDISK_IMAGE
778
The Android Open Source Project88b60792009-03-03 19:28:42 -0800779# -----------------------------------------------------------------
780# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700781
782# This is defined here since we may be building recovery as boot
783# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700784ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
785 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
786else
787 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
788endif
789
Yifan Hong0674a6e2020-10-22 14:37:01 -0700790INTERNAL_PREBUILT_BOOTIMAGE :=
791
792my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
793ifdef my_installed_prebuilt_gki_apex
794 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
795 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
796 endif # len(my_installed_prebuilt_gki_apex) > 1
797
798 ifdef BOARD_PREBUILT_BOOTIMAGE
799 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
800 endif # BOARD_PREBUILT_BOOTIMAGE defined
801
802 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
803 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
804 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
805
806 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
807
808else # my_installed_prebuilt_gki_apex not defined
809
Steve Muckle04b6f052020-08-09 14:36:56 -0700810# $1: boot image target
811# returns the kernel used to make the bootimage
812define bootimage-to-kernel
813 $(if $(BOARD_KERNEL_BINARIES),\
814 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
815 $(INSTALLED_KERNEL_TARGET))
816endef
817
Steve Muckle903a1ca2020-05-07 17:32:10 -0700818ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
819 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
820endif
821
822# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800823# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700824define get-bootimage-partition-size
825 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
826endef
Chris Grossa784ef12019-04-22 11:09:57 -0700827
828ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800829INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700830 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700831
832ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
833INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
834endif
835
Steve Mucklee1b10862019-07-10 10:49:37 -0700836ifndef BUILDING_VENDOR_BOOT_IMAGE
837ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
838 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
839endif
840endif
841
The Android Open Source Project88b60792009-03-03 19:28:42 -0800842INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
843
Anton Hansson8dab0a62019-03-28 15:45:40 +0000844ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700845ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000846VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700847 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
848endif
849endif
850
Anton Hansson72e36f02019-02-26 17:36:30 +0000851INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700852
Yifan Hong46aff092020-10-28 13:50:47 -0700853# kernel cmdline/base/pagesize in boot.
854# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
855# device-specific.
856# - If not using GKI:
857# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
858# - Otherwise, put them in boot.
859ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -0700860 ifdef GENERIC_KERNEL_CMDLINE
861 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
862 endif
Yifan Hong46aff092020-10-28 13:50:47 -0700863else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
864 ifdef INTERNAL_KERNEL_CMDLINE
865 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
866 endif
867 ifdef BOARD_KERNEL_BASE
868 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
869 endif
870 ifdef BOARD_KERNEL_PAGESIZE
871 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
872 endif
873endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700874
Sami Tolvanen3303d902016-03-15 16:49:30 +0000875INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -0700876 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +0000877 --os_patch_level $(PLATFORM_SECURITY_PATCH)
878
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800879ifdef BOARD_GKI_SIGNING_KEY_PATH
880ifndef BOARD_GKI_SIGNING_ALGORITHM
881$(error BOARD_GKI_SIGNING_ALGORITHM should be defined with BOARD_GKI_SIGNING_KEY_PATH)
882endif
883INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS := \
884 --gki_signing_key $(BOARD_GKI_SIGNING_KEY_PATH) \
885 --gki_signing_algorithm $(BOARD_GKI_SIGNING_ALGORITHM) \
886 --gki_signing_avbtool_path $(AVBTOOL)
887endif
888
889# Using double quote to pass BOARD_GKI_SIGNING_SIGNATURE_ARGS as a single string
890# to MKBOOTIMG, although it may contain multiple args.
891ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
892INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS += \
893 --gki_signing_signature_args "$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)"
894endif
895
Chris Grossa784ef12019-04-22 11:09:57 -0700896# Define these only if we are building boot
897ifdef BUILDING_BOOT_IMAGE
898INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
899
The Android Open Source Project88b60792009-03-03 19:28:42 -0800900ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800901$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700902endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -0400903
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700904$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
905
906ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -0400907
Steve Muckle04b6f052020-08-09 14:36:56 -0700908# $1: boot image target
909define build_boot_board_avb_enabled
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800910 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
911 $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700912 $(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 -0700913 $(AVBTOOL) add_hash_footer \
914 --image $(1) \
Yifan Hongebe65f82020-10-15 14:48:07 -0700915 --partition_size $(call get-bootimage-partition-size,$(1),boot) \
Steve Muckle04b6f052020-08-09 14:36:56 -0700916 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
917 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
918endef
919
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800920$(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 -0400921 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700922 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400923
924.PHONY: bootimage-nodeps
Bowgo Tsai27c39b02021-03-12 21:40:32 +0800925bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(BOARD_GKI_SIGNING_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400926 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700927 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400928
Anton Hansson8dab0a62019-03-28 15:45:40 +0000929else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700930
Steve Muckle04b6f052020-08-09 14:36:56 -0700931# $1: boot image target
932define build_boot_supports_boot_signer
933 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
934 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700935 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700936endef
937
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700938$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -0700939 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700940 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700941
942.PHONY: bootimage-nodeps
943bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
944 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700945 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700946
Anton Hansson8dab0a62019-03-28 15:45:40 +0000947else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800948
Steve Muckle04b6f052020-08-09 14:36:56 -0700949# $1: boot image target
950define build_boot_supports_vboot
951 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
952 $(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 -0700953 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700954endef
955
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700956$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800957 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700958 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800959
960.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800961bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800962 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700963 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800964
965else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800966
Steve Muckle04b6f052020-08-09 14:36:56 -0700967# $1: boot image target
968define build_boot_novboot
969 $(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 -0700970 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700971endef
972
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700973$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700975 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700976
977.PHONY: bootimage-nodeps
978bootimage-nodeps: $(MKBOOTIMG)
979 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700980 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700981
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700982endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -0700983endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800984
Tao Baob1a2e352018-08-14 16:17:12 -0700985else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700986ifdef BOARD_PREBUILT_BOOTIMAGE
987ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
988# Remove when b/63676296 is resolved.
989$(error Prebuilt bootimage is only supported for AB targets)
990endif
Yifan Hong0674a6e2020-10-22 14:37:01 -0700991INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +0900992INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Yifan Hong0674a6e2020-10-22 14:37:01 -0700993$(eval $(call copy-one-file,$(INTERNAL_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700994else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700995INSTALLED_BOOTIMAGE_TARGET :=
996endif # BOARD_PREBUILT_BOOTIMAGE
997endif # TARGET_NO_KERNEL
Yifan Hong0674a6e2020-10-22 14:37:01 -0700998endif # my_installed_prebuilt_gki_apex not defined
999
1000my_apex_extracted_boot_image :=
1001my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001002
1003# -----------------------------------------------------------------
Yifan Hong881df392020-10-09 14:29:39 -07001004# declare recovery ramdisk files
1005ifeq ($(BUILDING_RECOVERY_IMAGE),true)
1006INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
1007endif
1008
1009# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -07001010# vendor boot image
1011ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
1012
1013ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
1014 $(error vboot 1.0 does not support vendor_boot partition)
1015endif
1016
1017INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
1018 $(ALL_GENERATED_SOURCES) \
1019 $(ALL_DEFAULT_INSTALLED_MODULES))
1020
Petri Gynther6a6d6212021-03-06 00:45:53 -08001021INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -07001022
1023ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
1024$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
1025$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
1026endif
1027
J. Avila3f6560e2020-05-11 20:20:03 +00001028$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -07001029 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -07001030
Petri Gynther828828b2021-03-04 11:04:03 -08001031ifeq (true,$(BOARD_BUILD_VENDOR_RAMDISK_IMAGE))
1032INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
1033$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Petri Gynther4c063e32021-03-06 13:26:01 -08001034 $(call pretty,"Target vendor ramdisk: $@")
Petri Gynther828828b2021-03-04 11:04:03 -08001035 $(copy-file-to-target)
1036endif
1037
Petri Gynther6ff52012020-11-20 11:59:41 -08001038INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1039INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1040$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1041$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1042$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001043 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001044 mkdir -p $(dir $@)
1045 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001046 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1047 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001048
Steve Mucklee1b10862019-07-10 10:49:37 -07001049ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1050 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1051endif
1052ifdef BOARD_KERNEL_BASE
1053 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1054endif
1055ifdef BOARD_KERNEL_PAGESIZE
1056 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1057endif
1058ifdef INTERNAL_KERNEL_CMDLINE
1059 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1060endif
1061
Devin Moore50509012021-01-13 10:45:04 -08001062ifdef INTERNAL_BOOTCONFIG
Yi-Yo Chiang9c461362021-04-04 03:26:18 +08001063 ifneq (,$(findstring androidboot.hardware=, $(INTERNAL_BOOTCONFIG)))
1064 $(error "androidboot.hardware" BOOTCONFIG parameter is not supported due \
1065 to bootconfig limitations. Use "hardware" instead. INTERNAL_BOOTCONFIG: \
1066 $(INTERNAL_BOOTCONFIG))
1067 endif
1068 INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1069 $(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
Devin Moore50509012021-01-13 10:45:04 -08001070 rm -f $@
1071 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1072 printf "%s\n" $(param) >> $@;)
1073 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1074endif
1075
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001076# $(1): Build target name
1077# $(2): Staging dir to be compressed
1078# $(3): Build dependencies
1079define build-vendor-ramdisk-fragment-target
1080$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1081 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1082endef
1083
1084# $(1): Ramdisk name
1085define build-vendor-ramdisk-fragment
1086$(strip \
1087 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1088 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1089 $(build_target) \
1090)
1091endef
1092
1093# $(1): Ramdisk name
1094# $(2): Prebuilt file path
1095define build-prebuilt-vendor-ramdisk-fragment
1096$(strip \
1097 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1098 $(eval $(call copy-one-file,$(2),$(build_target))) \
1099 $(build_target) \
1100)
1101endef
1102
1103INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1104INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1105
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001106$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001107 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1108 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1109 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1110 $(eval ### else ###), \
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08001111 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001112 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1113 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1114)
1115
Steve Mucklee1b10862019-07-10 10:49:37 -07001116INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1117$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001118$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001119ifeq ($(BOARD_AVB_ENABLE),true)
1120$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1121 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001122 $(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 -07001123 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1124 $(AVBTOOL) add_hash_footer \
1125 --image $@ \
1126 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
1127 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1128 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1129else
1130$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1131 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001132 $(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 -07001133 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1134endif
1135endif # BUILDING_VENDOR_BOOT_IMAGE
1136
1137# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001138# NOTICE files
1139#
Steve Blockd14d3b42012-03-01 11:34:41 +00001140# We are required to publish the licenses for all code under BSD, GPL and
1141# Apache licenses (and possibly other more exotic ones as well). We err on the
1142# side of caution, so the licenses for other third-party code are included here
1143# too.
1144#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001145# This needs to be before the systemimage rules, because it adds to
1146# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1147# go into the systemimage.
1148
Steve Block495e5852012-02-29 19:18:08 +00001149.PHONY: notice_files
1150
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001151# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -07001152# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
1153# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
1154# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
1155# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001156# $(2) - Plain text output file
1157# $(3) - HTML/XML output file
1158# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -07001159# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -08001160# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001161# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -08001162# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -08001163#
1164# The algorithm here is that we go collect a hash for each of the notice
1165# files and write the names of the files that match that hash. Then
1166# to generate the real files, we go print out all of the files and their
1167# hashes.
1168#
1169# These rules are fairly complex, so they depend on this makefile so if
1170# it changes, they'll run again.
1171#
1172# TODO: We could clean this up so that we just record the locations of the
1173# original notice files instead of making rules to copy them somwehere.
1174# Then we could traverse that without quite as much bash drama.
1175define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -07001176$(2): PRIVATE_MESSAGE := $(4)
1177$(2): PRIVATE_DIR := $(5)
1178$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
1179$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -08001180 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -07001181 $(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, \
1182 $(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 +00001183 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001184 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001185 $(if $(filter $(1),xml_system),-i system --xml-output, \
1186 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001187 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001188 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
1189 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -07001190 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001191notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001192endef
1193
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001194# Notice file logic isn't relevant for TARGET_BUILD_APPS
1195ifndef TARGET_BUILD_APPS
1196
The Android Open Source Project88b60792009-03-03 19:28:42 -08001197# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1198# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1199# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001200target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001201tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001202tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001203kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1204winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001205
Bob Badour4b25c902020-01-28 13:23:39 -08001206# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1207# reasons--not to be flashed onto any device. Targets under these directories
1208# need no associated notice file on the device UI.
1209exclude_target_dirs := apex
1210
Steven Morelandae69e572017-12-15 14:49:55 -08001211# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001212ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1213target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1214target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1215installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1216$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001217 $(target_notice_file_txt), \
1218 $(target_notice_file_html), \
1219 "Notices for files contained in the filesystem images in this directory:", \
1220 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -07001221 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -08001222 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001223$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1224 $(hide) $(MINIGZIP) -9 < $< > $@
1225$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1226 $(copy-file-to-target)
1227else
1228target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1229target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001230installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1231
1232target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1233target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1234target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1235installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001236
1237target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1238target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1239target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1240installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001241
Justin Yun6151e3f2019-06-25 15:58:13 +09001242target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1243target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1244target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1245installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001246
Chris Gross15d96552019-07-16 14:38:43 -07001247target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1248target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1249target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1250installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1251
Yifan Hong3d3f0302020-05-11 18:35:11 -07001252target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1253target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1254target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1255installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1256
Yifan Hongc83f9e92020-07-15 16:57:47 -07001257target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1258target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1259target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1260installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1261
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001262# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1263# being built. A notice xml file must depend on all modules that could potentially
1264# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001265license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001266# Only files copied to a system image need system image notices.
1267license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001268# Phonys/fakes don't have notice files (though their deps might)
1269license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001270# testcases are not relevant to the system image.
1271license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001272# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001273license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001274# system_other is relevant to system partition.
1275license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001276license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1277license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001278license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001279license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001280license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001281license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001282license_modules_agg := $(license_modules_system) \
1283 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001284 $(license_modules_product) \
1285 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001286 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001287 $(license_modules_vendor_dlkm) \
1288 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001289# targets used for debug symbols only and do not get copied to the device
1290license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1291
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001292license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001293license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1294
1295# Identify the other targets we expect to have notices for:
1296# targets copied to the device but are not readable by the UI (e.g. must boot
1297# into a different partition to read or don't have an associated /etc
1298# directory) must have their notices built somewhere readable.
1299license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1300license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1301license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1302license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1303license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1304license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001305license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001306license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1307license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1308license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1309license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1310license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1311license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1312
1313# after removing targets in system images, targets reported in system images, and
1314# targets used for debug symbols that do not need notices, nothing must remain.
1315license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1316$(call maybe-print-list-and-error, $(license_modules_rest), \
1317 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001318
Chris Grossaad39b32019-06-13 09:43:26 -07001319# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1320# update its notice file, so include those notices in the system partition instead
1321ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001322license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001323system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1324system_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 -07001325else
Bob Badour4b25c902020-01-28 13:23:39 -08001326license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001327system_xml_directories := xml_system
1328system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001329endif
1330
1331$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001332 $(target_notice_file_txt), \
1333 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001334 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001335 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001336 $(license_modules_system), \
1337 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001338$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001339 $(target_vendor_notice_file_txt), \
1340 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001341 "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 +00001342 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001343 $(license_modules_vendor), \
1344 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001345$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001346 $(target_product_notice_file_txt), \
1347 $(target_product_notice_file_xml), \
1348 "Notices for files contained in the product filesystem image in this directory:", \
1349 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001350 $(license_modules_product), \
1351 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001352$(eval $(call combine-notice-files, xml_system_ext, \
1353 $(target_system_ext_notice_file_txt), \
1354 $(target_system_ext_notice_file_xml), \
1355 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001356 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001357 $(license_modules_system_ext), \
1358 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001359$(eval $(call combine-notice-files, xml_odm, \
1360 $(target_odm_notice_file_txt), \
1361 $(target_odm_notice_file_xml), \
1362 "Notices for files contained in the odm filesystem image in this directory:", \
1363 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001364 $(license_modules_odm), \
1365 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001366$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1367 $(target_vendor_dlkm_notice_file_txt), \
1368 $(target_vendor_dlkm_notice_file_xml), \
1369 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1370 $(TARGET_OUT_NOTICE_FILES), \
1371 $(license_modules_vendor_dlkm), \
1372 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001373$(eval $(call combine-notice-files, xml_odm_dlkm, \
1374 $(target_odm_dlkm_notice_file_txt), \
1375 $(target_odm_dlkm_notice_file_xml), \
1376 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1377 $(TARGET_OUT_NOTICE_FILES), \
1378 $(license_modules_odm_dlkm), \
1379 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001380
1381$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1382 $(hide) $(MINIGZIP) -9 < $< > $@
1383$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1384 $(hide) $(MINIGZIP) -9 < $< > $@
1385$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1386 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001387$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001388 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001389$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1390 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001391$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1392 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001393$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1394 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001395$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1396 $(copy-file-to-target)
1397$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1398 $(copy-file-to-target)
1399$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1400 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001401$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001402 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001403$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1404 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001405$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1406 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001407$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1408 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001409
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001410ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1411ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1412ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1413ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1414ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001415ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001416ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001417endif # PRODUCT_NOTICE_SPLIT
1418
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001419ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001420
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001421$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001422 $(tools_notice_file_txt), \
1423 $(tools_notice_file_html), \
1424 "Notices for files contained in the tools directory:", \
1425 $(HOST_OUT_NOTICE_FILES), \
1426 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001427 $(winpthreads_notice_file), \
1428 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001429
Ying Wang62c81f82013-08-22 20:02:03 -07001430endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001431
1432# The kernel isn't really a module, so to get its module file in there, we
1433# make the target NOTICE files depend on this particular file too, which will
1434# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001435$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001436
Dan Willemsen288bedf2019-05-28 15:36:47 -07001437$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001438
Doug Zongker8678df42009-06-15 14:30:14 -07001439
The Android Open Source Project88b60792009-03-03 19:28:42 -08001440# #################################################################
1441# Targets for user images
1442# #################################################################
1443
Ying Wang933abf12010-06-16 14:31:34 -07001444INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001445ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001446INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1447else
1448ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001449INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1450else
1451ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001452INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1453endif
1454endif
1455endif
1456
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001457# These options tell the recovery updater/installer how to mount the partitions writebale.
1458# <fstype>=<fstype_opts>[|<fstype_opts>]...
1459# fstype_opts := <opt>[,<opt>]...
1460# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001461# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1462DEFAULT_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 -07001463
Ying Wang542903a2010-11-17 15:40:38 -08001464ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1465 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1466endif
Gao Xiang961041a2020-06-17 13:59:16 +08001467ifneq (true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED))
1468 INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG := -s
1469endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001470ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1471 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1472endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001473ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1474 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1475endif
Tao Baodba635a2019-06-24 10:39:54 -07001476
1477INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001478 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001479 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001480 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001481
1482ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1483INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001484endif
1485
Yifan Hongcfb917a2020-05-07 14:58:20 -07001486ifneq ($(filter \
1487 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1488 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1489 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1490 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1491 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1492 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001493 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001494 ,erofs),)
1495INTERNAL_USERIMAGES_DEPS += $(MKEROFSUSERIMG)
1496endif
1497
1498ifneq ($(filter \
1499 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1500 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1501 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1502 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1503 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1504 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1505 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001506 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001507INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1508endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001509
Anton Hansson8dab0a62019-03-28 15:45:40 +00001510ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001511INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001512ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001513INTERNAL_USERIMAGES_DEPS += $(FEC)
1514endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001515endif
1516
Tao Baodba635a2019-06-24 10:39:54 -07001517ifeq ($(BOARD_AVB_ENABLE),true)
1518INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1519endif
1520
1521# Get a colon-separated list of search paths.
1522INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1523
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001524# Collects file_contexts files from modules to be installed
1525$(call merge-fc-files, \
1526 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1527 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1528
Alex Klyubin092c9022017-03-13 13:28:34 -07001529SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001530
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001531INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1532
Yifan Hongc5c01242018-11-09 10:27:23 -08001533ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001534
Anton Hansson8dab0a62019-03-28 15:45:40 +00001535ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001536 $(error vboot 1.0 doesn't support logical partition)
1537endif
1538
Yifan Hongc5c01242018-11-09 10:27:23 -08001539endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001540
Ying Wangbd93d422011-10-28 17:02:30 -07001541# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001542# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001543# $(3): additional "key=value" pairs to append to the dictionary file.
1544define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001545$(if $(filter $(2),system),\
1546 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001547 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001548 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Robin Hsu3e51f422020-11-04 09:29:09 +08001549 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "system_fs_compress=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_COMPRESS)" >> $(1))
1550 $(if $(BOARD_SYSTEMIMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "system_f2fs_sldc_flags=$(BOARD_SYSTEMIMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001551 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1552 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1553 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1554 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1555 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1556 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1557 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001558 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1559 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001560 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001561 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001562 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1563)
1564$(if $(filter $(2),system_other),\
1565 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001566)
Yifan Hong760d3c02018-05-30 11:16:46 -07001567$(if $(filter $(2),userdata),\
1568 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1569 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001570 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1571 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kimed754fb2020-10-12 19:50:05 -07001572 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001573 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001574 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001575)
Yifan Hong760d3c02018-05-30 11:16:46 -07001576$(if $(filter $(2),cache),\
1577 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1578 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001579 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001580 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001581)
1582$(if $(filter $(2),vendor),\
1583 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1584 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1585 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1586 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1587 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1588 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1589 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1590 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1591 $(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashfs_disable_4k_align=$(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001592 $(if $(PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
Yifan Hong749062d2018-06-19 16:23:16 -07001593 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001594 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001595 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001596)
1597$(if $(filter $(2),product),\
1598 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1599 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1600 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1601 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1602 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1603 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1604 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1605 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1606 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "product_squashfs_disable_4k_align=$(BOARD_PRODUCTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001607 $(if $(PRODUCT_PRODUCT_BASE_FS_PATH),$(hide) echo "product_base_fs_file=$(PRODUCT_PRODUCT_BASE_FS_PATH)" >> $(1))
Yifan Hong56a6c3b2018-07-20 15:19:34 -07001608 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001609 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001610 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001611)
Justin Yun6151e3f2019-06-25 15:58:13 +09001612$(if $(filter $(2),system_ext),\
1613 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1614 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1615 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1616 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1617 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1618 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1619 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1620 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1621 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1622 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1623 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001624 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001625)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001626$(if $(filter $(2),odm),\
1627 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1628 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1629 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1630 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1631 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1632 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1633 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1634 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1635 $(if $(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_squashfs_disable_4k_align=$(BOARD_ODMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001636 $(if $(PRODUCT_ODM_BASE_FS_PATH),$(hide) echo "odm_base_fs_file=$(PRODUCT_ODM_BASE_FS_PATH)" >> $(1))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001637 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001638 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001639 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001640)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001641$(if $(filter $(2),vendor_dlkm),\
1642 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1643 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1644 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1645 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1646 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1647 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1648 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1649 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1650 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1651 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1652 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1653 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1654)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001655$(if $(filter $(2),odm_dlkm),\
1656 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1657 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1658 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1659 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1660 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1661 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1662 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1663 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1664 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1665 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1666 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1667 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1668)
Yifan Hong760d3c02018-05-30 11:16:46 -07001669$(if $(filter $(2),oem),\
1670 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1671 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1672 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1673 $(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001674 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001675)
Tao Bao3602eca2018-07-10 10:53:55 -07001676$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001677
Tao Bao3602eca2018-07-10 10:53:55 -07001678$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001679$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Gao Xiang961041a2020-06-17 13:59:16 +08001680$(if $(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG),$(hide) echo "erofs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001681$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001682$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001683$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1684$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1685$(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 +00001686$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1687$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1688$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1689$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1690$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001691$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001692$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1693$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1694$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001695$(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 -07001696$(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 -07001697$(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 +00001698$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1699$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1700$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1701$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1702$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001703$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001704$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1705$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1706$(if $(BOARD_AVB_ENABLE),\
1707 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1708 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1709 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1710 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001711$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1712$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1713$(if $(BOARD_AVB_ENABLE),\
1714 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1715 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001716 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001717$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1718$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1719$(if $(BOARD_AVB_ENABLE),\
1720 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1721 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1722 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1723 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001724$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1725$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1726$(if $(BOARD_AVB_ENABLE),\
1727 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1728 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1729 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1730 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001731$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001732$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001733 $(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 +01001734$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001735 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1736 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1737 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1738 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001739$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1740$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1741$(if $(BOARD_AVB_ENABLE),\
1742 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1743 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1744 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1745 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001746$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1747$(if $(BOARD_AVB_ENABLE),\
1748 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1749$(if $(BOARD_AVB_ENABLE),\
1750 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1751 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1752 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1753 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001754$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1755$(if $(BOARD_AVB_ENABLE),\
1756 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1757$(if $(BOARD_AVB_ENABLE),\
1758 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1759 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1760 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1761 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001762$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1763 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001764$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001765 $(hide) echo "system_root_image=true" >> $(1))
1766$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001767$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1768 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001769$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1770endef
1771
1772# $(1): the path of the output dictionary file
1773# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001774PROP_DICTIONARY_IMAGES := oem
1775ifdef BUILDING_CACHE_IMAGE
1776 PROP_DICTIONARY_IMAGES += cache
1777endif
1778ifdef BUILDING_SYSTEM_IMAGE
1779 PROP_DICTIONARY_IMAGES += system
1780endif
Chris Gross203191b2020-05-30 02:39:12 +00001781ifdef BUILDING_SYSTEM_OTHER_IMAGE
1782 PROP_DICTIONARY_IMAGES += system_other
1783endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001784ifdef BUILDING_USERDATA_IMAGE
1785 PROP_DICTIONARY_IMAGES += userdata
1786endif
1787ifdef BUILDING_VENDOR_IMAGE
1788 PROP_DICTIONARY_IMAGES += vendor
1789endif
1790ifdef BUILDING_PRODUCT_IMAGE
1791 PROP_DICTIONARY_IMAGES += product
1792endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001793ifdef BUILDING_SYSTEM_EXT_IMAGE
1794 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001795endif
1796ifdef BUILDING_ODM_IMAGE
1797 PROP_DICTIONARY_IMAGES += odm
1798endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001799ifdef BUILDING_VENDOR_DLKM_IMAGE
1800 PROP_DICTIONARY_IMAGES += vendor_dlkm
1801endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001802ifdef BUILDING_ODM_DLKM_IMAGE
1803 PROP_DICTIONARY_IMAGES += odm_dlkm
1804endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001805define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001806 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001807endef
1808
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001809# $(1): the path of the input dictionary file, where each line has the format key=value
1810# $(2): the key to look up
1811define read-image-prop-dictionary
1812$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1813endef
1814
The Android Open Source Project88b60792009-03-03 19:28:42 -08001815# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001816# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001817
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001818# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001819ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001820
Ying Wang37526142015-03-10 12:02:57 -07001821INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1822 $(ALL_DEFAULT_INSTALLED_MODULES))
1823
Tao Bao10fc9492018-08-14 12:17:48 -07001824INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1825INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1826
Colin Cross359f4212020-12-02 15:14:04 -08001827ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1828INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1829endif
1830
Tao Bao10fc9492018-08-14 12:17:48 -07001831# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1832# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1833# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1834# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08001835$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07001836
1837$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001838$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001839 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001840 mkdir -p $(dir $@)
1841 rm -f $@
1842 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
1843 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001844
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001845recovery_sepolicy := \
1846 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001847 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001848 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001849 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1850 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1851 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001852 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001853 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001854 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1855 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1856 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001857
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001858# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1859# SELinux files
1860IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1861
Steve Muckle04b6f052020-08-09 14:36:56 -07001862# if building multiple boot images from multiple kernels, use the first kernel listed
1863# for the recovery image
1864recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001865recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001866recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001867
Anton Hansson45a40da2019-01-18 14:06:34 +00001868# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1869# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1870# which get remapped to a bucket.
1871recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001872ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1873recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001874# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001875# ------160------240------320----------480------------640------
1876# mdpi hdpi xhdpi xxhdpi xxxhdpi
1877recovery_density := $(strip \
1878 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1879 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1880 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1881 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001882endif
1883
1884ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1885recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1886else
Doug Zongker25d55f82014-04-04 13:51:15 -07001887recovery_resources_common := $(recovery_resources_common)-xhdpi
1888endif
1889
Tao Baoe1e829e2018-08-29 20:36:00 -07001890# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1891# Note that the font selected here can be overridden for a particular device by putting a font.png
1892# in its private recovery resources.
1893ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001894recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001895else
Dan Willemsen97672232020-05-27 00:09:16 -07001896recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001897endif
1898
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001899
1900# We will only generate the recovery background text images if the variable
1901# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1902# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1903# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1904# BoardConfig in order to use this feature.
1905ifeq ($(recovery_density),xxxhdpi)
1906TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1907else ifeq ($(recovery_density),xxhdpi)
1908TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1909endif
1910
1911ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1912# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1913ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1914 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1915else
1916 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1917endif
1918
1919
Dan Willemsen97672232020-05-27 00:09:16 -07001920RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001921RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1922RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1923RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1924RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1925
xunchangcc57d312018-12-07 12:12:17 -08001926RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1927RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1928RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1929RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1930RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1931
1932generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001933 $(RECOVERY_INSTALLING_TEXT_FILE) \
1934 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1935 $(RECOVERY_ERASING_TEXT_FILE) \
1936 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001937 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1938 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1939 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1940 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1941 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1942 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001943
Dan Willemsen97672232020-05-27 00:09:16 -07001944resource_dir := bootable/recovery/tools/recovery_l10n/res/
1945resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001946image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001947zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001948$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001949$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001950$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1951$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001952$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001953$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001954$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001955 recovery_installing \
1956 recovery_installing_security \
1957 recovery_erasing \
1958 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001959 recovery_no_command
1960$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001961 recovery_cancel_wipe_data \
1962 recovery_factory_data_reset \
1963 recovery_try_again \
1964 recovery_wipe_data_menu_header \
1965 recovery_wipe_data_confirmation
1966$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001967$(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 -08001968 # Prepares the font directory.
1969 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1970 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001971 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001972 @rm -rf $(dir $@)
1973 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001974 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001975 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001976 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001977 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1978 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1979 --text_name $(text_name) \
1980 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1981 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001982 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001983 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001984else
1985RECOVERY_INSTALLING_TEXT_FILE :=
1986RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1987RECOVERY_ERASING_TEXT_FILE :=
1988RECOVERY_ERROR_TEXT_FILE :=
1989RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001990RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1991RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1992RECOVERY_TRY_AGAIN_TEXT_FILE :=
1993RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1994RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001995endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1996
Ying Wang9a175682015-08-06 11:47:47 -07001997ifndef TARGET_PRIVATE_RES_DIRS
1998TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1999endif
Doug Zongker4647f122009-07-02 09:00:54 -07002000recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07002001 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08002002recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08002003
2004
Andrew Boiefa61ff02012-09-28 09:33:45 -07002005ifdef TARGET_RECOVERY_FSTAB
2006recovery_fstab := $(TARGET_RECOVERY_FSTAB)
2007else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07002008recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07002009endif
Tao Baoc3c17532016-06-10 10:11:54 -07002010ifdef TARGET_RECOVERY_WIPE
2011recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07002012else
Tao Baoc3c17532016-06-10 10:11:54 -07002013recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07002014endif
Tao Bao8beab692015-07-22 12:33:18 -07002015
Tao Bao6d5d6232018-03-09 17:04:42 -08002016# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002017# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08002018# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
2019# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002020#
2021# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08002022# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002023# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08002024# b) We build a single image that contains boot and recovery both - no recovery image to install
2025# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07002026# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08002027# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002028# d) We include the recovery DTBO image within recovery - not needing the resource file as we
2029# do bsdiff because boot and recovery will contain different number of entries
2030# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002031# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
2032# do bsdiff because boot and recovery will contain different number of entries
2033# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yifan Hongef7a9712020-10-20 13:17:42 -07002034# f) We build a single image that contains vendor_boot and recovery both - no recovery image to
2035# install
2036# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08002037
Tom Cherry2929cad2018-09-20 11:04:37 -07002038ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002039 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
2040 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002041# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002042RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2043ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002044else
Tao Bao8beab692015-07-22 12:33:18 -07002045RECOVERY_RESOURCE_ZIP :=
2046endif
Doug Zongker4647f122009-07-02 09:00:54 -07002047
Tao Bao139c7272018-07-31 13:26:54 -07002048INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2049
2050$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002051 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2052 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2053 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2054 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2055 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2056 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2057 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2058 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2059
2060# Parses the given list of build variables and writes their values as build properties if defined.
2061# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2062# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2063# $(1): Map from the build variable names to property names
2064# $(2): Output file
2065define append-recovery-ui-properties
2066echo "#" >> $(2)
2067echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2068echo "#" >> $(2)
2069$(foreach prop,$(1), \
2070 $(eval _varname := $(call word-colon,1,$(prop))) \
2071 $(eval _propname := $(call word-colon,2,$(prop))) \
2072 $(eval _value := $($(_varname))) \
2073 $(if $(_value), \
2074 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2075endef
2076
2077$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002078 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002079 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2080 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2081 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002082 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002083 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002084 $(hide) mkdir -p $(dir $@)
2085 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002086 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002087 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002088 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002089 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002090 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002091 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2092
Yifan Hong33fd5d42020-09-24 18:18:26 -07002093# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2094# On device with dedicated recovery partition, the file should come from the boot
2095# ramdisk.
2096ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2097INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2098$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2099 $(copy-file-to-target)
2100endif
2101
Yifan Hongc56931c2020-10-28 16:35:19 -07002102INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002103
Yifan Hong78860162020-10-28 14:15:21 -07002104ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002105INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002106# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002107ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002108ifdef INTERNAL_KERNEL_CMDLINE
2109 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002110endif # INTERNAL_KERNEL_CMDLINE != ""
2111endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002112ifdef BOARD_KERNEL_BASE
2113 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2114endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002115ifdef BOARD_KERNEL_PAGESIZE
2116 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2117endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002118ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002119ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2120 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2121else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002122 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2123endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002124endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002125ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2126 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2127endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002128ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2129 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2130endif
Yifan Hong3941a872020-10-28 16:33:06 -07002131endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002132ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2133 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2134endif
Doug Zongker4647f122009-07-02 09:00:54 -07002135
Yifan Hong881df392020-10-09 14:29:39 -07002136$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002137 $(INTERNAL_ROOT_FILES) \
2138 $(INSTALLED_RAMDISK_TARGET) \
2139 $(INTERNAL_RECOVERYIMAGE_FILES) \
2140 $(recovery_sepolicy) \
2141 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2142 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002143 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002144 $(recovery_resource_deps) \
2145 $(recovery_fstab)
2146 # Making recovery image
2147 mkdir -p $(TARGET_RECOVERY_OUT)
2148 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2149 # Copying baseline ramdisk...
2150 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2151 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2152 # Modifying ramdisk contents...
2153 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2154 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
2155 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2156 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2157 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2158 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2159 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2160 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2161 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2162 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2163 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2164 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2165 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2166 $(foreach item,$(recovery_fstab), \
2167 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2168 $(if $(strip $(recovery_wipe)), \
2169 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2170 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2171 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002172 $(hide) touch $@
2173
2174$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002175 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002176
Ying Wang747b9f12015-01-30 14:05:22 -08002177# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002178# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002179define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002180 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002181 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002182 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002183 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002184 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002185 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) \
2186 $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002187 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002188 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002189 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2190 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002191 )\
2192 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002193 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2194 $(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 +08002195 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002196 $(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 -07002197 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002198 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2199 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002200 $(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 -07002201 $(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 -08002202endef
2203
Dan Willemsend120ac62020-06-12 02:39:34 +00002204recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002205ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00002206 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002207endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002208ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002209 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002210endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002211ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002212 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002213endif
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002214ifdef BOARD_GKI_SIGNING_KEY_PATH
2215 recoveryimage-deps += $(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
2216endif
Tao Baof4866c72018-08-22 14:35:09 -07002217ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002218 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2219 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2220 else
2221 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2222 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002223endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002224ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002225 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002226endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002227ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002228 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002229endif
Tao Baof4866c72018-08-22 14:35:09 -07002230
Dan Willemsend120ac62020-06-12 02:39:34 +00002231ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002232$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002233$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002234 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002235 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07002236endif # BOARD_USES_RECOVERY_AS_BOOT
2237
Dan Willemsend120ac62020-06-12 02:39:34 +00002238$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002239 $(call build-recoveryimage-target, $@, \
2240 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002241
Tao Bao4594d0e2015-12-22 09:47:46 -08002242ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002243$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002244 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002245 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2246 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002247endif
Doug Zongker56588872012-08-20 15:38:58 -07002248
Ying Wang747b9f12015-01-30 14:05:22 -08002249.PHONY: recoveryimage-nodeps
2250recoveryimage-nodeps:
2251 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002252 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2253 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002254
Chris Grossa784ef12019-04-22 11:09:57 -07002255else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002256RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002257endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002258
2259.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002260recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002261
Jiyong Park03eb0612017-10-04 21:22:41 +09002262ifneq ($(BOARD_NAND_PAGE_SIZE),)
2263$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002264endif
2265
Jiyong Park03eb0612017-10-04 21:22:41 +09002266ifneq ($(BOARD_NAND_SPARE_SIZE),)
2267$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002268endif
2269
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002270ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002271# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002272# the debug ramdisk, which is the original ramdisk plus additional
2273# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2274# When /force_debuggable is present, /init will load userdebug sepolicy
2275# and property files to allow adb root, if the device is unlocked.
2276
2277ifdef BUILDING_RAMDISK_IMAGE
2278BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2279INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2280
2281INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2282 $(ALL_GENERATED_SOURCES) \
2283 $(ALL_DEFAULT_INSTALLED_MODULES))
2284
2285# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2286# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2287# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2288my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2289
2290INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2291INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2292$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2293$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2294
2295# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2296# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2297# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2298$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002299$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08002300 @echo Installed file list: $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002301 mkdir -p $(dir $@)
2302 rm -f $@
2303 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002304 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002305
2306# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2307# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2308ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2309my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2310else
2311my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2312endif # BOARD_USES_RECOVERY_AS_BOOT
2313
2314$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2315$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002316
2317ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2318# ramdisk-recovery.img isn't a make target, need to depend on boot.img if it's for recovery.
Bowgo Tsai0013f552019-03-20 17:59:52 +08002319$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002320else
2321# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2322$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2323endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002324$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002325 $(call pretty,"Target debug ramdisk: $@")
Bowgo Tsai0013f552019-03-20 17:59:52 +08002326 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2327 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002328 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002329 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002330
2331.PHONY: ramdisk_debug-nodeps
2332ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2333ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002334ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002335 echo "make $@: ignoring dependencies"
2336 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2337 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002338 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002339 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002340
2341my_debug_ramdisk_sync_dir :=
2342my_debug_ramdisk_root_dir :=
2343
2344endif # BUILDING_RAMDISK_IMAGE
2345
2346# -----------------------------------------------------------------
2347# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2348#
2349# Note: it's intentional to skip signing for boot-debug.img, because it
2350# can only be used if the device is unlocked with verification error.
Daniel Normanaf670812020-10-12 11:31:35 -07002351ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002352ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002353ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2354 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2355 $(PRODUCT_OUT)/$(k).img)
2356else
2357 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2358endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002359
2360# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2361ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2362INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2363else
2364INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2365endif
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
2391 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,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 Tsaif85e68f2021-03-04 14:41:16 +08002394 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
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
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002398$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_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
2407endif # TARGET_NO_KERNEL
Daniel Normanaf670812020-10-12 11:31:35 -07002408endif # INSTALLED_BOOTIMAGE_TARGET
Bowgo Tsai0013f552019-03-20 17:59:52 +08002409
Bowgo Tsai6a683672020-02-14 19:00:15 +08002410ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2411ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2412# -----------------------------------------------------------------
2413# vendor debug ramdisk
2414# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Petri Gynther6a6d6212021-03-06 00:45:53 -08002415INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002416$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2417$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002418
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002419ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002420$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002421endif
2422
Bowgo Tsai6a683672020-02-14 19:00:15 +08002423INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2424 $(ALL_GENERATED_SOURCES) \
2425 $(ALL_DEFAULT_INSTALLED_MODULES))
2426
2427# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2428# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2429# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2430# $(PRODUCT_OUT)/vendor_debug_ramdisk.
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002431$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/debug_ramdisk
2432$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2433$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2434$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002435 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2436 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2437 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002438 cp -f $(debug_file) $(patsubst $(DEBUG_RAMDISK_DIR)/%,$(VENDOR_DEBUG_RAMDISK_DIR)/%,$(debug_file)) &&) true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002439 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_RAMDISK_DIR) $(VENDOR_DEBUG_RAMDISK_DIR) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002440
Petri Gyntherd7946d12021-03-10 12:38:15 -08002441ifeq (true,$(BOARD_BUILD_VENDOR_RAMDISK_IMAGE))
2442INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2443$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
2444 $(call pretty,"Target vendor debug ramdisk: $@")
2445 $(copy-file-to-target)
2446endif
2447
Bowgo Tsai6a683672020-02-14 19:00:15 +08002448INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2449INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2450$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2451$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2452
2453# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2454# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002455$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002456$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08002457 @echo Installed file list: $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002458 mkdir -p $(dir $@)
2459 rm -f $@
2460 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2461 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2462
2463# -----------------------------------------------------------------
2464# vendor_boot-debug.img.
2465INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2466
2467# The util to sign vendor_boot-debug.img with a test key.
2468BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2469INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2470# $(1): the vendor bootimage to sign
2471define test-key-sign-vendor-bootimage
2472$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2473$(AVBTOOL) add_hash_footer \
2474 --image $(1) \
2475 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2476 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2477 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2478$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2479endef
2480
2481ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2482$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2483endif
2484
2485# 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 +08002486$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002487$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002488 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002489 $(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 +08002490 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2491 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2492
2493endif # BUILDING_RAMDISK_IMAGE
2494endif # BUILDING_VENDOR_BOOT_IMAGE
2495
Bowgo Tsai0013f552019-03-20 17:59:52 +08002496# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002497# The test harness ramdisk, which is based off debug_ramdisk, plus a
2498# few additional test-harness-specific properties in adb_debug.prop.
2499
2500ifdef BUILDING_RAMDISK_IMAGE
2501BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2502INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2503
2504# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2505# appends a few test harness specific properties into the adb_debug.prop.
2506TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2507TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2508
2509# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2510# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2511TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2512ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2513ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2514
2515# $(1): a list of key=value pairs for additional property assignments
2516# $(2): the target .prop file to append the properties from $(1)
2517define append-test-harness-props
2518 echo "#" >> $(2); \
2519 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2520 echo "#" >> $(2);
2521 $(foreach line,$(1), echo "$(line)" >> $(2);)
2522endef
2523
2524$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002525$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002526 $(call pretty,"Target test harness ramdisk: $@")
Rupert Shuttleworth3993af72021-04-06 20:35:16 +00002527 rsync --chmod=u+w -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002528 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002529 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002530
2531.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002532ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002533 echo "make $@: ignoring dependencies"
2534 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2535 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002536 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002537
2538endif # BUILDING_RAMDISK_IMAGE
2539
2540# -----------------------------------------------------------------
2541# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2542#
2543# Note: it's intentional to skip signing for boot-test-harness.img, because it
2544# can only be used if the device is unlocked with verification error.
Bowgo Tsai1ed0fd52021-04-06 16:09:19 +08002545ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002546ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2547
Steve Muckle4866bd62020-04-02 11:31:08 -07002548ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2549 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2550 $(PRODUCT_OUT)/$(k).img)
2551else
2552 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2553endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002554
2555# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2556INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2557
2558# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2559# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2560# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2561# public key, if the device is unlocked.
2562ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2563$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2564endif
2565
Steve Muckle4866bd62020-04-02 11:31:08 -07002566# $(1): output file
2567define build-boot-test-harness-target
2568 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002569 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
2570 $(INTERNAL_MKBOOTIMG_GKI_SINGING_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002571 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002572endef
2573
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002574# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002575$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
2576$(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002577 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002578 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002579
2580.PHONY: bootimage_test_harness-nodeps
Bowgo Tsai27c39b02021-03-12 21:40:32 +08002581bootimage_test_harness-nodeps: $(MKBOOTIMG) $(BOARD_GKI_SIGNING_KEY_PATH) $(AVBTOOL)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002582 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002583 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002584
2585endif # TARGET_NO_KERNEL
Bowgo Tsai1ed0fd52021-04-06 16:09:19 +08002586endif # INSTALLED_BOOTIMAGE_TARGET
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002587endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2588
Colin Crossbd382142020-08-26 15:08:57 -07002589# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2590# $1: from location (e.g $(TARGET_OUT)/vendor)
2591# $2: destination location (e.g. /vendor)
2592# $3: partition image name (e.g. vendor.img)
2593define create-partition-compat-symlink
2594$(eval \
2595$1:
2596 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2597 mkdir -p $(dir $1)
2598 if [ -d $1 ] && [ ! -h $1 ]; then \
2599 echo 'Non-symlink $1 detected!' 1>&2; \
2600 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2601 exit 1; \
2602 fi
2603 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002604$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002605)
2606$1
2607endef
2608
2609
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002610# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002611# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002612
Dan Willemsen37a19862018-10-31 16:31:46 -07002613INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002614 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002615 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002616
Colin Crossbd382142020-08-26 15:08:57 -07002617# Create symlink /system/vendor to /vendor if necessary.
2618ifdef BOARD_USES_VENDORIMAGE
2619 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2620endif
2621
2622# Create symlink /system/product to /product if necessary.
2623ifdef BOARD_USES_PRODUCTIMAGE
2624 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2625endif
2626
2627# Create symlink /system/system_ext to /system_ext if necessary.
2628ifdef BOARD_USES_SYSTEM_EXTIMAGE
2629 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2630endif
2631
Ying Wang82cceba2012-08-13 15:03:00 -07002632FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002633
2634# ASAN libraries in the system image - add dependency.
2635ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002636ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002637 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2638 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2639 endif
2640endif
2641
Tom Cherryd14b8952018-08-09 14:26:00 -07002642FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002643
Ying Wange5e8c5f2011-09-09 16:35:53 -07002644# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002645ifdef BUILDING_SYSTEM_IMAGE
2646
Kiyoung Kim36481e02020-11-16 10:50:05 +09002647# Install system linker configuration
2648# Collect all available stub libraries installed in system and install with predefined linker configuration
2649SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
2650$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(LINKER_CONFIG_PATH_system_linker_config) | conv_linker_config
2651 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(LINKER_CONFIG_PATH_system_linker_config)\
2652 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
2653
2654FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
2655
Ying Wange5e8c5f2011-09-09 16:35:53 -07002656# installed file list
2657# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2658# We put installed-files.txt ahead of image itself in the dependency graph
2659# so that we can get the size stat even if the build fails due to too large
2660# system image.
2661INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002662INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2663$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002664$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002665 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002666 mkdir -p $(dir $@)
2667 rm -f $@
2668 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
2669 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002670
2671.PHONY: installed-file-list
2672installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002673
2674$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002675
2676systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002677 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002678BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2679
The Android Open Source Project88b60792009-03-03 19:28:42 -08002680# $(1): output file
2681define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002682 @echo "Target system fs image: $(1)"
2683 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002684 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002685 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002686 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002687 $(BUILD_IMAGE) \
2688 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2689 || ( mkdir -p $${DIST_DIR}; \
2690 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2691 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002692endef
2693
Dan Willemsen6b72c732019-06-12 21:33:38 +00002694ifeq ($(BOARD_AVB_ENABLE),true)
2695$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2696endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002697$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002698 $(call build-systemimage-target,$@)
2699
Tao Baoe9d61b02018-08-20 21:09:07 -07002700INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002701SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002702
Tao Baoe9d61b02018-08-20 21:09:07 -07002703# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2704# compatibility, in case device-specific Makefiles still refer to the old name.
2705INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2706
Doug Zongker73ef8252009-07-23 15:12:53 -07002707# The system partition needs room for the recovery image as well. We
2708# now store the recovery image as a binary patch using the boot image
2709# as the source (since they are very similar). Generate the patch so
2710# we can see how big it's going to be, and include that in the system
2711# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002712ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002713ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002714ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002715ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002716diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2717else
2718diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2719endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002720intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2721RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002722$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2723$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002724 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002725 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002726 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002727 @echo "Construct recovery from boot"
2728 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002729 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002730else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2731RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002732endif # BOARD_USES_FULL_RECOVERY_IMAGE
2733endif # INSTALLED_RECOVERYIMAGE_TARGET
2734endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002735
Yifan Hong9a3cad92020-04-27 19:06:59 -07002736$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002737 @echo "Install system fs image: $@"
2738 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002739 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002740
Tao Baoe9d61b02018-08-20 21:09:07 -07002741systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002742
2743.PHONY: systemimage-nodeps snod
2744systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002745 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002746 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002747 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002748 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002749ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002750 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002751endif
2752
Dan Willemsen67495202019-01-16 12:42:05 -08002753endif # BUILDING_SYSTEM_IMAGE
2754
Anton Hansson30e061b2018-11-12 13:36:46 +00002755.PHONY: sync syncsys
2756sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002757
Ying Wang3a61eeb2016-03-11 10:32:01 -08002758# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002759# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002760.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002761platform:
2762 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002763
2764.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002765platform-java:
2766 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002767
Ying Wang3a61eeb2016-03-11 10:32:01 -08002768# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002769# data partition image
2770INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002771 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002772
Dan Willemsen67495202019-01-16 12:42:05 -08002773ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002774userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002775 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002776BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2777
Ying Wangbd93d422011-10-28 17:02:30 -07002778define build-userdataimage-target
2779 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2780 @mkdir -p $(TARGET_OUT_DATA)
2781 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002782 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002783 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002784 $(BUILD_IMAGE) \
2785 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2786 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2787 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002788endef
2789
Joe Onorato64d85d02009-04-09 19:31:12 -07002790# We just build this directly to the install location.
2791INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002792INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2793 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002794 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002795$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002796 $(build-userdataimage-target)
2797
2798.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002799userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002800 $(build-userdataimage-target)
2801
Dan Willemsen67495202019-01-16 12:42:05 -08002802endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002803
Andreas Gampe039b5c72017-03-24 16:06:31 -07002804# ASAN libraries in the system image - build rule.
2805ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2806 $(TARGET_OUT_SHARED_LIBRARIES) \
2807 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2808 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2809 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002810# Extra options: Enforce the system user for the files to avoid having to change ownership.
2811ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002812# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2813# enough space.
2814$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002815 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 -07002816
The Android Open Source Project88b60792009-03-03 19:28:42 -08002817# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002818# partition table image
2819ifdef BOARD_BPT_INPUT_FILES
2820
2821BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002822BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002823
2824INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2825 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002826 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002827 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2828
2829ifdef BOARD_BPT_DISK_SIZE
2830INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2831endif
2832
2833define build-bptimage-target
2834 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2835 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2836endef
2837
2838INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002839$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2840 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2841
David Zeuthen25328622016-04-08 15:08:03 -04002842$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2843 $(build-bptimage-target)
2844
2845.PHONY: bptimage-nodeps
2846bptimage-nodeps:
2847 $(build-bptimage-target)
2848
2849endif # BOARD_BPT_INPUT_FILES
2850
2851# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002852# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002853ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002854INTERNAL_CACHEIMAGE_FILES := \
2855 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2856
2857cacheimage_intermediates := \
2858 $(call intermediates-dir-for,PACKAGING,cache)
2859BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2860
2861define build-cacheimage-target
2862 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2863 @mkdir -p $(TARGET_OUT_CACHE)
2864 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002865 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002866 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002867 $(BUILD_IMAGE) \
2868 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2869 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2870 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002871endef
2872
2873# We just build this directly to the install location.
2874INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002875$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002876 $(build-cacheimage-target)
2877
2878.PHONY: cacheimage-nodeps
2879cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2880 $(build-cacheimage-target)
2881
Dan Willemsen67495202019-01-16 12:42:05 -08002882else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002883# we need to ignore the broken cache link when doing the rsync
2884IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002885endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002886
David Zeuthen0eb10972016-09-28 17:55:27 -04002887# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002888# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002889ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002890ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002891# Marker file to identify that odex files are installed
2892INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2893ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2894$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2895 $(hide) touch $@
2896endif
2897
Alex Light4e358ab2016-06-16 14:47:10 -07002898INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2899 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002900 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002901
Colin Cross6db5b0e2018-11-16 21:26:33 -08002902# system_other dex files are installed as a side-effect of installing system image files
2903INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2904
Alex Light4e358ab2016-06-16 14:47:10 -07002905INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002906INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2907$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002908$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002909 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002910 mkdir -p $(dir $@)
2911 rm -f $@
2912 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
2913 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002914
Bowgo Tsai867ab662019-01-29 13:30:18 +08002915# Determines partition size for system_other.img.
2916ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2917ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2918INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2919endif
2920endif
2921
2922ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2923INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2924endif
2925
Alex Light4e358ab2016-06-16 14:47:10 -07002926systemotherimage_intermediates := \
2927 $(call intermediates-dir-for,PACKAGING,system_other)
2928BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2929
2930# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2931define build-systemotherimage-target
2932 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2933 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2934 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002935 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002936 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002937 $(BUILD_IMAGE) \
2938 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2939 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2940 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002941endef
2942
2943# We just build this directly to the install location.
2944INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002945ifneq (true,$(SANITIZE_LITE))
2946# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002947$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2948 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002949endif
Alex Light4e358ab2016-06-16 14:47:10 -07002950
2951.PHONY: systemotherimage-nodeps
2952systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2953 $(build-systemotherimage-target)
2954
Dan Willemsen67495202019-01-16 12:42:05 -08002955endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002956
2957
2958# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002959# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002960ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002961INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002962 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002963 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002964
Ying Wang8da19e32015-09-15 14:22:12 -07002965
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002966# Create symlink /vendor/odm to /odm if necessary.
2967ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002968 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002969endif
2970
Yifan Honge51dff22020-06-23 17:26:57 -07002971# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2972# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2973#
2974# On devices with a vendor_dlkm partition,
2975# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2976# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2977# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2978# are hidden.
2979# On devices without a vendor_dlkm partition,
2980# - /vendor/lib/modules stores vendor DLKMs directly.
2981# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2982# See system/core/rootdir/Android.mk for a list of created symlinks.
2983# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2984# are not guaranteed to exist on all devices.
2985ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002986 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 -07002987endif
2988
Colin Crossbd382142020-08-26 15:08:57 -07002989INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2990INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2991$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2992$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2993 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002994 mkdir -p $(dir $@)
2995 rm -f $@
2996 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2997 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002998
Ying Wanga0febe52013-03-20 11:02:05 -07002999vendorimage_intermediates := \
3000 $(call intermediates-dir-for,PACKAGING,vendor)
3001BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07003002define build-vendorimage-target
3003 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
3004 @mkdir -p $(TARGET_OUT_VENDOR)
3005 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003006 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003007 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003008 $(BUILD_IMAGE) \
3009 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
3010 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07003011 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07003012endef
3013
3014# We just build this directly to the install location.
3015INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003016$(INSTALLED_VENDORIMAGE_TARGET): \
3017 $(INTERNAL_USERIMAGES_DEPS) \
3018 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07003019 $(INSTALLED_FILES_FILE_VENDOR) \
3020 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07003021 $(build-vendorimage-target)
3022
Steven Morelanda2e734d2017-03-07 12:10:09 -08003023.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07003024vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07003025 $(build-vendorimage-target)
3026
Colin Cross91a52272017-06-20 16:57:52 -07003027sync: $(INTERNAL_VENDORIMAGE_FILES)
3028
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07003029else ifdef BOARD_PREBUILT_VENDORIMAGE
3030INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
3031$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
3032endif
Ying Wanga0febe52013-03-20 11:02:05 -07003033
Ying Wang9f8e8db2011-11-04 11:37:01 -07003034# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003035# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003036ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003037INTERNAL_PRODUCTIMAGE_FILES := \
3038 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003039 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003040
3041INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07003042INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
3043$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003044$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003045 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003046 mkdir -p $(dir $@)
3047 rm -f $@
3048 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3049 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003050
3051productimage_intermediates := \
3052 $(call intermediates-dir-for,PACKAGING,product)
3053BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3054define build-productimage-target
3055 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3056 @mkdir -p $(TARGET_OUT_PRODUCT)
3057 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003058 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003059 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003060 $(BUILD_IMAGE) \
3061 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3062 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3063 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003064endef
3065
3066# We just build this directly to the install location.
3067INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003068$(INSTALLED_PRODUCTIMAGE_TARGET): \
3069 $(INTERNAL_USERIMAGES_DEPS) \
3070 $(INTERNAL_PRODUCTIMAGE_FILES) \
3071 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003072 $(build-productimage-target)
3073
3074.PHONY: productimage-nodeps pnod
3075productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3076 $(build-productimage-target)
3077
3078sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3079
3080else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3081INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3082$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3083endif
3084
3085# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003086# system_ext partition image
3087ifdef BUILDING_SYSTEM_EXT_IMAGE
3088INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3089 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003090 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003091
Justin Yun6151e3f2019-06-25 15:58:13 +09003092INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3093INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3094$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3095$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003096 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003097 mkdir -p $(dir $@)
3098 rm -f $@
3099 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3100 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003101
Justin Yun6151e3f2019-06-25 15:58:13 +09003102system_extimage_intermediates := \
3103 $(call intermediates-dir-for,PACKAGING,system_ext)
3104BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3105define build-system_extimage-target
3106 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3107 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3108 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3109 $(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 -07003110 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003111 $(BUILD_IMAGE) \
3112 $(TARGET_OUT_SYSTEM_EXT) \
3113 $(system_extimage_intermediates)/system_ext_image_info.txt \
3114 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3115 $(TARGET_OUT)
3116 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003117endef
3118
3119# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003120INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003121$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3122 $(INTERNAL_USERIMAGES_DEPS) \
3123 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3124 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003125 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003126
Justin Yun6151e3f2019-06-25 15:58:13 +09003127.PHONY: systemextimage-nodeps senod
3128systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3129 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003130
Justin Yun6151e3f2019-06-25 15:58:13 +09003131sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003132
Justin Yun6151e3f2019-06-25 15:58:13 +09003133else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3134INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3135$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003136endif
3137
3138# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003139# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003140ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003141INTERNAL_ODMIMAGE_FILES := \
3142 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003143 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003144
Colin Crossbd382142020-08-26 15:08:57 -07003145# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3146# /odm/lib/modules -> /odm_dlkm/lib/modules
3147#
3148# On devices with a odm_dlkm partition,
3149# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3150# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3151# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3152# are hidden.
3153# On devices without a odm_dlkm partition,
3154# - /odm/lib/modules stores odm DLKMs directly.
3155# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3156# See system/core/rootdir/Android.mk for a list of created symlinks.
3157# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3158# are not guaranteed to exist on all devices.
3159ifdef BOARD_USES_ODM_DLKMIMAGE
3160 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3161endif
3162
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003163INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3164INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3165$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003166$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003167 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003168 mkdir -p $(dir $@)
3169 rm -f $@
3170 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3171 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003172
3173odmimage_intermediates := \
3174 $(call intermediates-dir-for,PACKAGING,odm)
3175BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3176define build-odmimage-target
3177 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3178 @mkdir -p $(TARGET_OUT_ODM)
3179 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
3180 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003181 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003182 $(BUILD_IMAGE) \
3183 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3184 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3185 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003186endef
3187
3188# We just build this directly to the install location.
3189INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003190$(INSTALLED_ODMIMAGE_TARGET): \
3191 $(INTERNAL_USERIMAGES_DEPS) \
3192 $(INTERNAL_ODMIMAGE_FILES) \
3193 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003194 $(build-odmimage-target)
3195
3196.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003197odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003198 $(build-odmimage-target)
3199
3200sync: $(INTERNAL_ODMIMAGE_FILES)
3201
3202else ifdef BOARD_PREBUILT_ODMIMAGE
3203INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3204$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3205endif
3206
3207# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003208# vendor_dlkm partition image
3209ifdef BUILDING_VENDOR_DLKM_IMAGE
3210INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3211 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003212 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003213
3214INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3215INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3216$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3217$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3218 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003219 mkdir -p $(dir $@)
3220 rm -f $@
3221 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3222 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003223
3224vendor_dlkmimage_intermediates := \
3225 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3226BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3227define build-vendor_dlkmimage-target
3228 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3229 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3230 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
3231 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
3232 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3233 $(BUILD_IMAGE) \
3234 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3235 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3236 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3237endef
3238
3239# We just build this directly to the install location.
3240INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3241$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3242 $(INTERNAL_USERIMAGES_DEPS) \
3243 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3244 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3245 $(build-vendor_dlkmimage-target)
3246
3247.PHONY: vendor_dlkmimage-nodeps vdnod
3248vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3249 $(build-vendor_dlkmimage-target)
3250
3251sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3252
3253else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3254INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3255$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3256endif
3257
3258# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003259# odm_dlkm partition image
3260ifdef BUILDING_ODM_DLKM_IMAGE
3261INTERNAL_ODM_DLKMIMAGE_FILES := \
3262 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003263 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003264
3265INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3266INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3267$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3268$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3269 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003270 mkdir -p $(dir $@)
3271 rm -f $@
3272 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3273 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003274
3275odm_dlkmimage_intermediates := \
3276 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3277BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3278define build-odm_dlkmimage-target
3279 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3280 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3281 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3282 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3283 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3284 $(BUILD_IMAGE) \
3285 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3286 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3287 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3288endef
3289
3290# We just build this directly to the install location.
3291INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3292$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3293 $(INTERNAL_USERIMAGES_DEPS) \
3294 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3295 $(INSTALLED_FILES_FILE_ODM_DLKM)
3296 $(build-odm_dlkmimage-target)
3297
3298.PHONY: odm_dlkmimage-nodeps odnod
3299odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3300 $(build-odm_dlkmimage-target)
3301
3302sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3303
3304else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3305INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3306$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3307endif
3308
3309
3310# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003311# dtbo image
3312ifdef BOARD_PREBUILT_DTBOIMAGE
3313INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3314
3315ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003316$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003317 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3318 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003319 --image $@ \
3320 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3321 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3322 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003323else
3324$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3325 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3326endif
3327
Tao Bao0da43472018-08-22 22:53:41 -07003328endif # BOARD_PREBUILT_DTBOIMAGE
3329
Andrew Scull9b103e42020-11-29 14:04:28 +00003330# -----------------------------------------------------------------
3331# Protected VM firmware image
3332ifdef BOARD_PREBUILT_PVMFWIMAGE
3333INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
3334
3335ifeq ($(BOARD_AVB_ENABLE),true)
3336$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH)
3337 cp $(BOARD_PREBUILT_PVMFWIMAGE) $@
3338 $(AVBTOOL) add_hash_footer \
3339 --image $@ \
3340 --partition_size $(BOARD_PVMFWIMG_PARTITION_SIZE) \
3341 --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \
3342 $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)
3343else
3344$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE)
3345 cp $(BOARD_PREBUILT_PVMFWIMAGE) $@
3346endif
3347
3348endif # BOARD_PREBUILT_PVMFWIMAGE
3349
Tao Bao0da43472018-08-22 22:53:41 -07003350# Returns a list of image targets corresponding to the given list of partitions. For example, it
3351# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3352# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003353# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003354define images-for-partitions
3355$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3356endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003357
3358# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003359# custom images
3360INSTALLED_CUSTOMIMAGES_TARGET :=
3361
3362ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3363INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3364
3365# Sign custom image.
3366# $(1): the prebuilt custom image.
3367# $(2): the mount point of the prebuilt custom image.
3368# $(3): the signed custom image target.
3369define sign_custom_image
3370$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3371 @echo Target custom image: $(3)
3372 mkdir -p $(dir $(3))
3373 cp $(1) $(3)
3374ifeq ($(BOARD_AVB_ENABLE),true)
3375 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3376 $(AVBTOOL) add_hashtree_footer \
3377 --image $(3) \
3378 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3379 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3380 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3381 --partition_name $(2) \
3382 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3383 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3384endif
3385INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3386endef
3387
3388$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3389 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3390 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3391endif
3392
3393# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003394# vbmeta image
3395ifeq ($(BOARD_AVB_ENABLE),true)
3396
3397BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003398AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003399
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003400ifdef BOARD_AVB_KEY_PATH
3401$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3402else
3403# If key path isn't specified, use the 4096-bit test key.
3404BOARD_AVB_ALGORITHM := SHA256_RSA4096
3405BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3406endif
3407
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003408# AVB signing for system_other.img.
3409ifdef BUILDING_SYSTEM_OTHER_IMAGE
3410ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3411$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3412else
3413# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3414BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3415BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3416endif
3417
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003418$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3419 @echo Extracting system_other avb key: $@
3420 @rm -f $@
3421 @mkdir -p $(dir $@)
3422 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003423
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003424ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3425BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3426endif
3427
3428BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3429endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3430
Tao Bao744c4c72018-08-20 21:09:07 -07003431INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003432 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003433 $(BOARD_AVB_VBMETA_VENDOR)
3434
3435# Not allowing the same partition to appear in multiple groups.
3436ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003437 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003438endif
3439
cfig1aeef722019-09-20 22:45:06 +08003440# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3441# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3442# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003443ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003444ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3445$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003446 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003447 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3448endif
3449endif
3450
Bowgo Tsai9b548012019-05-14 16:57:03 +08003451# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003452
3453BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003454 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003455 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003456 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3457
3458BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003459 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003460 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003461 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3462
Justin Yun6151e3f2019-06-25 15:58:13 +09003463BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003464 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003465 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003466 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003467
Bowgo Tsai9b548012019-05-14 16:57:03 +08003468BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003469 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003470 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003471
Tao Bao19b02fe2019-10-09 00:04:28 -07003472BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3473 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3474
3475BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3476 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3477
Bowgo Tsai9b548012019-05-14 16:57:03 +08003478BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003479 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003480 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003481
3482BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003483 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003484 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003485
Yifan Hongcfb917a2020-05-07 14:58:20 -07003486BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3487 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3488 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3489
Yifan Hongf496f1b2020-07-15 16:52:59 -07003490BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3491 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3492 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3493
Tao Bao19b02fe2019-10-09 00:04:28 -07003494BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3495 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3496
Andrew Scull9b103e42020-11-29 14:04:28 +00003497BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3498 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3499
Bowgo Tsai9b548012019-05-14 16:57:03 +08003500# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003501ifdef BOOT_SECURITY_PATCH
3502BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3503 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3504endif
3505
3506ifdef VENDOR_SECURITY_PATCH
3507BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3508 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3509endif
3510
3511ifdef ODM_SECURITY_PATCH
3512BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3513 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3514endif
3515
Yifan Hongcfb917a2020-05-07 14:58:20 -07003516ifdef VENDOR_DLKM_SECURITY_PATCH
3517BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3518 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3519endif
3520
Yifan Hongf496f1b2020-07-15 16:52:59 -07003521ifdef ODM_DLKM_SECURITY_PATCH
3522BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3523 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3524endif
3525
Andrew Scull9b103e42020-11-29 14:04:28 +00003526ifdef PVMFW_SECURITY_PATCH
3527BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3528 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
3529endif
3530
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003531BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003532VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003533DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00003534PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003535SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3536VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003537RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003538PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003539SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003540ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003541VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003542ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003543
Tao Bao0da43472018-08-22 22:53:41 -07003544# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003545# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003546define _check-and-set-avb-chain-args
3547$(eval part := $(1))
3548$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003549
3550$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3551$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3552$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3553$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3554$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3555$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3556$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3557$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3558
3559# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3560$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3561$(eval $(_signing_args) := \
3562 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3563
cfig1aeef722019-09-20 22:45:06 +08003564# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3565# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003566$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003567 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3568 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003569
Tao Bao744c4c72018-08-20 21:09:07 -07003570# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003571# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003572$(if $(filter $(part),$(part:vbmeta_%=%)),\
3573 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3574 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003575endef
3576
Tao Bao0da43472018-08-22 22:53:41 -07003577# Checks and sets the required build variables for an AVB partition. The partition will be
3578# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003579# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3580# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003581# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3582# but vbmeta would capture the image descriptor of only the first boot
3583# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003584# $(1): Partition name, e.g. boot or system.
3585define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003586$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003587$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003588 $(if $(_in_chained_vbmeta),\
3589 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003590 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003591 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003592 $(if $(filter boot,$(1)),\
3593 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3594 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3595 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3596 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003597endef
3598
Hongguang Chenf23364d2020-04-27 18:36:36 -07003599# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3600# $(1): the custom partition to enable AVB chain.
3601define check-and-set-custom-avb-chain-args
3602$(eval part := $(1))
3603$(eval PART=$(call to-upper,$(part)))
3604$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3605$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3606
3607INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3608 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3609endef
3610
Tao Baob1a2e352018-08-14 16:17:12 -07003611ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003612$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003613endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003614
Steve Mucklee1b10862019-07-10 10:49:37 -07003615ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3616$(eval $(call check-and-set-avb-args,vendor_boot))
3617endif
3618
Tao Bao0da43472018-08-22 22:53:41 -07003619$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003620
3621ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003622$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003623endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003624
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003625ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003626$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003627endif
3628
Justin Yun6151e3f2019-06-25 15:58:13 +09003629ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3630$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003631endif
3632
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003633ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003634$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003635endif
3636
Yifan Hongcfb917a2020-05-07 14:58:20 -07003637ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3638$(eval $(call check-and-set-avb-args,vendor_dlkm))
3639endif
3640
Yifan Hongf496f1b2020-07-15 16:52:59 -07003641ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3642$(eval $(call check-and-set-avb-args,odm_dlkm))
3643endif
3644
Yueyao Zhu211c9012017-04-27 00:34:50 -07003645ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003646$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003647endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003648
Andrew Scull9b103e42020-11-29 14:04:28 +00003649ifdef INSTALLED_PVMFWIMAGE_TARGET
3650$(eval $(call check-and-set-avb-args,pvmfw))
3651endif
3652
David Zeuthen8fecb282017-12-01 16:24:01 -05003653ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003654$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003655endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003656
David Anderson7709ab22018-10-15 14:41:34 -07003657# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3658ifdef BOARD_AVB_VBMETA_SYSTEM
3659$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003660endif
3661
3662ifdef BOARD_AVB_VBMETA_VENDOR
3663$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3664endif
3665
Hongguang Chenf23364d2020-04-27 18:36:36 -07003666ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3667$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3668 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3669endif
3670
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003671# Add kernel cmdline descriptor for kernel to mount system.img as root with
3672# dm-verity. This works when system.img is either chained or not-chained:
3673# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3674# cmdline descriptor to system.img
3675# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3676# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003677ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003678ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003679BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003680endif
David Anderson8916a2a2018-09-18 15:46:59 -07003681endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003682
Tao Bao0da43472018-08-22 22:53:41 -07003683BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003684BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003685BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3686
3687ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003688# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003689BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003690endif
Tao Bao0da43472018-08-22 22:53:41 -07003691
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003692ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003693BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003694endif
3695
David Anderson7709ab22018-10-15 14:41:34 -07003696ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3697BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3698 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003699endif
3700
3701ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3702BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3703 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003704endif
3705
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003706# $(1): the directory to extract public keys to
3707define extract-avb-chain-public-keys
3708 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3709 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3710 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003711 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3712 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3713 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003714 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3715 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3716 --output $(1)/system.avbpubkey)
3717 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3718 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3719 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003720 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3721 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3722 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003723 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3724 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3725 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003726 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3727 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3728 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003729 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3730 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3731 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003732 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3733 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3734 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003735 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3736 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3737 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00003738 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
3739 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
3740 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003741 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3742 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3743 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003744 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3745 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3746 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003747 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3748 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3749 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003750 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3751 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3752 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3753 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003754endef
3755
Tao Bao744c4c72018-08-20 21:09:07 -07003756# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3757# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003758# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003759# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3760# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003761# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003762# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003763# $(2): Output filename.
3764define build-chained-vbmeta-image
3765 $(call pretty,"Target chained vbmeta image: $@")
3766 $(hide) $(AVBTOOL) make_vbmeta_image \
3767 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3768 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3769 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3770 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3771 --output $@
3772endef
3773
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003774ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003775ifdef BOARD_AVB_VBMETA_SYSTEM
3776INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3777$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003778 $(AVBTOOL) \
3779 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3780 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003781 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003782endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003783endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003784
3785ifdef BOARD_AVB_VBMETA_VENDOR
3786INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3787$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003788 $(AVBTOOL) \
3789 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3790 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003791 $(call build-chained-vbmeta-image,vbmeta_vendor)
3792endif
3793
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003794define build-vbmetaimage-target
3795 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003796 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3797 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003798 $(hide) $(AVBTOOL) make_vbmeta_image \
3799 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003800 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003801 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3802 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003803 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003804endef
3805
Paul Trautrim4e143232019-08-13 16:30:57 +09003806ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003807INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003808$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3809 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3810
David Zeuthen8fecb282017-12-01 16:24:01 -05003811$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003812 $(AVBTOOL) \
3813 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003814 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003815 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3816 $(INSTALLED_VENDORIMAGE_TARGET) \
3817 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003818 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003819 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003820 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003821 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003822 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00003823 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003824 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003825 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3826 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3827 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3828 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3829 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3830 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003831 $(build-vbmetaimage-target)
3832
3833.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003834vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3835 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003836vbmetaimage-nodeps:
3837 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003838endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003839
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003840endif # BOARD_AVB_ENABLE
3841
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003842# List of files from all images
3843INTERNAL_ALLIMAGES_FILES := \
3844 $(FULL_SYSTEMIMAGE_DEPS) \
3845 $(INTERNAL_RAMDISK_FILES) \
3846 $(INTERNAL_USERDATAIMAGE_FILES) \
3847 $(INTERNAL_VENDORIMAGE_FILES) \
3848 $(INTERNAL_PRODUCTIMAGE_FILES) \
3849 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3850 $(INTERNAL_ODMIMAGE_FILES) \
3851 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3852 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3853
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003854# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003855# Check VINTF of build
3856
Yifan Hongc08cbf02020-09-15 19:07:39 +00003857# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003858ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003859
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003860intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3861check_vintf_all_deps :=
3862
Yifan Hongaf9b0702020-01-21 12:46:57 -08003863# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3864# because they are only used for prebuilt images.
3865check_vintf_common_srcs_patterns := \
3866 $(TARGET_OUT)/etc/vintf/% \
3867 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3868 $(TARGET_OUT_ODM)/etc/vintf/% \
3869 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3870 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3871
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003872check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08003873check_vintf_common_srcs_patterns :=
3874
3875check_vintf_has_system :=
3876check_vintf_has_vendor :=
3877
Yifan Hong28ffd732020-03-13 13:11:10 -07003878ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3879$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3880endif
3881ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3882$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3883endif
3884
Yifan Hong605ea042020-01-14 21:36:00 +00003885# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003886check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3887ifneq ($(check_vintf_system_deps),)
3888check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00003889
Yifan Hongfd150d32021-03-09 12:19:11 -08003890check_vintf_system_log := $(intermediates)/check_vintf_system.log
Yifan Hong605ea042020-01-14 21:36:00 +00003891check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003892$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003893 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3894check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00003895
Yifan Hongfd150d32021-03-09 12:19:11 -08003896vintffm_log := $(intermediates)/vintffm.log
Yifan Hong7a157b02020-10-20 17:08:11 +00003897check_vintf_all_deps += $(vintffm_log)
3898$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
3899 @( $< --check --dirmap /system:$(TARGET_OUT) \
3900 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3901
Yifan Hongaf9b0702020-01-21 12:46:57 -08003902endif # check_vintf_system_deps
3903check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003904
3905# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003906check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3907ifneq ($(check_vintf_vendor_deps),)
3908check_vintf_has_vendor := true
Yifan Hongfd150d32021-03-09 12:19:11 -08003909check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
Yifan Hong605ea042020-01-14 21:36:00 +00003910check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003911# Check vendor SKU=(empty) case when:
3912# - DEVICE_MANIFEST_FILE is not empty; OR
3913# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003914$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003915 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3916 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003917 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003918$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003919 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3920 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3921 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3922 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003923check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003924endif # check_vintf_vendor_deps
3925check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003926
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003927# -- Kernel version and configurations.
3928ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3929
Yifan Hong605ea042020-01-14 21:36:00 +00003930BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3931BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3932
3933my_board_extracted_kernel :=
3934
3935# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3936# from INSTALLED_KERNEL_TARGET.
3937ifdef BOARD_KERNEL_CONFIG_FILE
3938ifdef BOARD_KERNEL_VERSION
3939$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3940 cp $< $@
3941$(BUILT_KERNEL_VERSION_FILE):
3942 echo $(BOARD_KERNEL_VERSION) > $@
3943
3944my_board_extracted_kernel := true
3945endif # BOARD_KERNEL_VERSION
3946endif # BOARD_KERNEL_CONFIG_FILE
3947
3948ifneq ($(my_board_extracted_kernel),true)
3949ifndef INSTALLED_KERNEL_TARGET
3950$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3951 is true. Information about the updated kernel cannot be built into OTA update package. \
3952 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3953 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3954 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3955 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3956 manually.)
Yifan Hong3e061bd2021-04-02 16:12:05 -07003957# Clear their values to indicate that these two files does not exist.
3958BUILT_KERNEL_CONFIGS_FILE :=
3959BUILT_KERNEL_VERSION_FILE :=
Yifan Hong605ea042020-01-14 21:36:00 +00003960else
3961
3962# Tools for decompression that is not in PATH.
3963# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3964# Algorithms that are in the script but not in this list will be found in PATH.
3965my_decompress_tools := \
3966 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3967
3968$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3969$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3970$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003971$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3972 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003973 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08003974 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00003975
3976my_decompress_tools :=
3977
3978endif # my_board_extracted_kernel
3979my_board_extracted_kernel :=
3980
3981endif # INSTALLED_KERNEL_TARGET
3982
Yifan Hongc0f904e2021-03-17 11:25:31 -07003983endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3984
3985# -- Check VINTF compatibility of build.
3986# Skip partial builds; only check full builds. Only check if:
3987# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
3988# - system / vendor VINTF metadata exists
3989# - Building product / system_ext / odm images if board has product / system_ext / odm images
3990ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
3991ifeq ($(check_vintf_has_system),true)
3992ifeq ($(check_vintf_has_vendor),true)
3993ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3994ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3995ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3996
3997check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
3998check_vintf_all_deps += $(check_vintf_compatible_log)
3999
4000check_vintf_compatible_args :=
4001check_vintf_compatible_deps := $(check_vintf_common_srcs)
4002
4003ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004004ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
Yifan Hong72e78f22020-11-13 18:30:06 -08004005check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004006check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong3e061bd2021-04-02 16:12:05 -07004007endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004008endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
4009
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004010check_vintf_compatible_args += \
4011 --dirmap /system:$(TARGET_OUT) \
4012 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
4013 --dirmap /odm:$(TARGET_OUT_ODM) \
4014 --dirmap /product:$(TARGET_OUT_PRODUCT) \
4015 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
4016
4017ifdef PRODUCT_SHIPPING_API_LEVEL
4018check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
4019endif # PRODUCT_SHIPPING_API_LEVEL
4020
4021$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
4022$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07004023# Check ODM SKU=(empty) case when:
4024# - ODM_MANIFEST_FILES is not empty; OR
4025# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004026$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004027 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
4028 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004029 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07004030# Check vendor SKU=(empty) case when:
4031# - DEVICE_MANIFEST_FILE is not empty; OR
4032# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07004033$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07004034 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
4035 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004036 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004037$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
Yifan Hong80ab2142021-03-10 18:10:05 -08004038 @echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
4039 @echo -n -e 'Deps: \n ' >> $@
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004040 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
4041 @echo -n -e 'Args: \n ' >> $@
4042 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07004043 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
4044 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004045 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07004046 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
4047 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
4048 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004049
4050check_vintf_compatible_log :=
4051check_vintf_compatible_args :=
4052check_vintf_compatible_deps :=
4053
4054endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4055endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4056endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004057endif # check_vintf_has_vendor
4058endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004059endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4060
4061# Add all logs of VINTF checks to dist builds
4062droid_targets: $(check_vintf_all_deps)
4063$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4064
4065# Helper alias to check all VINTF of current build.
4066.PHONY: check-vintf-all
4067check-vintf-all: $(check_vintf_all_deps)
4068 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4069
Yifan Hongaf9b0702020-01-21 12:46:57 -08004070check_vintf_has_vendor :=
4071check_vintf_has_system :=
4072check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004073check_vintf_all_deps :=
4074intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004075endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004076
4077# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004078# Check image sizes <= size of super partition
4079
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004080ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004081
4082ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004083
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004084# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004085# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004086define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004087 mkdir -p $(dir $(1))
4088 rm -f $(1)
4089 $(call dump-super-image-info, $(1))
4090 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4091 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004092 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004093endef
4094
Yifan Hongd11953c2021-03-11 14:47:48 -08004095check_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 -07004096droid_targets: $(check_all_partition_sizes_log)
4097$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004098
Yifan Hong30910932019-10-25 20:36:55 -07004099$(check_all_partition_sizes_log): \
4100 $(CHECK_PARTITION_SIZES) \
4101 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
4102 $(call check-all-partition-sizes-target, \
4103 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4104 $@)
4105
4106.PHONY: check-all-partition-sizes
4107check-all-partition-sizes: $(check_all_partition_sizes_log)
4108
4109.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004110check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004111 $(call check-all-partition-sizes-target, \
4112 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004113
Yifan Hong2dae5722018-07-31 12:47:27 -07004114endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004115
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004116endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004117
4118# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004119# bring in the installer image generation defines if necessary
4120ifeq ($(TARGET_USE_DISKINSTALLER),true)
4121include bootable/diskinstaller/config.mk
4122endif
4123
4124# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004125# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004126
Ying Wangbd2d0242015-09-22 11:17:52 -07004127ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004128 build_ota_package := false
4129 build_otatools_package := false
4130else
Tao Bao9be20c72019-04-08 21:11:59 -07004131 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004132 build_ota_package := true
4133 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4134 build_ota_package := false
4135 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004136 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004137 build_ota_package := false
4138 endif
4139 ifeq ($(TARGET_PRODUCT),sdk)
4140 build_ota_package := false
4141 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004142 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4143 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4144 build_ota_package := false
4145 endif
4146 ifeq ($(TARGET_NO_KERNEL),true)
4147 build_ota_package := false
4148 endif
4149 ifeq ($(recovery_fstab),)
4150 build_ota_package := false
4151 endif
4152 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004153
Tao Bao9be20c72019-04-08 21:11:59 -07004154 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004155 build_otatools_package := true
4156 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4157 build_otatools_package := false
4158 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004159endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004160
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004161ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004162
4163INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004164 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004165 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07004166 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004167 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004168 append2simg \
4169 avbtool \
4170 blk_alloc_to_base_fs \
4171 boot_signer \
4172 brillo_update_payload \
4173 brotli \
4174 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004175 build_image \
4176 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004177 build_verity_metadata \
4178 build_verity_tree \
4179 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004180 check_ota_package_signature \
4181 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004182 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004183 checkvintf \
4184 delta_generator \
4185 e2fsck \
4186 e2fsdroid \
4187 fc_sort \
4188 fec \
4189 fs_config \
4190 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08004191 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07004192 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004193 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004194 imgdiff \
4195 libconscrypt_openjdk_jni \
4196 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004197 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07004198 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07004199 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07004200 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07004201 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004202 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004203 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004204 mkbootfs \
4205 mkbootimg \
4206 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004207 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08004208 mkfs.erofs \
4209 mkerofsimage.sh \
Tao Bao96daeeb2019-05-01 21:17:13 -07004210 mkf2fsuserimg.sh \
4211 mksquashfs \
4212 mksquashfsimage.sh \
4213 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07004214 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08004215 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08004216 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07004217 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004218 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004219 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004220 sign_apex \
4221 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07004222 signapk \
4223 simg2img \
4224 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07004225 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07004226 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08004227 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07004228 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07004229 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004230 verity_signer \
4231 verity_verifier \
4232 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08004233
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004234# Additional tools to unpack and repack the apex file.
4235INTERNAL_OTATOOLS_MODULES += \
4236 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00004237 apex_compression_tool \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004238 deapexer \
4239 debugfs_static \
4240 merge_zips \
4241 resize2fs \
4242 soong_zip \
4243
Anton Hansson8dab0a62019-03-28 15:45:40 +00004244ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004245INTERNAL_OTATOOLS_MODULES += \
4246 futility \
4247 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004248endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004249
Tao Bao96daeeb2019-05-01 21:17:13 -07004250INTERNAL_OTATOOLS_FILES := \
4251 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004252
Ying Wang06898662010-06-17 17:52:18 -07004253.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07004254otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07004255
Tao Bao96daeeb2019-05-01 21:17:13 -07004256# For each module, recursively resolve its host shared library dependencies. Then we have a full
4257# list of modules whose installed files need to be packed.
4258INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
4259 $(sort $(INTERNAL_OTATOOLS_MODULES) \
4260 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004261
Tao Bao96daeeb2019-05-01 21:17:13 -07004262INTERNAL_OTATOOLS_PACKAGE_FILES := \
4263 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
4264
4265INTERNAL_OTATOOLS_PACKAGE_FILES += \
4266 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
4267 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07004268
4269ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07004270INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07004271 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004272 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004273endif
4274ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004275INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004276 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4277 -name "atx_metadata.bin"))
4278endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004279ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004280INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004281 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004282endif
4283
Tao Bao96daeeb2019-05-01 21:17:13 -07004284INTERNAL_OTATOOLS_RELEASETOOLS := \
4285 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4286 \( -type f -o -type l \) -print))
4287
4288BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4289$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4290$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4291$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4292$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004293$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004294 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004295 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4296 mkdir -p $(dir $@)
4297 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4298 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004299 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004300 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004301
4302.PHONY: otatools-package
4303otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4304
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004305endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004306
The Android Open Source Project88b60792009-03-03 19:28:42 -08004307# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004308# misc_info.txt
4309
4310INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4311
4312ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4313# default to common dir for device vendor
4314tool_extensions := $(TARGET_DEVICE_DIR)/../common
4315else
4316tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4317endif
4318.KATI_READONLY := tool_extensions
4319
Steve Muckle903a1ca2020-05-07 17:32:10 -07004320# $1: boot image file name
4321define misc_boot_size
4322$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4323endef
4324
Daniel Normane1e48082019-06-27 13:55:23 -07004325$(INSTALLED_MISC_INFO_TARGET):
4326 rm -f $@
4327 $(call pretty,"Target misc_info.txt: $@")
4328 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4329 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4330ifdef BOARD_FLASH_BLOCK_SIZE
4331 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4332endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004333ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4334 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4335 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004336endif
4337ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4338 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004339else
4340 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004341endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004342ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4343 echo "lz4_ramdisks=true" >> $@
4344endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004345ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4346 echo "vendor_boot=true" >> $@
4347 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4348endif
Daniel Normane1e48082019-06-27 13:55:23 -07004349ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4350 $(hide) echo "no_recovery=true" >> $@
4351endif
4352ifdef BOARD_INCLUDE_RECOVERY_DTBO
4353 $(hide) echo "include_recovery_dtbo=true" >> $@
4354endif
4355ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4356 $(hide) echo "include_recovery_acpio=true" >> $@
4357endif
4358ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4359 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4360endif
4361ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4362 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4363 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4364else
4365 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4366endif
4367 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4368 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4369ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4370 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4371endif
4372 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004373 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004374 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
Bowgo Tsai27c39b02021-03-12 21:40:32 +08004375ifdef BOARD_GKI_SIGNING_KEY_PATH
4376 $(hide) echo 'gki_signing_key_path=$(BOARD_GKI_SIGNING_KEY_PATH)' >> $@
4377 $(hide) echo 'gki_signing_algorithm=$(BOARD_GKI_SIGNING_ALGORITHM)' >> $@
4378endif
4379ifdef BOARD_GKI_SIGNING_SIGNATURE_ARGS
4380 $(hide) echo 'gki_signing_signature_args=$(BOARD_GKI_SIGNING_SIGNATURE_ARGS)' >> $@
4381endif
Daniel Normane1e48082019-06-27 13:55:23 -07004382 $(hide) echo "multistage_support=1" >> $@
4383 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4384ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4385 $(hide) echo "build_generic_ota_package=true" >> $@
4386endif
4387ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4388 # OTA scripts are only interested in fingerprint related properties
4389 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4390endif
4391ifneq (,$(filter address, $(SANITIZE_TARGET)))
4392 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4393 $(hide) echo "userdata_img_with_data=true" >> $@
4394endif
4395ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4396 $(hide) echo "full_recovery_image=true" >> $@
4397endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004398ifdef BOARD_USES_VENDORIMAGE
4399 $(hide) echo "board_uses_vendorimage=true" >> $@
4400endif
Daniel Normane1e48082019-06-27 13:55:23 -07004401ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08004402ifeq ($(BUILDING_VBMETA_IMAGE),true)
4403 $(hide) echo "avb_building_vbmeta_image=true" >> $@
4404endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004405 $(hide) echo "avb_enable=true" >> $@
4406 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4407 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4408 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4409 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4410ifdef BOARD_AVB_BOOT_KEY_PATH
4411 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4412 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4413 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4414endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004415 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4416ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4417 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4418 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4419 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4420endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004421 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4422ifdef BOARD_AVB_RECOVERY_KEY_PATH
4423 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4424 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4425 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4426endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004427ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4428 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4429 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4430 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4431 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4432 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4433 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4434 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4435 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4436endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004437ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4438 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4439 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4440 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4441 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4442 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4443endif # BOARD_AVB_VBMETA_SYSTEM
4444ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4445 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4446 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4447 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4448 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4449 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4450endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4451endif # BOARD_AVB_ENABLE
4452ifdef BOARD_BPT_INPUT_FILES
4453 $(hide) echo "board_bpt_enable=true" >> $@
4454 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4455 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4456endif
4457ifdef BOARD_BPT_DISK_SIZE
4458 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4459endif
4460 $(call generate-userimage-prop-dictionary, $@)
4461ifeq ($(AB_OTA_UPDATER),true)
4462 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4463 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4464 $(hide) echo "ab_update=true" >> $@
4465endif
Yifan Hong65afc072020-04-17 10:08:10 -07004466ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4467 $(hide) echo "allow_non_ab=true" >> $@
4468endif
Daniel Normane1e48082019-06-27 13:55:23 -07004469ifdef BOARD_PREBUILT_DTBOIMAGE
4470 $(hide) echo "has_dtbo=true" >> $@
4471ifeq ($(BOARD_AVB_ENABLE),true)
4472 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4473 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4474ifdef BOARD_AVB_DTBO_KEY_PATH
4475 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4476 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4477 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4478endif # BOARD_AVB_DTBO_KEY_PATH
4479endif # BOARD_AVB_ENABLE
4480endif # BOARD_PREBUILT_DTBOIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00004481ifdef BOARD_PREBUILT_PVMFWIMAGE
4482 $(hide) echo "has_pvmfw=true" >> $@
4483ifeq ($(BOARD_AVB_ENABLE),true)
4484 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMG_PARTITION_SIZE)" >> $@
4485 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
4486ifdef BOARD_AVB_PVMFW_KEY_PATH
4487 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
4488 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
4489 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
4490endif # BOARD_AVB_PVMFW_KEY_PATH
4491endif # BOARD_AVB_ENABLE
4492endif # BOARD_PREBUILT_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004493 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004494 @# VINTF checks
4495ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4496 $(hide) echo "vintf_enforce=true" >> $@
4497endif
4498ifdef ODM_MANIFEST_SKUS
4499 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4500endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004501ifdef ODM_MANIFEST_FILES
4502 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4503endif
4504ifdef DEVICE_MANIFEST_SKUS
4505 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4506endif
4507ifdef DEVICE_MANIFEST_FILE
4508 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4509endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004510ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4511 $(hide) echo "bootloader_in_update_package=true" >> $@
4512endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07004513ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
4514 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
4515endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05004516ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
4517 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
4518endif
Daniel Normane1e48082019-06-27 13:55:23 -07004519
4520.PHONY: misc_info
4521misc_info: $(INSTALLED_MISC_INFO_TARGET)
4522
4523droidcore: $(INSTALLED_MISC_INFO_TARGET)
4524
4525# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004526# A zip of the directories that map to the target filesystem.
4527# This zip can be used to create an OTA package or filesystem image
4528# as a post-build step.
4529#
4530name := $(TARGET_PRODUCT)
4531ifeq ($(TARGET_BUILD_TYPE),debug)
4532 name := $(name)_debug
4533endif
4534name := $(name)-target_files-$(FILE_NAME_TAG)
4535
4536intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4537BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4538$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4539$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004540 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004541
4542# $(1): Directory to copy
4543# $(2): Location to copy it to
4544# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4545define package_files-copy-root
4546 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4547 mkdir -p $(2) && \
4548 $(ACP) -rd $(strip $(1))/* $(2); \
4549 fi
4550endef
4551
Tao Baoa04fca32015-11-30 12:22:24 -08004552built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004553
4554# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004555ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004556built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004557 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004558endif
4559
The Android Open Source Project88b60792009-03-03 19:28:42 -08004560$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4561
Dan Willemsen653bea92017-03-21 15:47:37 -07004562tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004563$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004564
Sen Jiang4438fd92016-03-07 16:51:01 -08004565ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004566updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004567endif
4568
4569# Build OTA tools if non-A/B is allowed
4570ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004571updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004572endif
Yifan Hong65afc072020-04-17 10:08:10 -07004573
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004574$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004575
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004576# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07004577# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004578ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4579$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07004580else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
4581$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004582else
4583$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4584endif
4585
Dan Willemsen653bea92017-03-21 15:47:37 -07004586ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004587 ifdef OSRELEASED_DIRECTORY
4588 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4589 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4590 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4591 endif
Tao Baoa835f382019-07-18 15:55:30 -07004592
4593 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4594 # additionally include radio or bootloader partitions).
4595 ifeq ($(AB_OTA_PARTITIONS),)
4596 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4597 endif
4598endif
4599
4600ifneq ($(AB_OTA_PARTITIONS),)
4601 ifneq ($(AB_OTA_UPDATER),true)
4602 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4603 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004604endif
4605
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004606# Run fs_config while creating the target files package
4607# $1: root directory
4608# $2: add prefix
4609define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004610(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 -08004611endef
4612
Yifan Hong60bfcc42019-11-01 11:39:45 -07004613define filter-out-missing-vendor
4614$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4615endef
Petri Gynther09865a42021-03-10 18:23:39 -08004616define filter-out-missing-vendor_dlkm
4617$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
4618endef
4619define filter-out-missing-odm
4620$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
4621endef
4622define filter-out-missing-odm_dlkm
4623$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
4624endef
4625# Filter out vendor,vendor_dlkm,odm,odm_dlkm from the list for AOSP targets.
4626# $(1): list
4627define filter-out-missing-partitions
4628$(call filter-out-missing-vendor,\
4629 $(call filter-out-missing-vendor_dlkm,\
4630 $(call filter-out-missing-odm,\
4631 $(call filter-out-missing-odm_dlkm,$(1)))))
4632endef
Yifan Hong60bfcc42019-11-01 11:39:45 -07004633
4634# Information related to dynamic partitions and virtual A/B. This information
4635# is needed for building the super image (see dump-super-image-info) and
4636# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004637# $(1): file
4638define dump-dynamic-partitions-info
4639 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4640 echo "use_dynamic_partitions=true" >> $(1))
4641 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4642 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004643 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4644 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4645 echo "build_super_partition=true" >> $(1)))
Yo Chiange86bab42021-03-25 10:12:28 +00004646 $(if $(BUILDING_SUPER_EMPTY_IMAGE), \
4647 echo "build_super_empty_partition=true" >> $(1))
Tao Bao519d1822018-12-27 12:47:23 -08004648 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4649 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004650 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4651 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4652 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4653 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4654 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4655 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08004656 echo "dynamic_partition_list=$(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004657 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4658 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4659 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4660 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4661 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Petri Gynther09865a42021-03-10 18:23:39 -08004662 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 -07004663 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4664 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004665 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4666 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004667 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4668 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004669 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4670 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4671 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4672 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4673 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4674 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4675 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4676 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004677 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4678 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05004679 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
4680 echo "virtual_ab_compression=true" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004681 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4682 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004683endef
4684
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004685# By conditionally including the dependency of the target files package on the
4686# full system image deps, we speed up builds that do not build the system
4687# image.
4688ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004689 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4690endif
4691
4692ifdef BUILDING_USERDATA_IMAGE
4693 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4694endif
4695
4696ifdef BUILDING_SYSTEM_OTHER_IMAGE
4697 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4698endif
4699
4700ifdef BUILDING_VENDOR_BOOT_IMAGE
4701 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08004702 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Colin Crosse6431202021-02-24 11:44:55 -08004703 # The vendor ramdisk may be built from the recovery ramdisk.
4704 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
4705 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
4706 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07004707endif
4708
4709ifdef BUILDING_RECOVERY_IMAGE
4710 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08004711 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07004712 # commands in build-recoveryimage-target, which would touch the files under
4713 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4714 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4715 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4716 else
4717 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4718 endif
4719 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4720endif
4721
4722# Conditionally depend on the image files if the image is being built so the
4723# target-files.zip rule doesn't wait on the image creation rule, or the image
4724# if it is coming from a prebuilt.
4725
4726ifdef BUILDING_VENDOR_IMAGE
4727 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4728else ifdef BOARD_PREBUILT_VENDORIMAGE
4729 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4730endif
4731
4732ifdef BUILDING_PRODUCT_IMAGE
4733 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4734else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4735 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4736endif
4737
4738ifdef BUILDING_SYSTEM_EXT_IMAGE
4739 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4740else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4741 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4742endif
4743
4744ifdef BUILDING_BOOT_IMAGE
4745 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Yifan Hong49968aa2020-11-09 11:52:52 -08004746endif
4747ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07004748 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4749endif
4750
4751ifdef BUILDING_ODM_IMAGE
4752 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4753else ifdef BOARD_PREBUILT_ODMIMAGE
4754 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4755endif
4756
4757ifdef BUILDING_VENDOR_DLKM_IMAGE
4758 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08004759else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004760 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4761endif
4762
4763ifdef BUILDING_ODM_DLKM_IMAGE
4764 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08004765else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004766 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004767endif
4768
Isaac Chen9e09d472019-07-05 17:30:41 +08004769ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004770 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4771 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004772endif
4773
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004774ifdef BOARD_PREBUILT_BOOTLOADER
4775$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004776droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004777endif
4778
The Android Open Source Project88b60792009-03-03 19:28:42 -08004779# Depending on the various images guarantees that the underlying
4780# directories are up-to-date.
4781$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004782 $(INSTALLED_RADIOIMAGE_TARGET) \
4783 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004784 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004785 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004786 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004787 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004788 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4789 $(INSTALLED_KERNEL_TARGET) \
Enrico Granata16059382020-10-14 15:17:20 -06004790 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004791 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004792 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4793 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004794 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004795 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004796 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4797 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4798 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004799 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004800 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004801 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004802 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004803 $(LPMAKE) \
4804 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004805 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004806 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004807 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004808 $(SOONG_ZIP) \
4809 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004810 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004811 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004812 $(BUILT_KERNEL_CONFIGS_FILE) \
4813 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004814 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004815 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004816 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004817 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07004818ifneq (,$(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 -08004819 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004820 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004821 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004822 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004823ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004824ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004825 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07004826else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07004827 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4828endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004829endif
Yifan Hong78860162020-10-28 14:15:21 -07004830ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004831ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004832 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004833endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004834ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004835ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004836 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004837else
Steve Mucklee1b10862019-07-10 10:49:37 -07004838 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004839endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004840endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004841ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004842 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004843endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004844ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004845 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004846endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004847ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004848ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004849 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07004850endif # INTERNAL_KERNEL_CMDLINE != ""
4851endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07004852ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004853 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004854endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004855ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004856 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004857endif
Yifan Hong3941a872020-10-28 16:33:06 -07004858endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004859endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004860 @# Components of the boot image
4861 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004862 $(hide) mkdir -p $(zip_root)/ROOT
4863 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004864 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004865 @# If we are using recovery as boot, this is already done when processing recovery.
4866ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004867ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004868 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004869 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004870endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004871ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004872 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004873endif
Yifan Hong46aff092020-10-28 13:50:47 -07004874ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07004875 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07004876else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07004877 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004878ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004879 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004880endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004881ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004882 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004883endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004884ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004885 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004886endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004887ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004888 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004889endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004890endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07004891endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004892 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4893 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004894 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004895ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4896 mkdir -p $(zip_root)/VENDOR_BOOT
4897 $(call package_files-copy-root, \
4898 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4899ifdef INSTALLED_DTBIMAGE_TARGET
4900 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4901endif
Devin Moore50509012021-01-13 10:45:04 -08004902ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
4903 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
4904endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004905ifdef BOARD_KERNEL_BASE
4906 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4907endif
4908ifdef BOARD_KERNEL_PAGESIZE
4909 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4910endif
4911 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08004912ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
4913 echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
4914 $(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08004915 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
4916 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
4917 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
4918 $(if $(prebuilt_ramdisk), \
4919 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
4920 $(call package_files-copy-root, \
4921 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
4922 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
4923 ))
Yi-Yo Chiang1519d432021-04-04 16:03:10 +08004924endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07004925endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004926ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004927 @# Contents of the system image
4928 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004929 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004930endif
4931ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004932 @# Contents of the data image
4933 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004934 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004935endif
4936ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004937 @# Contents of the vendor image
4938 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004939 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004940endif
Dan Willemsen67495202019-01-16 12:42:05 -08004941ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004942 @# Contents of the product image
4943 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004944 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004945endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004946ifdef BUILDING_SYSTEM_EXT_IMAGE
4947 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004948 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004949 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004950endif
Dan Willemsen67495202019-01-16 12:42:05 -08004951ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004952 @# Contents of the odm image
4953 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004954 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004955endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004956ifdef BUILDING_VENDOR_DLKM_IMAGE
4957 @# Contents of the vendor_dlkm image
4958 $(hide) $(call package_files-copy-root, \
4959 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4960endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004961ifdef BUILDING_ODM_DLKM_IMAGE
4962 @# Contents of the odm_dlkm image
4963 $(hide) $(call package_files-copy-root, \
4964 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4965endif
Dan Willemsen67495202019-01-16 12:42:05 -08004966ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004967 @# Contents of the system_other image
4968 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004969 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004970endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004971 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004972 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004973 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granata16059382020-10-14 15:17:20 -06004974ifdef BUILDING_RAMDISK_IMAGE
4975ifeq (true,$(BOARD_IMG_USE_RAMDISK))
4976 @# Contents of the ramdisk image
4977 $(hide) mkdir -p $(zip_root)/IMAGES
4978 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
4979endif
4980endif
Yifan Hong65afc072020-04-17 10:08:10 -07004981ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004982ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004983 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004984 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004985endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004986endif
Doug Zongker8678df42009-06-15 14:30:14 -07004987 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004988 @# build them.
4989 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004990 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004991 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004992ifneq ($(tool_extension),)
4993 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4994endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004995 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004996 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004997 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004998ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4999 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
5000 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005001endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005002ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
5003 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
5004 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07005005endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005006ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
5007 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
5008 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005009endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005010ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
5011 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
5012 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01005013endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00005014ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
5015 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
5016 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005017endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005018ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
5019 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
5020 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
5021endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005022ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
5023 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
5024 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
5025endif
Yifan Hong65afc072020-04-17 10:08:10 -07005026ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07005027ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07005028 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07005029 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07005030endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08005031endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005032ifeq ($(AB_OTA_UPDATER),true)
5033 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07005034 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07005035 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07005036 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
5037 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08005038 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
5039 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
5040 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005041ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07005042 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
5043 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
5044 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07005045endif
Alex Deymo70067ac2015-09-29 19:05:37 -07005046endif
Steve Fungdfbab492015-09-24 18:12:33 -07005047ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07005048 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07005049 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07005050endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07005051ifdef BOARD_PREBUILT_VENDORIMAGE
5052 $(hide) mkdir -p $(zip_root)/IMAGES
5053 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
5054endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005055ifdef BOARD_PREBUILT_PRODUCTIMAGE
5056 $(hide) mkdir -p $(zip_root)/IMAGES
5057 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
5058endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005059ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01005060 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09005061 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01005062endif
Yifan Hong49968aa2020-11-09 11:52:52 -08005063ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
5064ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07005065 $(hide) mkdir -p $(zip_root)/IMAGES
5066 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08005067endif # INSTALLED_BOOTIMAGE_TARGET
5068endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005069ifdef BOARD_PREBUILT_ODMIMAGE
5070 $(hide) mkdir -p $(zip_root)/IMAGES
5071 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
5072endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07005073ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07005074 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07005075 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
5076endif
5077ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
5078 $(hide) mkdir -p $(zip_root)/IMAGES
5079 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07005080endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07005081ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07005082 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5083 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08005084endif # BOARD_PREBUILT_DTBOIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00005085ifdef BOARD_PREBUILT_PVMFWIMAGE
5086 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5087 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5088endif # BOARD_PREBUILT_PVMFWIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005089ifdef BOARD_PREBUILT_BOOTLOADER
5090 $(hide) mkdir -p $(zip_root)/IMAGES
5091 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
5092endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07005093ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
5094 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5095 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5096 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
5097endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07005098 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
5099 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
5100 @# INSTALLED_RADIOIMAGE_TARGET.
5101 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
5102 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005103 @# Run fs_config on all the system, vendor, boot ramdisk,
5104 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08005105ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005106 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08005107endif
5108ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005109 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
5110endif
Dan Willemsen67495202019-01-16 12:42:05 -08005111ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005112 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
5113endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005114ifdef BUILDING_SYSTEM_EXT_IMAGE
5115 $(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 +01005116endif
Dan Willemsen67495202019-01-16 12:42:05 -08005117ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005118 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
5119endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005120ifdef BUILDING_VENDOR_DLKM_IMAGE
5121 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
5122endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005123ifdef BUILDING_ODM_DLKM_IMAGE
5124 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
5125endif
Tom Cherryd14b8952018-08-09 14:26:00 -07005126 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005127 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005128ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07005129 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005130 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005131endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005132ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5133 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
5134endif
Tom Cherry2929cad2018-09-20 11:04:37 -07005135ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
5136 @# 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 -08005137 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
5138endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005139ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5140 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
5141endif
Dan Willemsen67495202019-01-16 12:42:05 -08005142ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005143 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
5144endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07005145 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07005146ifdef BUILT_KERNEL_CONFIGS_FILE
5147 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
5148endif
5149ifdef BUILT_KERNEL_VERSION_FILE
5150 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
5151endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07005152 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
5153ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5154 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
5155endif
Tao Baocbd6d492019-10-07 22:46:02 -07005156 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
5157 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08005158ifeq ($(BUILD_QEMU_IMAGES),true)
5159 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
5160 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
5161endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08005162 @# Zip everything up, preserving symlinks and placing META/ files first to
5163 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005164 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07005165 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08005166 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07005167
Ying Wanga0febe52013-03-20 11:02:05 -07005168.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08005169target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
5170
Ying Wang4709d7c2014-04-14 17:25:43 -07005171$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07005172
Dan Albert4d323332016-10-14 13:23:06 -07005173# -----------------------------------------------------------------
5174# NDK Sysroot Package
5175NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07005176$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07005177 @echo Package NDK sysroot...
5178 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
5179
5180$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
5181
Ying Wang09c4b682015-08-11 11:24:19 -07005182ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07005183# -----------------------------------------------------------------
5184# OTA update package
5185
Yifan Hong50e79542018-11-08 17:44:12 -08005186# $(1): output file
5187# $(2): additional args
5188define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07005189PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07005190 $(OTA_FROM_TARGET_FILES) \
5191 --verbose \
5192 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
5193 --path $(HOST_OUT) \
5194 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
5195 $(2) \
5196 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08005197endef
5198
Tianjie6bd3b1a2020-10-16 18:53:47 -07005199product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07005200ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005201 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07005202endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07005203name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07005204
5205INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08005206INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
5207
Doug Zongker8678df42009-06-15 14:30:14 -07005208$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08005209$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07005210$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07005211 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08005212 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07005213
5214.PHONY: otapackage
5215otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
5216
Tao Bao519d1822018-12-27 12:47:23 -08005217ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005218name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08005219
5220INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08005221$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07005222$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
5223 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07005224 $(OTA_FROM_TARGET_FILES) \
5225 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08005226 @echo "Package OTA (retrofit dynamic partitions): $@"
5227 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
5228
5229.PHONY: otardppackage
5230
5231otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
5232
Tao Bao519d1822018-12-27 12:47:23 -08005233endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08005234
Tianjie6bd3b1a2020-10-16 18:53:47 -07005235ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5236name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
5237
5238INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5239$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
5240$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
5241 @echo "Package partial OTA: $@"
5242 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
5243
5244.PHONY: partialotapackage
5245partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
5246
5247endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
5248
Ying Wang09c4b682015-08-11 11:24:19 -07005249endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07005250
Ying Wang09a00a62010-10-20 14:01:09 -07005251# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01005252# A zip of the appcompat directory containing logs
5253APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
5254# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005255ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07005256$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
5257 $(INTERNAL_RAMDISK_FILES) \
5258 $(INTERNAL_USERDATAIMAGE_FILES) \
5259 $(INTERNAL_VENDORIMAGE_FILES) \
5260 $(INTERNAL_PRODUCTIMAGE_FILES) \
5261 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01005262endif
5263$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
5264$(APPCOMPAT_ZIP): $(SOONG_ZIP)
5265 @echo "appcompat logs: $@"
5266 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5267 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
5268 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
5269 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
5270
Dario Frenid1011272018-07-23 20:20:15 +01005271# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005272# A zip of the symbols directory. Keep the full paths to make it
5273# more obvious where these files came from.
5274#
5275name := $(TARGET_PRODUCT)
5276ifeq ($(TARGET_BUILD_TYPE),debug)
5277 name := $(name)_debug
5278endif
5279name := $(name)-symbols-$(FILE_NAME_TAG)
5280
5281SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07005282# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005283ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005284$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07005285endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005286$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
5287$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005288 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005289 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5290 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09005291 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07005292 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005293# -----------------------------------------------------------------
5294# A zip of the coverage directory.
5295#
Oliver Nguyene91ab232019-04-30 15:14:44 -07005296name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07005297ifeq ($(TARGET_BUILD_TYPE),debug)
5298name := $(name)_debug
5299endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07005300COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005301ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005302$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005303endif
5304$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
5305$(COVERAGE_ZIP): $(SOONG_ZIP)
5306 @echo "Package coverage: $@"
5307 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5308 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
5309 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
5310 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005311
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08005312#------------------------------------------------------------------
5313# Export the LLVM profile data tool and dependencies for Clang coverage processing
5314#
5315ifeq (true,$(CLANG_COVERAGE))
5316 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
5317 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
5318 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
5319 $(PROFDATA_ZIP): $(SOONG_ZIP)
5320 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
5321
5322 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
5323endif
5324
The Android Open Source Project88b60792009-03-03 19:28:42 -08005325# -----------------------------------------------------------------
5326# A zip of the Android Apps. Not keeping full path so that we don't
5327# include product names when distributing
5328#
5329name := $(TARGET_PRODUCT)
5330ifeq ($(TARGET_BUILD_TYPE),debug)
5331 name := $(name)_debug
5332endif
5333name := $(name)-apps-$(FILE_NAME_TAG)
5334
5335APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07005336$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005337 @echo "Package apps: $@"
5338 $(hide) rm -rf $@
5339 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005340 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
5341 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00005342 echo "No apps to zip up. Generating empty apps archive." ; \
5343 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005344 else \
Anton Hansson6d814982018-11-26 18:12:05 +00005345 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005346 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07005347
Ying Wangbc415dd2012-08-15 12:22:44 -07005348ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07005349#------------------------------------------------------------------
5350# An archive of classes for use in generating code-coverage reports
5351# These are the uninstrumented versions of any classes that were
5352# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07005353# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005354
Colin Crossa6bc3a82017-09-27 14:28:41 -07005355JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005356$(JACOCO_REPORT_CLASSES_ALL) :
5357 @echo "Collecting uninstrumented classes"
Colin Crosse8ac9952020-10-09 18:41:58 -07005358 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" -o -name "proguard_usage.zip" 2>/dev/null | sort > $@.list
Colin Crossd81f4b32020-02-12 14:14:27 -08005359 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005360
Jiyong Park3c875602021-01-21 12:46:56 +09005361ifeq (,$(TARGET_BUILD_UNBUNDLED))
5362 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
5363endif
Ying Wangbc415dd2012-08-15 12:22:44 -07005364endif # EMMA_INSTRUMENT=true
5365
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005366
Ying Wangae9115a2013-08-22 20:52:47 -07005367#------------------------------------------------------------------
5368# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07005369#
Ying Wangc62c92c2013-08-28 18:38:25 -07005370PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07005371# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005372ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005373$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07005374endif
5375$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
5376$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07005377 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07005378 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5379 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
5380 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
5381 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07005382
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005383#------------------------------------------------------------------
5384# A zip of Proguard usage files.
5385#
5386PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
5387# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
5388ifeq (,$(TARGET_BUILD_UNBUNDLED))
5389$(PROGUARD_USAGE_ZIP): \
5390 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5391 $(INSTALLED_RAMDISK_TARGET) \
5392 $(INSTALLED_BOOTIMAGE_TARGET) \
5393 $(INSTALLED_USERDATAIMAGE_TARGET) \
5394 $(INSTALLED_VENDORIMAGE_TARGET) \
5395 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5396 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
5397 $(INSTALLED_ODMIMAGE_TARGET) \
5398 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
5399 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
5400 $(updater_dep)
5401endif
5402$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
5403$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
5404 @echo "Packaging Proguard usage files."
5405 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5406 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
5407 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07005408
5409ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5410
5411# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
5412# $(1): output file
5413define dump-super-image-info
5414 $(call dump-dynamic-partitions-info,$(1))
5415 $(if $(filter true,$(AB_OTA_UPDATER)), \
5416 echo "ab_update=true" >> $(1))
5417endef
5418
5419endif # PRODUCT_USE_DYNAMIC_PARTITIONS
5420
The Android Open Source Project88b60792009-03-03 19:28:42 -08005421# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005422# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005423
5424ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5425
5426# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5427ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5428
5429ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005430
5431# For real devices and for dist builds, build super image from target files to an intermediate directory.
5432INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5433$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5434$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5435 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005436 PATH=$(dir $(LPMAKE)):$$PATH \
5437 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005438
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005439# Skip packing it in dist package because it is in update package.
5440ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005441$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005442endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005443
5444.PHONY: superimage_dist
5445superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005446
5447endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005448endif # BOARD_SUPER_PARTITION_SIZE != ""
5449endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005450
Yifan Hongacd862a2019-04-16 15:44:30 -07005451# -----------------------------------------------------------------
5452# super partition image for development
5453
5454ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5455ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5456ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5457
5458# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5459# $(1): built image path
5460# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5461define build-superimage-target
5462 mkdir -p $(dir $(2))
5463 rm -rf $(2)
5464 $(call dump-super-image-info,$(2))
5465 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5466 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005467 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5468 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005469 mkdir -p $(dir $(1))
5470 PATH=$(dir $(LPMAKE)):$$PATH \
5471 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5472endef
5473
5474INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5475INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5476 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5477
changho.shina8f9f112019-10-15 13:26:19 +09005478ifdef BUILDING_SYSTEM_OTHER_IMAGE
5479ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5480INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5481endif
5482endif
5483
Yifan Hongacd862a2019-04-16 15:44:30 -07005484# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5485# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5486# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5487# virtual devices.
5488ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5489$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5490 $(call pretty,"Target super fs image for debug: $@")
5491 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005492 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005493
5494droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5495
5496# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5497.PHONY: superimage
5498superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005499
5500$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005501endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5502
5503# Build $(PRODUCT_OUT)/super.img without dependencies.
5504.PHONY: superimage-nodeps supernod
5505superimage-nodeps supernod: intermediates :=
5506superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5507 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5508 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5509 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5510
5511endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5512endif # BOARD_SUPER_PARTITION_SIZE != ""
5513endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5514
5515# -----------------------------------------------------------------
5516# super empty image
Yo Chiange86bab42021-03-25 10:12:28 +00005517ifdef BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08005518
Yifan Hong8b79d162018-11-29 12:32:00 -08005519INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5520$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5521$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5522 $(call pretty,"Target empty super fs image: $@")
5523 mkdir -p $(intermediates)
5524 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005525 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005526 PATH=$(dir $(LPMAKE)):$$PATH \
5527 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005528
5529$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5530
Yo Chiange86bab42021-03-25 10:12:28 +00005531endif # BUILDING_SUPER_EMPTY_IMAGE
Yifan Hong2b891ac2018-11-29 12:06:31 -08005532
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005533
5534# -----------------------------------------------------------------
5535# The update package
5536
5537name := $(TARGET_PRODUCT)
5538ifeq ($(TARGET_BUILD_TYPE),debug)
5539 name := $(name)_debug
5540endif
5541name := $(name)-img-$(FILE_NAME_TAG)
5542
5543INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5544
Tao Bao57f8ed62019-08-14 23:08:18 -07005545$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5546 $(call pretty,"Package: $@")
5547 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5548 $(IMG_FROM_TARGET_FILES) \
5549 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5550 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005551
5552.PHONY: updatepackage
5553updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005554$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005555
5556
Yifan Hong2b891ac2018-11-29 12:06:31 -08005557# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005558# dalvik something
5559.PHONY: dalvikfiles
5560dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5561
Bo Huf0d50bb2017-08-01 19:02:09 +00005562ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005563MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005564MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005565SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005566
5567ifdef INSTALLED_SYSTEMIMAGE_TARGET
5568INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005569INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5570$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5571 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5572 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005573$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005574 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5575 @echo Create system-qemu.img now
5576 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005577 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005578
5579systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5580droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005581endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005582ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005583INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005584$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005585 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005586 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005587
5588vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5589droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5590endif
bohu8fd437c2020-03-30 20:16:13 -07005591
5592ifdef INSTALLED_RAMDISK_TARGET
5593ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5594ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5595INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5596$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5597 @echo Create ramdisk-qemu.img
5598 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5599
5600droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5601endif
5602endif
5603endif
5604
Anton Hansson32c76fe2018-12-13 14:34:18 +00005605ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005606INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005607$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005608 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005609 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005610
5611productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5612droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5613endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005614ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5615INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5616$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5617 @echo Create system_ext-qemu.img
5618 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005619
Justin Yun6151e3f2019-06-25 15:58:13 +09005620systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5621droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005622endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005623ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005624INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5625$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5626 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005627 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005628
5629odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5630droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5631endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005632
Yifan Hongcfb917a2020-05-07 14:58:20 -07005633ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5634INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5635$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5636 @echo Create vendor_dlkm-qemu.img
5637 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5638
5639vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5640droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5641endif
5642
Yifan Hongf496f1b2020-07-15 16:52:59 -07005643ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5644INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5645$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5646 @echo Create odm_dlkm-qemu.img
5647 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5648
5649odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5650droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5651endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005652
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005653QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005654$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5655 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005656 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005657 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5658 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005659
5660systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5661droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005662
Bo Huf0d50bb2017-08-01 19:02:09 +00005663endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005664# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005665# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005666ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005667INTERNAL_EMULATOR_PACKAGE_FILES += \
5668 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005669 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005670 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005671 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5672 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005673
5674name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5675
5676INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5677
Ying Wang5d887702015-11-04 10:06:25 -08005678$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005679 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005680 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005681
Ying Wang7d8c5352012-07-26 10:15:21 -07005682endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005683
The Android Open Source Project88b60792009-03-03 19:28:42 -08005684
5685# -----------------------------------------------------------------
5686# The SDK
5687
The Android Open Source Project88b60792009-03-03 19:28:42 -08005688# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005689sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005690
5691# Build a name that looks like:
5692#
5693# linux-x86 --> android-sdk_12345_linux-x86
5694# darwin-x86 --> android-sdk_12345_mac-x86
5695# windows-x86 --> android-sdk_12345_windows
5696#
5697sdk_name := android-sdk_$(FILE_NAME_TAG)
5698ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005699 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005700else
Joe Onorato03fbe402009-04-13 08:31:16 -07005701 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005702endif
5703ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005704 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005705endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005706sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005707
5708sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5709
5710ATREE_FILES :=
5711-include $(sdk_dep_file)
5712
5713# if we don't have a real list, then use "everything"
5714ifeq ($(strip $(ATREE_FILES)),)
5715ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005716 $(ALL_DEFAULT_INSTALLED_MODULES) \
5717 $(INSTALLED_RAMDISK_TARGET) \
5718 $(ALL_DOCS) \
5719 $(ALL_SDK_FILES)
5720endif
5721
5722atree_dir := development/build
5723
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005724
The Android Open Source Project88b60792009-03-03 19:28:42 -08005725sdk_atree_files := \
5726 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005727 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005728
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005729# development/build/sdk-android-<abi>.atree is used to differentiate
5730# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5731# files like the kernel image. We use TARGET_CPU_ABI because we don't
5732# have a better way to distinguish between CPU models.
5733ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5734 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5735endif
5736
Anton Hansson8dab0a62019-03-28 15:45:40 +00005737ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5738sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005739else
5740sdk_atree_files += $(atree_dir)/sdk.atree
5741endif
5742
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005743include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005744
The Android Open Source Project88b60792009-03-03 19:28:42 -08005745deps := \
5746 $(target_notice_file_txt) \
5747 $(tools_notice_file_txt) \
5748 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005749 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005750 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005751 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005752 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005753 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005754 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005755 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005756 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005757 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005758 $(INSTALLED_USERDATAIMAGE_TARGET) \
5759 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005760 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005761 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005762 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005763 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005764 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005765 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005766 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005767
5768INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5769$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5770$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5771$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5772$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5773
5774# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5775#
5776#SDK_GNU_ERROR := true
5777
Ying Wang5d887702015-11-04 10:06:25 -08005778$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005779 @echo "Package SDK: $@"
5780 $(hide) rm -rf $(PRIVATE_DIR) $@
5781 $(hide) for f in $(target_gnu_MODULES); do \
5782 if [ -f $$f ]; then \
5783 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5784 including GNU target $$f >&2; \
5785 FAIL=$(SDK_GNU_ERROR); \
5786 fi; \
5787 done; \
5788 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005789 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005790 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005791 ATREE_STRIP="$(HOST_STRIP) -x" \
5792 $(HOST_OUT_EXECUTABLES)/atree \
5793 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5794 -m $(PRIVATE_DEP_FILE) \
5795 -I . \
5796 -I $(PRODUCT_OUT) \
5797 -I $(HOST_OUT) \
5798 -I $(TARGET_COMMON_OUT_ROOT) \
5799 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5800 -v "OUT_DIR=$(OUT_DIR)" \
5801 -v "HOST_OUT=$(HOST_OUT)" \
5802 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5803 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5804 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5805 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5806 -o $(PRIVATE_DIR) && \
5807 cp -f $(target_notice_file_txt) \
5808 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5809 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5810 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5811 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5812 chmod -R ug+rwX $(PRIVATE_DIR) && \
5813 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005814 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5815
Raphael3d224a02010-04-16 17:50:09 -07005816
5817# Is a Windows SDK requested? If so, we need some definitions from here
5818# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005819MAIN_SDK_NAME := $(sdk_name)
5820MAIN_SDK_DIR := $(sdk_dir)
5821MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005822ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005823include $(TOPDIR)development/build/tools/windows_sdk.mk
5824endif
5825
The Android Open Source Project88b60792009-03-03 19:28:42 -08005826# -----------------------------------------------------------------
5827# Findbugs
5828INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5829INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5830$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5831 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005832 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005833 > $@
5834$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5835 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005836 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005837 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005838
5839# -----------------------------------------------------------------
5840# Findbugs
5841
5842# -----------------------------------------------------------------
5843# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005844ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005845include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005846-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005847-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005848-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005849# Also the project-specific tasks
5850-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5851-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005852-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005853# Also add test specifc tasks
5854include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005855include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005856endif
Raphaelc4d47312011-02-15 16:09:36 -08005857
Ying Wang67132ba2015-10-28 16:42:39 -07005858include $(BUILD_SYSTEM)/product-graph.mk
5859
Raphaelc4d47312011-02-15 16:09:36 -08005860# -----------------------------------------------------------------
5861# Create SDK repository packages. Must be done after tasks/* since
5862# we need the addon rules defined.
5863ifneq ($(sdk_repo_goal),)
5864include $(TOPDIR)development/build/tools/sdk_repo.mk
5865endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005866
5867# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005868# Soong generates the list of all shared libraries that are depended on by fuzz
5869# targets. It saves this list as a source:destination pair to
5870# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5871# build of the unstripped shared library, and the destination is the
5872# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5873# where fuzz target shared libraries are to be "reinstalled". The
5874# copy-many-files below generates the rules to copy the unstripped shared
5875# libraries to the device or host "reinstallation" directory. These rules are
5876# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5877# a dependency on each shared library that it needs to be "reinstalled".
5878FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5879
5880# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005881# The rule to build all fuzz targets, and package them.
5882# Note: The packages are created in Soong, and in a perfect world,
5883# we'd be able to create the phony rule there. But, if we want to
5884# have dist goals for the fuzz target, we need to have the PHONY
5885# target defined in make. MakeVarsContext.DistForGoal doesn't take
5886# into account that a PHONY rule create by Soong won't be available
5887# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005888# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005889# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005890.PHONY: haiku
5891haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5892$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))