blob: a67d02a16523b9c523ce8168f33f23bd39fe5446 [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# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700214# kernel modules
215
216# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
217DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
218
J. Avilaa2ceec62020-05-12 23:40:02 +0000219define copy-and-strip-kernel-module
220$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000221 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000222endef
223
Colin Cross4f60e362019-06-05 11:53:43 -0700224# $(1): modules list
225# $(2): output dir
226# $(3): mount point
227# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700228# $(5): module load list
229# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800230# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000231# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700232# $(9): module directory name
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800233# Returns a list of src:dest pairs to install the modules using copy-many-files.
Colin Cross4f60e362019-06-05 11:53:43 -0700234define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700235 $(if $(9), \
236 $(eval _dir := $(9)/), \
237 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000238 $(foreach module,$(1), \
239 $(eval _src := $(module)) \
240 $(if $(8), \
241 $(eval _src := $(8)/$(notdir $(module))) \
242 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700243 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700244 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700245 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
246 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
247 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
248 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700249endef
250
251# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700252# $(2): mount point
253# $(3): staging dir
254# $(4): module load list
255# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800256# $(6): module archive
257# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700258# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800259# TODO(b/144844424): If a module archive is being used, this step (which
260# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
261# the output directory. This should be moved to a module with a
262# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
263# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700264define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700265$(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 -0700266$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
267$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
268$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700269$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700270$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
271$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
272$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800273$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
274$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
275$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700276 @echo depmod $$(PRIVATE_STAGING_DIR)
277 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700278 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800279 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700280 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800281 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700282 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800283 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
284 )
285 $(if $(1),\
286 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
287 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
288 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
289 done; \
290 )
Colin Cross4f60e362019-06-05 11:53:43 -0700291 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
292 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700293 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
294 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700295endef
296
Steve Muckle474e4d02019-06-19 12:56:48 -0700297# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700298# $(2): modules list
299# $(3): module load list
300# $(4): module load list filename
301# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700302define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700303 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
304 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700305endef
306
307# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700308# $(2): modules list
309# $(3): module load list
310# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700311define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700312$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
313$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
314 @echo load-list $$(@)
315 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700316endef
317
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800318# $(1): source blocklist file
319# $(2): destination pathname
320# Returns a build rule that checks the syntax of and installs a kernel modules
321# blocklist file. Strip and squeeze any extra space in the blocklist.
322# For use via $(eval).
323define build-image-kernel-modules-blocklist-file
324$(2): $(1)
325 @echo "modprobe blocklist $$(@)"
326 $(hide) mkdir -p "$$(dir $$@)"
327 $(hide) rm -f "$$@"
328 $(hide) awk <"$$<" >"$$@" \
329 '/^#/ { print; next } \
330 NF == 0 { next } \
331 NF != 2 || $$$$1 != "blocklist" \
332 { print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
333 exit_status = 1; next } \
334 { $$$$1 = $$$$1; print } \
335 END { exit exit_status }'
336endef
337
Steve Muckle2335d762020-05-28 18:39:38 -0700338# $(1): image name
339# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
340# $(3): mount point
341# $(4): module load filename
342# $(5): stripped staging directory
343# $(6): kernel module directory name (top is an out of band value for no directory)
344define build-image-kernel-modules-dir
345$(if $(filter top,$(6)),\
346 $(eval _kver :=)$(eval _sep :=),\
347 $(eval _kver := $(6))$(eval _sep :=_))\
348$(if $(5),\
349 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
350 $(eval _stripped_staging_dir :=))\
351$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
352 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
353 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
Yi-Yo Chiangc12dd842021-02-04 23:20:15 +0800354 $(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)))) \
355$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
356 $(eval $(call build-image-kernel-modules-blocklist-file, \
357 $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
358 $(2)/lib/modules/modules.blocklist)) \
359 $(2)/lib/modules/modules.blocklist)
Steve Muckle2335d762020-05-28 18:39:38 -0700360endef
361
362# $(1): kernel module directory name (top is an out of band value for no directory)
363define build-recovery-as-boot-load
364$(if $(filter top,$(1)),\
365 $(eval _kver :=)$(eval _sep :=),\
366 $(eval _kver := $(1))$(eval _sep :=_))\
367 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
368 $(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))))
369endef
370
371# $(1): kernel module directory name (top is an out of band value for no directory)
372define build-vendor-ramdisk-recovery-load
373$(if $(filter top,$(1)),\
374 $(eval _kver :=)$(eval _sep :=),\
375 $(eval _kver := $(1))$(eval _sep :=_))\
376 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
377 $(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))))
378endef
379
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700380# $(1): kernel module directory name (top is an out of band value for no directory)
381define build-vendor-charger-load
382$(if $(filter top,$(1)),\
383 $(eval _kver :=)$(eval _sep :=),\
384 $(eval _kver := $(1))$(eval _sep :=_))\
385 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
386 $(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))))
387endef
388
Steve Mucklee1b10862019-07-10 10:49:37 -0700389ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
390 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
391 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700392 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700393 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
394endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700395
Steve Muckle69280d22019-07-11 12:23:38 -0700396ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
397 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700398endif
399
Steve Mucklee1b10862019-07-10 10:49:37 -0700400ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700401 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700402 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700403 endif
404endif
405
J. Avilaa2ceec62020-05-12 23:40:02 +0000406ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
407 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
408else
409 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
410endif
Colin Cross4f60e362019-06-05 11:53:43 -0700411
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700412ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
413 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
414else
415 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
416endif
417
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800418# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
419$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
420 $(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
421 $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
422 $(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))) \
423 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-dlkm-$(vendor_ramdisk_fragment))) \
424 $(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
425 $(foreach dir,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
426 $(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(dir)) \
427 $(if $($(kmd_vrf)),$(error Kernel module directory "$(dir)" 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)) \
428 $(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
429 ) \
430)
431
Steve Muckle2335d762020-05-28 18:39:38 -0700432BOARD_KERNEL_MODULE_DIRS += top
433$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
434 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(dir))) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +0800435 $(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(dir))) \
436 $(if $(vendor_ramdisk_fragment), \
437 $(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
438 $(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
439 $(eval ### else ###), \
440 $(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
441 $(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
442 $(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700443 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
Yifan Honge51dff22020-06-23 17:26:57 -0700444 $(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),$(dir))) \
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700445 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Yifan Hong3d5e2c22020-07-15 17:01:14 -0700446 $(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,,$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700447 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
448 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
449 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,,$(dir)))))
Colin Cross4f60e362019-06-05 11:53:43 -0700450
451# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800452# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700453# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900454# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700455# $2 certificate
456# $3 private key
457# $4 compressed
458# $5 partition tag
459# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100460define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700461$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
462$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
463$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
464$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700465
466endef
467
Jaewoong Jung704b4542020-06-29 19:37:53 -0700468# -----------------------------------------------------------------
469# Merge an individual apkcerts output into the final apkcerts.txt output.
470# Use a macro to make it compatible with _apkcerts_write_line
471# $1 apkcerts file to be merged
472# $2 output file
473define _apkcerts_merge
474$(hide) cat $1 >> $2
475
476endef
477
The Android Open Source Project88b60792009-03-03 19:28:42 -0800478name := $(TARGET_PRODUCT)
479ifeq ($(TARGET_BUILD_TYPE),debug)
480 name := $(name)_debug
481endif
482name := $(name)-apkcerts-$(FILE_NAME_TAG)
483intermediates := \
484 $(call intermediates-dir-for,PACKAGING,apkcerts)
485APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700486all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
487$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800488# We don't need to really build all the modules.
489# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700490$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800491 @echo APK certs list: $@
492 @mkdir -p $(dir $@)
493 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700494 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700495 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
496 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
497 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
Jaewoong Jung7b634d32020-10-23 14:02:16 -0700498 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700499 $(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 -0700500 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700501 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800502
503.PHONY: apkcerts-list
504apkcerts-list: $(APKCERTS_FILE)
505
Ying Wang15e487a2011-02-15 10:56:18 -0800506ifneq (,$(TARGET_BUILD_APPS))
507 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900508 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800509endif
Ying Wangefb21682010-07-23 16:42:13 -0700510
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900511
The Android Open Source Project88b60792009-03-03 19:28:42 -0800512# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700513# build system stats
514BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
515$(BUILD_SYSTEM_STATS):
516 @rm -f $@
517 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
518 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
519$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700520
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700521# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800522# build /product/etc/security/avb/system_other.avbpubkey if needed
523ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800524ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800525INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
526ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800527endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800528endif # BUILDING_SYSTEM_OTHER_IMAGE
529
530# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700531# Modules ready to be converted to Soong, ordered by how many
532# modules depend on them.
533SOONG_CONV := $(sort $(SOONG_CONV))
534SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
535$(SOONG_CONV_DATA):
536 @rm -f $@
Joe Onorato02fb89a2020-06-27 00:10:23 -0700537 @$(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 -0700538
Colin Crossfdea8932017-12-06 14:38:40 -0800539SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700540SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
541$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
542 @rm -f $@
543 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
544$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
545
Joe Onorato02fb89a2020-06-27 00:10:23 -0700546MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
547MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
548$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
549$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
550 @rm -f $@
551 $(hide) $(MK2BP_CATALOG_SCRIPT) \
552 --device=$(TARGET_DEVICE) \
553 --title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
554 --codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
555 --out_dir="$(OUT_DIR)" \
Joe Onorato31986072020-08-10 09:58:49 -0700556 --mode=html \
Joe Onorato02fb89a2020-06-27 00:10:23 -0700557 > $@
558$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_HTML))
559
Joe Onorato31986072020-08-10 09:58:49 -0700560MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
561$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT)
562 @rm -f $@
563 $(hide) $(MK2BP_CATALOG_SCRIPT) \
564 --device=$(TARGET_DEVICE) \
565 --out_dir="$(OUT_DIR)" \
566 --mode=csv \
567 > $@
568$(call dist-for-goals,droidcore,$(MK2BP_REMAINING_CSV))
569
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700570# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800571# Modules use -Wno-error, or added default -Wall -Werror
572WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
573$(WALL_WERROR):
574 @rm -f $@
575 echo "# Modules using -Wno-error" >> $@
576 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 -0800577 echo "# Modules added default -Wall" >> $@
578 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
579
580$(call dist-for-goals,droidcore,$(WALL_WERROR))
581
582# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700583# C/C++ flag information for modules
584$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
585
586# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800587# Modules missing profile files
588PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
589$(PGO_PROFILE_MISSING):
590 @rm -f $@
591 echo "# Modules missing PGO profile files" >> $@
592 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
593
594$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
595
Anton Hanssoncd8fa362020-12-08 20:56:02 +0000596CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
597$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
598 rm -f $@
599 $(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
600$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
601
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800602# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700603# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700604# for future OTA packages installed by this system. Actual product
605# deliverables will be re-signed by hand. We expect this file to
606# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700607DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700608
609
Jeff Browne33ba4c2011-07-11 22:11:46 -0700610# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800611# if they don't do anything.
612.PHONY: systemimage
613systemimage:
614
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800615# -----------------------------------------------------------------
616
617.PHONY: event-log-tags
618
Joe Onoratob7510532010-07-14 10:22:54 -0700619# Produce an event logs tag file for everything we know about, in order
620# to properly allocate numbers. Then produce a file that's filtered
621# for what's going to be installed.
622
623all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
624
Colin Crossdc8f8e42012-04-12 13:25:54 -0700625event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
626
Joe Onoratob7510532010-07-14 10:22:54 -0700627# Include tags from all packages that we know about
628all_event_log_tags_src := \
629 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
630
Dan Willemsena3f66322020-05-28 15:46:33 -0700631$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src)
632$(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 -0700633 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900634 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700635
Doug Zongkera34fa952011-02-23 12:17:29 -0800636# Include tags from all packages included in this product, plus all
637# tags that are part of the system (ie, not in a vendor/ or device/
638# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800639event_log_tags_src := \
640 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800641 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800642 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800643 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
644 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800645
Dan Willemsena3f66322020-05-28 15:46:33 -0700646$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
Joe Onoratob7510532010-07-14 10:22:54 -0700647$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Dan Willemsena3f66322020-05-28 15:46:33 -0700648$(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 -0800649 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900650 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800651
652event-log-tags: $(event_log_tags_file)
653
654ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
655
Joe Onoratob7510532010-07-14 10:22:54 -0700656
The Android Open Source Project88b60792009-03-03 19:28:42 -0800657# #################################################################
658# Targets for boot/OS images
659# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800660ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
661 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
Ram Muthiah0c4a3522020-08-27 00:54:13 +0000662 ifdef BOARD_PREBUILT_BOOTLOADER
663 $(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
664 $(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
665 endif # BOARD_PREBUILT_BOOTLOADER
Ying Wangc6349742014-01-13 16:14:20 -0800666 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
667 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
668 else
669 INSTALLED_2NDBOOTLOADER_TARGET :=
670 endif
671else
672 INSTALLED_BOOTLOADER_MODULE :=
673 INSTALLED_2NDBOOTLOADER_TARGET :=
674endif # TARGET_NO_BOOTLOADER
675ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700676 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
677 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
678 $(PRODUCT_OUT)/$(k))
679 else
680 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
681 endif
Ying Wangc6349742014-01-13 16:14:20 -0800682else
683 INSTALLED_KERNEL_TARGET :=
684endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800685
686# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700687# the root dir
688INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800689 $(ALL_GENERATED_SOURCES) \
690 $(ALL_DEFAULT_INSTALLED_MODULES))
691
Luis Hector Chavezff489932018-07-03 15:41:40 -0700692INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
693INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
694$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700695$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700696 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800697 mkdir -p $(dir $@)
698 rm -f $@
699 $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
700 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700701
702$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
703
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800704#------------------------------------------------------------------
705# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700706ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800707INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700708ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800709$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800710 cat $^ > $@
711endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700712endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800713
Tom Cherryd14b8952018-08-09 14:26:00 -0700714# -----------------------------------------------------------------
715# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800716ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700717INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
718 $(ALL_GENERATED_SOURCES) \
719 $(ALL_DEFAULT_INSTALLED_MODULES))
720
721INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
722INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
723$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700724$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700725 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -0800726 mkdir -p $(TARGET_RAMDISK_OUT)
727 mkdir -p $(dir $@)
728 rm -f $@
729 $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
730 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700731
732$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700733BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
734
J. Avila3f6560e2020-05-11 20:20:03 +0000735ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
736# -l enables the legacy format used by the Linux kernel
737COMPRESSION_COMMAND_DEPS := $(LZ4)
738COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
739RAMDISK_EXT := .lz4
740else
741COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
742COMPRESSION_COMMAND := $(MINIGZIP)
743RAMDISK_EXT := .gz
744endif
745
Joe Onorato64d85d02009-04-09 19:31:12 -0700746# We just build this directly to the install location.
747INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000748$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -0800749 $(call pretty,"Target ramdisk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000750 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800751
Ying Wangad7fd292013-08-08 16:34:29 -0700752.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000753ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700754 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000755 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800756
Dan Willemsen67495202019-01-16 12:42:05 -0800757endif # BUILDING_RAMDISK_IMAGE
758
The Android Open Source Project88b60792009-03-03 19:28:42 -0800759# -----------------------------------------------------------------
760# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700761
762# This is defined here since we may be building recovery as boot
763# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700764ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
765 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
766else
767 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
768endif
769
Yifan Hong0674a6e2020-10-22 14:37:01 -0700770INTERNAL_PREBUILT_BOOTIMAGE :=
771
772my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
773ifdef my_installed_prebuilt_gki_apex
774 ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
775 $(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
776 endif # len(my_installed_prebuilt_gki_apex) > 1
777
778 ifdef BOARD_PREBUILT_BOOTIMAGE
779 $(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
780 endif # BOARD_PREBUILT_BOOTIMAGE defined
781
782 my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
783 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
784 $(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
785
786 INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
787
788else # my_installed_prebuilt_gki_apex not defined
789
Steve Muckle04b6f052020-08-09 14:36:56 -0700790# $1: boot image target
791# returns the kernel used to make the bootimage
792define bootimage-to-kernel
793 $(if $(BOARD_KERNEL_BINARIES),\
794 $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
795 $(INSTALLED_KERNEL_TARGET))
796endef
797
Steve Muckle903a1ca2020-05-07 17:32:10 -0700798ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
799 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
800endif
801
802# $1: boot image file name
Bowgo Tsaif85e68f2021-03-04 14:41:16 +0800803# $2: boot image variant (boot, boot-debug, boot-test-harness)
Steve Muckle903a1ca2020-05-07 17:32:10 -0700804define get-bootimage-partition-size
805 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
806endef
Chris Grossa784ef12019-04-22 11:09:57 -0700807
808ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800809INTERNAL_BOOTIMAGE_ARGS := \
Steve Muckle04b6f052020-08-09 14:36:56 -0700810 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700811
812ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
813INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
814endif
815
Steve Mucklee1b10862019-07-10 10:49:37 -0700816ifndef BUILDING_VENDOR_BOOT_IMAGE
817ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
818 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
819endif
820endif
821
The Android Open Source Project88b60792009-03-03 19:28:42 -0800822INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
823
Anton Hansson8dab0a62019-03-28 15:45:40 +0000824ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700825ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000826VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700827 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
828endif
829endif
830
Anton Hansson72e36f02019-02-26 17:36:30 +0000831INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700832
Yifan Hong46aff092020-10-28 13:50:47 -0700833# kernel cmdline/base/pagesize in boot.
834# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
835# device-specific.
836# - If not using GKI:
837# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
838# - Otherwise, put them in boot.
839ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -0700840 ifdef GENERIC_KERNEL_CMDLINE
841 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
842 endif
Yifan Hong46aff092020-10-28 13:50:47 -0700843else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
844 ifdef INTERNAL_KERNEL_CMDLINE
845 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
846 endif
847 ifdef BOARD_KERNEL_BASE
848 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
849 endif
850 ifdef BOARD_KERNEL_PAGESIZE
851 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
852 endif
853endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700854
Sami Tolvanen3303d902016-03-15 16:49:30 +0000855INTERNAL_MKBOOTIMG_VERSION_ARGS := \
Dianne Hackborn25648e62019-10-22 15:58:17 -0700856 --os_version $(PLATFORM_VERSION_LAST_STABLE) \
Sami Tolvanen3303d902016-03-15 16:49:30 +0000857 --os_patch_level $(PLATFORM_SECURITY_PATCH)
858
Chris Grossa784ef12019-04-22 11:09:57 -0700859# Define these only if we are building boot
860ifdef BUILDING_BOOT_IMAGE
861INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
862
The Android Open Source Project88b60792009-03-03 19:28:42 -0800863ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800864$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700865endif # TARGET_BOOTIMAGE_USE_EXT2
David Zeuthen0eb10972016-09-28 17:55:27 -0400866
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700867$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
868
869ifeq (true,$(BOARD_AVB_ENABLE))
David Zeuthen0eb10972016-09-28 17:55:27 -0400870
Steve Muckle04b6f052020-08-09 14:36:56 -0700871# $1: boot image target
872define build_boot_board_avb_enabled
873 $(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 -0700874 $(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 -0700875 $(AVBTOOL) add_hash_footer \
876 --image $(1) \
Yifan Hongebe65f82020-10-15 14:48:07 -0700877 --partition_size $(call get-bootimage-partition-size,$(1),boot) \
Steve Muckle04b6f052020-08-09 14:36:56 -0700878 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
879 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
880endef
881
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700882$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400883 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700884 $(call build_boot_board_avb_enabled,$@)
David Zeuthen0eb10972016-09-28 17:55:27 -0400885
886.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800887bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400888 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700889 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400890
Anton Hansson8dab0a62019-03-28 15:45:40 +0000891else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700892
Steve Muckle04b6f052020-08-09 14:36:56 -0700893# $1: boot image target
894define build_boot_supports_boot_signer
895 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
896 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)
Yifan Hongebe65f82020-10-15 14:48:07 -0700897 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700898endef
899
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700900$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
Geremy Condra740b6632014-07-08 20:07:41 -0700901 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700902 $(call build_boot_supports_boot_signer,$@)
Geremy Condra740b6632014-07-08 20:07:41 -0700903
904.PHONY: bootimage-nodeps
905bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
906 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700907 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_boot_signer,$(b)))
Geremy Condra740b6632014-07-08 20:07:41 -0700908
Anton Hansson8dab0a62019-03-28 15:45:40 +0000909else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800910
Steve Muckle04b6f052020-08-09 14:36:56 -0700911# $1: boot image target
912define build_boot_supports_vboot
913 $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
914 $(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 -0700915 $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700916endef
917
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700918$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800919 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700920 $(call build_boot_supports_vboot,$@)
David Riley17be3d32015-03-03 08:54:11 -0800921
922.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800923bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800924 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700925 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
David Riley17be3d32015-03-03 08:54:11 -0800926
927else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800928
Steve Muckle04b6f052020-08-09 14:36:56 -0700929# $1: boot image target
930define build_boot_novboot
931 $(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 -0700932 $(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
Steve Muckle04b6f052020-08-09 14:36:56 -0700933endef
934
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700935$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800936 $(call pretty,"Target boot image: $@")
Steve Muckle04b6f052020-08-09 14:36:56 -0700937 $(call build_boot_novboot,$@)
Ying Wangad7fd292013-08-08 16:34:29 -0700938
939.PHONY: bootimage-nodeps
940bootimage-nodeps: $(MKBOOTIMG)
941 @echo "make $@: ignoring dependencies"
Steve Muckle04b6f052020-08-09 14:36:56 -0700942 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
Ying Wangad7fd292013-08-08 16:34:29 -0700943
Yifan Hong3e0b5d02020-09-29 21:18:20 -0700944endif # BOARD_AVB_ENABLE
Chris Grossa784ef12019-04-22 11:09:57 -0700945endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800946
Tao Baob1a2e352018-08-14 16:17:12 -0700947else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700948ifdef BOARD_PREBUILT_BOOTIMAGE
949ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
950# Remove when b/63676296 is resolved.
951$(error Prebuilt bootimage is only supported for AB targets)
952endif
Yifan Hong0674a6e2020-10-22 14:37:01 -0700953INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
Kiyoung Kim62e22312019-06-20 14:27:45 +0900954INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Yifan Hong0674a6e2020-10-22 14:37:01 -0700955$(eval $(call copy-one-file,$(INTERNAL_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700956else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700957INSTALLED_BOOTIMAGE_TARGET :=
958endif # BOARD_PREBUILT_BOOTIMAGE
959endif # TARGET_NO_KERNEL
Yifan Hong0674a6e2020-10-22 14:37:01 -0700960endif # my_installed_prebuilt_gki_apex not defined
961
962my_apex_extracted_boot_image :=
963my_installed_prebuilt_gki_apex :=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800964
965# -----------------------------------------------------------------
Yifan Hong881df392020-10-09 14:29:39 -0700966# declare recovery ramdisk files
967ifeq ($(BUILDING_RECOVERY_IMAGE),true)
968INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
969endif
970
971# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700972# vendor boot image
973ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
974
975ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
976 $(error vboot 1.0 does not support vendor_boot partition)
977endif
978
979INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
980 $(ALL_GENERATED_SOURCES) \
981 $(ALL_DEFAULT_INSTALLED_MODULES))
982
Petri Gynther6a6d6212021-03-06 00:45:53 -0800983INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
Yifan Hong881df392020-10-09 14:29:39 -0700984
985ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
986$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
987$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
988endif
989
J. Avila3f6560e2020-05-11 20:20:03 +0000990$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Yifan Hong881df392020-10-09 14:29:39 -0700991 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700992
Petri Gynther828828b2021-03-04 11:04:03 -0800993ifeq (true,$(BOARD_BUILD_VENDOR_RAMDISK_IMAGE))
994INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
995$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
Petri Gynther4c063e32021-03-06 13:26:01 -0800996 $(call pretty,"Target vendor ramdisk: $@")
Petri Gynther828828b2021-03-04 11:04:03 -0800997 $(copy-file-to-target)
998endif
999
Petri Gynther6ff52012020-11-20 11:59:41 -08001000INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
1001INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
1002$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
1003$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
1004$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08001005 @echo Installed file list: $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001006 mkdir -p $(dir $@)
1007 rm -f $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001008 $(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
1009 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Petri Gynther6ff52012020-11-20 11:59:41 -08001010
Steve Mucklee1b10862019-07-10 10:49:37 -07001011ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1012 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1013endif
1014ifdef BOARD_KERNEL_BASE
1015 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1016endif
1017ifdef BOARD_KERNEL_PAGESIZE
1018 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1019endif
1020ifdef INTERNAL_KERNEL_CMDLINE
1021 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
1022endif
1023
Devin Moore50509012021-01-13 10:45:04 -08001024ifdef INTERNAL_BOOTCONFIG
1025INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
1026$(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
1027 rm -f $@
1028 $(foreach param,$(INTERNAL_BOOTCONFIG), \
1029 printf "%s\n" $(param) >> $@;)
1030 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
1031endif
1032
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001033# $(1): Build target name
1034# $(2): Staging dir to be compressed
1035# $(3): Build dependencies
1036define build-vendor-ramdisk-fragment-target
1037$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
1038 $(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
1039endef
1040
1041# $(1): Ramdisk name
1042define build-vendor-ramdisk-fragment
1043$(strip \
1044 $(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
1045 $(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
1046 $(build_target) \
1047)
1048endef
1049
1050# $(1): Ramdisk name
1051# $(2): Prebuilt file path
1052define build-prebuilt-vendor-ramdisk-fragment
1053$(strip \
1054 $(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
1055 $(eval $(call copy-one-file,$(2),$(build_target))) \
1056 $(build_target) \
1057)
1058endef
1059
1060INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
1061INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
1062
1063$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
1064 $(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
1065 $(if $(prebuilt_vendor_ramdisk_fragment_file), \
1066 $(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
1067 $(eval ### else ###), \
1068 $(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment))) \
1069 $(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
1070 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
Yo Chiang68ab6262021-01-19 18:14:59 +08001071 $(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
1072 $(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
1073 $(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001074 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
1075 $(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
1076)
1077
Steve Mucklee1b10862019-07-10 10:49:37 -07001078INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
1079$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
Devin Moore50509012021-01-13 10:45:04 -08001080$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
Steve Mucklee1b10862019-07-10 10:49:37 -07001081ifeq ($(BOARD_AVB_ENABLE),true)
1082$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
1083 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001084 $(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 -07001085 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1086 $(AVBTOOL) add_hash_footer \
1087 --image $@ \
1088 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
1089 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
1090 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
1091else
1092$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
1093 $(call pretty,"Target vendor_boot image: $@")
Yo Chiangd21e7dc2020-12-10 18:42:47 +08001094 $(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 -07001095 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
1096endif
1097endif # BUILDING_VENDOR_BOOT_IMAGE
1098
1099# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08001100# NOTICE files
1101#
Steve Blockd14d3b42012-03-01 11:34:41 +00001102# We are required to publish the licenses for all code under BSD, GPL and
1103# Apache licenses (and possibly other more exotic ones as well). We err on the
1104# side of caution, so the licenses for other third-party code are included here
1105# too.
1106#
The Android Open Source Project88b60792009-03-03 19:28:42 -08001107# This needs to be before the systemimage rules, because it adds to
1108# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
1109# go into the systemimage.
1110
Steve Block495e5852012-02-29 19:18:08 +00001111.PHONY: notice_files
1112
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001113# Create the rule to combine the files into text and html/xml forms
Yifan Hongc83f9e92020-07-15 16:57:47 -07001114# $(1) - xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm|
1115# xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm|
1116# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|
1117# xml_odm_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001118# $(2) - Plain text output file
1119# $(3) - HTML/XML output file
1120# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -07001121# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -08001122# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001123# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -08001124# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -08001125#
1126# The algorithm here is that we go collect a hash for each of the notice
1127# files and write the names of the files that match that hash. Then
1128# to generate the real files, we go print out all of the files and their
1129# hashes.
1130#
1131# These rules are fairly complex, so they depend on this makefile so if
1132# it changes, they'll run again.
1133#
1134# TODO: We could clean this up so that we just record the locations of the
1135# original notice files instead of making rules to copy them somwehere.
1136# Then we could traverse that without quite as much bash drama.
1137define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -07001138$(2): PRIVATE_MESSAGE := $(4)
1139$(2): PRIVATE_DIR := $(5)
1140$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
1141$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -08001142 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hongc83f9e92020-07-15 16:57:47 -07001143 $(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, \
1144 $(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 +00001145 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +09001146 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -07001147 $(if $(filter $(1),xml_system),-i system --xml-output, \
1148 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001149 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001150 $(if $(filter $(1),xml_odm_dlkm),-i odm_dlkm --xml-output, \
1151 --html-output)))))))) $(3) \
Bob Badour5e9e1fb2020-07-17 20:47:42 -07001152 -t $$(PRIVATE_MESSAGE) $$(foreach dir,$$(sort $$(PRIVATE_DIR)), -s $$(dir)/src)
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001153notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001154endef
1155
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001156# Notice file logic isn't relevant for TARGET_BUILD_APPS
1157ifndef TARGET_BUILD_APPS
1158
The Android Open Source Project88b60792009-03-03 19:28:42 -08001159# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
1160# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
1161# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +00001162target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +00001163tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001164tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001165kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
1166winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08001167
Bob Badour4b25c902020-01-28 13:23:39 -08001168# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
1169# reasons--not to be flashed onto any device. Targets under these directories
1170# need no associated notice file on the device UI.
1171exclude_target_dirs := apex
1172
Steven Morelandae69e572017-12-15 14:49:55 -08001173# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001174ifneq ($(PRODUCT_NOTICE_SPLIT),true)
1175target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
1176target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
1177installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
1178$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001179 $(target_notice_file_txt), \
1180 $(target_notice_file_html), \
1181 "Notices for files contained in the filesystem images in this directory:", \
1182 $(TARGET_OUT_NOTICE_FILES), \
Dan Willemsena3f66322020-05-28 15:46:33 -07001183 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file), \
Bob Badour4b25c902020-01-28 13:23:39 -08001184 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001185$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
1186 $(hide) $(MINIGZIP) -9 < $< > $@
1187$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
1188 $(copy-file-to-target)
1189else
1190target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
1191target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001192installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
1193
1194target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
1195target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
1196target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
1197installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +01001198
1199target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
1200target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
1201target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
1202installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +01001203
Justin Yun6151e3f2019-06-25 15:58:13 +09001204target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
1205target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
1206target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
1207installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001208
Chris Gross15d96552019-07-16 14:38:43 -07001209target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
1210target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
1211target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
1212installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
1213
Yifan Hong3d3f0302020-05-11 18:35:11 -07001214target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
1215target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
1216target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
1217installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
1218
Yifan Hongc83f9e92020-07-15 16:57:47 -07001219target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
1220target_odm_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml
1221target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
1222installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
1223
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001224# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
1225# being built. A notice xml file must depend on all modules that could potentially
1226# install a license file relevant to it.
Dan Willemsena3f66322020-05-28 15:46:33 -07001227license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
Bob Badour4b25c902020-01-28 13:23:39 -08001228# Only files copied to a system image need system image notices.
1229license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001230# Phonys/fakes don't have notice files (though their deps might)
1231license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001232# testcases are not relevant to the system image.
1233license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001234# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001235license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Jeongik Cha99175202020-06-17 17:10:19 +09001236# system_other is relevant to system partition.
1237license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001238license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1239license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001240license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001241license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001242license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001243license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001244license_modules_agg := $(license_modules_system) \
1245 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001246 $(license_modules_product) \
1247 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001248 $(license_modules_odm) \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001249 $(license_modules_vendor_dlkm) \
1250 $(license_modules_odm_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001251# targets used for debug symbols only and do not get copied to the device
1252license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1253
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001254license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001255license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1256
1257# Identify the other targets we expect to have notices for:
1258# targets copied to the device but are not readable by the UI (e.g. must boot
1259# into a different partition to read or don't have an associated /etc
1260# directory) must have their notices built somewhere readable.
1261license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1262license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1263license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1264license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1265license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1266license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
Petri Gyntherdc24d882021-03-02 23:54:08 -08001267license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
Bob Badour4b25c902020-01-28 13:23:39 -08001268license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1269license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1270license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1271license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1272license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1273license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1274
1275# after removing targets in system images, targets reported in system images, and
1276# targets used for debug symbols that do not need notices, nothing must remain.
1277license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1278$(call maybe-print-list-and-error, $(license_modules_rest), \
1279 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001280
Chris Grossaad39b32019-06-13 09:43:26 -07001281# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1282# update its notice file, so include those notices in the system partition instead
1283ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001284license_modules_system += $(license_modules_rehomed)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001285system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
1286system_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 -07001287else
Bob Badour4b25c902020-01-28 13:23:39 -08001288license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001289system_xml_directories := xml_system
1290system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001291endif
1292
1293$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001294 $(target_notice_file_txt), \
1295 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001296 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001297 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001298 $(license_modules_system), \
1299 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001300$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm_odm_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001301 $(target_vendor_notice_file_txt), \
1302 $(target_vendor_notice_file_xml), \
Yifan Hongc83f9e92020-07-15 16:57:47 -07001303 "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 +00001304 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001305 $(license_modules_vendor), \
1306 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001307$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001308 $(target_product_notice_file_txt), \
1309 $(target_product_notice_file_xml), \
1310 "Notices for files contained in the product filesystem image in this directory:", \
1311 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001312 $(license_modules_product), \
1313 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001314$(eval $(call combine-notice-files, xml_system_ext, \
1315 $(target_system_ext_notice_file_txt), \
1316 $(target_system_ext_notice_file_xml), \
1317 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001318 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001319 $(license_modules_system_ext), \
1320 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001321$(eval $(call combine-notice-files, xml_odm, \
1322 $(target_odm_notice_file_txt), \
1323 $(target_odm_notice_file_xml), \
1324 "Notices for files contained in the odm filesystem image in this directory:", \
1325 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001326 $(license_modules_odm), \
1327 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001328$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1329 $(target_vendor_dlkm_notice_file_txt), \
1330 $(target_vendor_dlkm_notice_file_xml), \
1331 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1332 $(TARGET_OUT_NOTICE_FILES), \
1333 $(license_modules_vendor_dlkm), \
1334 $(exclude_target_dirs)))
Yifan Hongc83f9e92020-07-15 16:57:47 -07001335$(eval $(call combine-notice-files, xml_odm_dlkm, \
1336 $(target_odm_dlkm_notice_file_txt), \
1337 $(target_odm_dlkm_notice_file_xml), \
1338 "Notices for files contained in the odm_dlkm filesystem image in this directory:", \
1339 $(TARGET_OUT_NOTICE_FILES), \
1340 $(license_modules_odm_dlkm), \
1341 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001342
1343$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1344 $(hide) $(MINIGZIP) -9 < $< > $@
1345$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1346 $(hide) $(MINIGZIP) -9 < $< > $@
1347$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1348 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001349$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001350 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001351$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1352 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001353$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1354 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hongc83f9e92020-07-15 16:57:47 -07001355$(target_odm_dlkm_notice_file_xml_gz): $(target_odm_dlkm_notice_file_xml) | $(MINIGZIP)
1356 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001357$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1358 $(copy-file-to-target)
1359$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1360 $(copy-file-to-target)
1361$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1362 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001363$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001364 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001365$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1366 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001367$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1368 $(copy-file-to-target)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001369$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
1370 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001371
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001372ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1373ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1374ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1375ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1376ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001377ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Yifan Hongc83f9e92020-07-15 16:57:47 -07001378ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001379endif # PRODUCT_NOTICE_SPLIT
1380
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001381ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001382
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001383$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001384 $(tools_notice_file_txt), \
1385 $(tools_notice_file_html), \
1386 "Notices for files contained in the tools directory:", \
1387 $(HOST_OUT_NOTICE_FILES), \
1388 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001389 $(winpthreads_notice_file), \
1390 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001391
Ying Wang62c81f82013-08-22 20:02:03 -07001392endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001393
1394# The kernel isn't really a module, so to get its module file in there, we
1395# make the target NOTICE files depend on this particular file too, which will
1396# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001397$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001398
Dan Willemsen288bedf2019-05-28 15:36:47 -07001399$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001400
Doug Zongker8678df42009-06-15 14:30:14 -07001401
The Android Open Source Project88b60792009-03-03 19:28:42 -08001402# #################################################################
1403# Targets for user images
1404# #################################################################
1405
Ying Wang933abf12010-06-16 14:31:34 -07001406INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001407ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001408INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1409else
1410ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001411INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1412else
1413ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001414INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1415endif
1416endif
1417endif
1418
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001419# These options tell the recovery updater/installer how to mount the partitions writebale.
1420# <fstype>=<fstype_opts>[|<fstype_opts>]...
1421# fstype_opts := <opt>[,<opt>]...
1422# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001423# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1424DEFAULT_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 -07001425
Ying Wang542903a2010-11-17 15:40:38 -08001426ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1427 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1428endif
Gao Xiang961041a2020-06-17 13:59:16 +08001429ifneq (true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED))
1430 INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG := -s
1431endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001432ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1433 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1434endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001435ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1436 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1437endif
Tao Baodba635a2019-06-24 10:39:54 -07001438
1439INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001440 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001441 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001442 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001443
1444ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1445INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001446endif
1447
Yifan Hongcfb917a2020-05-07 14:58:20 -07001448ifneq ($(filter \
1449 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1450 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1451 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1452 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1453 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1454 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07001455 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Gao Xiang961041a2020-06-17 13:59:16 +08001456 ,erofs),)
1457INTERNAL_USERIMAGES_DEPS += $(MKEROFSUSERIMG)
1458endif
1459
1460ifneq ($(filter \
1461 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1462 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1463 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1464 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1465 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1466 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1467 $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07001468 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001469INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1470endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001471
Anton Hansson8dab0a62019-03-28 15:45:40 +00001472ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001473INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001474ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001475INTERNAL_USERIMAGES_DEPS += $(FEC)
1476endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001477endif
1478
Tao Baodba635a2019-06-24 10:39:54 -07001479ifeq ($(BOARD_AVB_ENABLE),true)
1480INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1481endif
1482
1483# Get a colon-separated list of search paths.
1484INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1485
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001486# Collects file_contexts files from modules to be installed
1487$(call merge-fc-files, \
1488 $(sort $(foreach m,$(product_MODULES),$(ALL_MODULES.$(m).FILE_CONTEXTS))),\
1489 $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.modules.tmp)
1490
Alex Klyubin092c9022017-03-13 13:28:34 -07001491SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Jooyung Hanb27c2e82020-09-23 19:15:20 +09001492
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001493INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1494
Yifan Hongc5c01242018-11-09 10:27:23 -08001495ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001496
Anton Hansson8dab0a62019-03-28 15:45:40 +00001497ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001498 $(error vboot 1.0 doesn't support logical partition)
1499endif
1500
Yifan Hongc5c01242018-11-09 10:27:23 -08001501endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001502
Ying Wangbd93d422011-10-28 17:02:30 -07001503# $(1): the path of the output dictionary file
Yifan Hongf496f1b2020-07-15 16:52:59 -07001504# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001505# $(3): additional "key=value" pairs to append to the dictionary file.
1506define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001507$(if $(filter $(2),system),\
1508 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001509 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001510 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
Robin Hsu3e51f422020-11-04 09:29:09 +08001511 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "system_fs_compress=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_COMPRESS)" >> $(1))
1512 $(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 -07001513 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1514 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1515 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1516 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1517 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1518 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1519 $(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 +00001520 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1521 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001522 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001523 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001524 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1525)
1526$(if $(filter $(2),system_other),\
1527 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001528)
Yifan Hong760d3c02018-05-30 11:16:46 -07001529$(if $(filter $(2),userdata),\
1530 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1531 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001532 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1533 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Jaegeuk Kimed754fb2020-10-12 19:50:05 -07001534 $(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001535 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001536 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001537)
Yifan Hong760d3c02018-05-30 11:16:46 -07001538$(if $(filter $(2),cache),\
1539 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1540 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001541 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001542 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001543)
1544$(if $(filter $(2),vendor),\
1545 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1546 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1547 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1548 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1549 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1550 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1551 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1552 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1553 $(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 +00001554 $(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 -07001555 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001556 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001557 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001558)
1559$(if $(filter $(2),product),\
1560 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1561 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1562 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1563 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1564 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1565 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1566 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1567 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1568 $(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 +00001569 $(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 -07001570 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001571 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001572 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001573)
Justin Yun6151e3f2019-06-25 15:58:13 +09001574$(if $(filter $(2),system_ext),\
1575 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1576 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1577 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1578 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1579 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1580 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1581 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1582 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1583 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1584 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1585 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001586 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001587)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001588$(if $(filter $(2),odm),\
1589 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1590 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1591 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1592 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1593 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1594 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1595 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1596 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1597 $(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 +00001598 $(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 +08001599 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001600 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001601 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001602)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001603$(if $(filter $(2),vendor_dlkm),\
1604 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1605 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1606 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1607 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1608 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1609 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1610 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1611 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1612 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1613 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1614 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1615 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1616)
Yifan Hongf496f1b2020-07-15 16:52:59 -07001617$(if $(filter $(2),odm_dlkm),\
1618 $(if $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_dlkm_fs_type=$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1619 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_dlkm_extfs_inode_count=$(BOARD_ODM_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1620 $(if $(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_dlkm_extfs_rsv_pct=$(BOARD_ODM_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1621 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "odm_dlkm_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1622 $(if $(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_dlkm_journal_size=$(BOARD_ODM_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1623 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_dlkm_squashfs_compressor=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1624 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_dlkm_squashfs_compressor_opt=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1625 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_dlkm_squashfs_block_size=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1626 $(if $(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "odm_dlkm_squashfs_disable_4k_align=$(BOARD_ODM_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1627 $(if $(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_dlkm_reserved_size=$(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1628 $(hide) echo "odm_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1629 $(hide) echo "building_odm_dlkm_image=$(BUILDING_ODM_DLKM_IMAGE)" >> $(1)
1630)
Yifan Hong760d3c02018-05-30 11:16:46 -07001631$(if $(filter $(2),oem),\
1632 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1633 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1634 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1635 $(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 -07001636 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001637)
Tao Bao3602eca2018-07-10 10:53:55 -07001638$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001639
Tao Bao3602eca2018-07-10 10:53:55 -07001640$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001641$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Gao Xiang961041a2020-06-17 13:59:16 +08001642$(if $(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG),$(hide) echo "erofs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EROFS_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001643$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001644$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001645$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1646$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1647$(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 +00001648$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1649$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1650$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1651$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1652$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001653$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001654$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1655$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1656$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001657$(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 -07001658$(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 -07001659$(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 +00001660$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1661$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1662$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1663$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1664$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001665$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001666$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1667$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1668$(if $(BOARD_AVB_ENABLE),\
1669 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1670 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1671 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1672 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001673$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1674$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1675$(if $(BOARD_AVB_ENABLE),\
1676 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1677 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001678 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001679$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1680$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1681$(if $(BOARD_AVB_ENABLE),\
1682 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1683 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1684 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1685 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001686$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1687$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1688$(if $(BOARD_AVB_ENABLE),\
1689 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1690 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1691 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1692 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001693$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001694$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001695 $(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 +01001696$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001697 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1698 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1699 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1700 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001701$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1702$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1703$(if $(BOARD_AVB_ENABLE),\
1704 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1705 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1706 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1707 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001708$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1709$(if $(BOARD_AVB_ENABLE),\
1710 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1711$(if $(BOARD_AVB_ENABLE),\
1712 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1713 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1714 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1715 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongf496f1b2020-07-15 16:52:59 -07001716$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1717$(if $(BOARD_AVB_ENABLE),\
1718 $(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1719$(if $(BOARD_AVB_ENABLE),\
1720 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
1721 $(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)
1722 $(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)
1723 $(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001724$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1725 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001726$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001727 $(hide) echo "system_root_image=true" >> $(1))
1728$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001729$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1730 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001731$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1732endef
1733
1734# $(1): the path of the output dictionary file
1735# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001736PROP_DICTIONARY_IMAGES := oem
1737ifdef BUILDING_CACHE_IMAGE
1738 PROP_DICTIONARY_IMAGES += cache
1739endif
1740ifdef BUILDING_SYSTEM_IMAGE
1741 PROP_DICTIONARY_IMAGES += system
1742endif
Chris Gross203191b2020-05-30 02:39:12 +00001743ifdef BUILDING_SYSTEM_OTHER_IMAGE
1744 PROP_DICTIONARY_IMAGES += system_other
1745endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001746ifdef BUILDING_USERDATA_IMAGE
1747 PROP_DICTIONARY_IMAGES += userdata
1748endif
1749ifdef BUILDING_VENDOR_IMAGE
1750 PROP_DICTIONARY_IMAGES += vendor
1751endif
1752ifdef BUILDING_PRODUCT_IMAGE
1753 PROP_DICTIONARY_IMAGES += product
1754endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001755ifdef BUILDING_SYSTEM_EXT_IMAGE
1756 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001757endif
1758ifdef BUILDING_ODM_IMAGE
1759 PROP_DICTIONARY_IMAGES += odm
1760endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001761ifdef BUILDING_VENDOR_DLKM_IMAGE
1762 PROP_DICTIONARY_IMAGES += vendor_dlkm
1763endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07001764ifdef BUILDING_ODM_DLKM_IMAGE
1765 PROP_DICTIONARY_IMAGES += odm_dlkm
1766endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001767define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001768 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001769endef
1770
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001771# $(1): the path of the input dictionary file, where each line has the format key=value
1772# $(2): the key to look up
1773define read-image-prop-dictionary
1774$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1775endef
1776
The Android Open Source Project88b60792009-03-03 19:28:42 -08001777# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001778# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001779
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001780# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001781ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001782
Ying Wang37526142015-03-10 12:02:57 -07001783INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1784 $(ALL_DEFAULT_INSTALLED_MODULES))
1785
Tao Bao10fc9492018-08-14 12:17:48 -07001786INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1787INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1788
Colin Cross359f4212020-12-02 15:14:04 -08001789ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1790INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
1791endif
1792
Tao Bao10fc9492018-08-14 12:17:48 -07001793# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1794# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1795# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1796# the call to FILELIST.
Colin Cross359f4212020-12-02 15:14:04 -08001797$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
Tao Bao10fc9492018-08-14 12:17:48 -07001798
1799$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001800$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001801 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08001802 mkdir -p $(dir $@)
1803 rm -f $@
1804 $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
1805 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001806
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001807recovery_sepolicy := \
1808 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001809 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001810 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001811 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1812 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1813 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001814 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001815 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001816 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1817 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1818 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001819
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001820# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1821# SELinux files
1822IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1823
Steve Muckle04b6f052020-08-09 14:36:56 -07001824# if building multiple boot images from multiple kernels, use the first kernel listed
1825# for the recovery image
1826recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07001827recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001828recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001829
Anton Hansson45a40da2019-01-18 14:06:34 +00001830# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1831# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1832# which get remapped to a bucket.
1833recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001834ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1835recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001836# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001837# ------160------240------320----------480------------640------
1838# mdpi hdpi xhdpi xxhdpi xxxhdpi
1839recovery_density := $(strip \
1840 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1841 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1842 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1843 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001844endif
1845
1846ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1847recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1848else
Doug Zongker25d55f82014-04-04 13:51:15 -07001849recovery_resources_common := $(recovery_resources_common)-xhdpi
1850endif
1851
Tao Baoe1e829e2018-08-29 20:36:00 -07001852# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1853# Note that the font selected here can be overridden for a particular device by putting a font.png
1854# in its private recovery resources.
1855ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001856recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001857else
Dan Willemsen97672232020-05-27 00:09:16 -07001858recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001859endif
1860
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001861
1862# We will only generate the recovery background text images if the variable
1863# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1864# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1865# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1866# BoardConfig in order to use this feature.
1867ifeq ($(recovery_density),xxxhdpi)
1868TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1869else ifeq ($(recovery_density),xxhdpi)
1870TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1871endif
1872
1873ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1874# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1875ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1876 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1877else
1878 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1879endif
1880
1881
Dan Willemsen97672232020-05-27 00:09:16 -07001882RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001883RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1884RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1885RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1886RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1887
xunchangcc57d312018-12-07 12:12:17 -08001888RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1889RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1890RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1891RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1892RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1893
1894generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001895 $(RECOVERY_INSTALLING_TEXT_FILE) \
1896 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1897 $(RECOVERY_ERASING_TEXT_FILE) \
1898 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001899 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1900 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1901 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1902 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1903 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1904 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001905
Dan Willemsen97672232020-05-27 00:09:16 -07001906resource_dir := bootable/recovery/tools/recovery_l10n/res/
1907resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001908image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001909zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001910$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001911$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001912$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1913$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001914$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001915$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001916$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001917 recovery_installing \
1918 recovery_installing_security \
1919 recovery_erasing \
1920 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001921 recovery_no_command
1922$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001923 recovery_cancel_wipe_data \
1924 recovery_factory_data_reset \
1925 recovery_try_again \
1926 recovery_wipe_data_menu_header \
1927 recovery_wipe_data_confirmation
1928$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001929$(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 -08001930 # Prepares the font directory.
1931 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1932 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001933 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001934 @rm -rf $(dir $@)
1935 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001936 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001937 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001938 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001939 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1940 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1941 --text_name $(text_name) \
1942 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1943 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001944 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001945 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001946else
1947RECOVERY_INSTALLING_TEXT_FILE :=
1948RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1949RECOVERY_ERASING_TEXT_FILE :=
1950RECOVERY_ERROR_TEXT_FILE :=
1951RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001952RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1953RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1954RECOVERY_TRY_AGAIN_TEXT_FILE :=
1955RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1956RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001957endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1958
Ying Wang9a175682015-08-06 11:47:47 -07001959ifndef TARGET_PRIVATE_RES_DIRS
1960TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1961endif
Doug Zongker4647f122009-07-02 09:00:54 -07001962recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001963 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001964recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001965
1966
Andrew Boiefa61ff02012-09-28 09:33:45 -07001967ifdef TARGET_RECOVERY_FSTAB
1968recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1969else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001970recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001971endif
Tao Baoc3c17532016-06-10 10:11:54 -07001972ifdef TARGET_RECOVERY_WIPE
1973recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001974else
Tao Baoc3c17532016-06-10 10:11:54 -07001975recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001976endif
Tao Bao8beab692015-07-22 12:33:18 -07001977
Tao Bao6d5d6232018-03-09 17:04:42 -08001978# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001979# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001980# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1981# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001982#
1983# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001984# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001985# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001986# b) We build a single image that contains boot and recovery both - no recovery image to install
1987# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001988# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001989# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001990# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1991# do bsdiff because boot and recovery will contain different number of entries
1992# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001993# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1994# do bsdiff because boot and recovery will contain different number of entries
1995# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Yifan Hongef7a9712020-10-20 13:17:42 -07001996# f) We build a single image that contains vendor_boot and recovery both - no recovery image to
1997# install
1998# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001999
Tom Cherry2929cad2018-09-20 11:04:37 -07002000ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Yifan Hongef7a9712020-10-20 13:17:42 -07002001 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
2002 $(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
Doug Zongker56588872012-08-20 15:38:58 -07002003# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07002004RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
2005ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07002006else
Tao Bao8beab692015-07-22 12:33:18 -07002007RECOVERY_RESOURCE_ZIP :=
2008endif
Doug Zongker4647f122009-07-02 09:00:54 -07002009
Tao Bao139c7272018-07-31 13:26:54 -07002010INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
2011
2012$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07002013 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
2014 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
2015 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
2016 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
2017 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
2018 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
2019 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
2020 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
2021
2022# Parses the given list of build variables and writes their values as build properties if defined.
2023# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
2024# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
2025# $(1): Map from the build variable names to property names
2026# $(2): Output file
2027define append-recovery-ui-properties
2028echo "#" >> $(2)
2029echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
2030echo "#" >> $(2)
2031$(foreach prop,$(1), \
2032 $(eval _varname := $(call word-colon,1,$(prop))) \
2033 $(eval _propname := $(call word-colon,2,$(prop))) \
2034 $(eval _value := $($(_varname))) \
2035 $(if $(_value), \
2036 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
2037endef
2038
2039$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002040 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00002041 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
2042 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
2043 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09002044 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07002045 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07002046 $(hide) mkdir -p $(dir $@)
2047 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09002048 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002049 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002050 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002051 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002052 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07002053 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
2054
Yifan Hong33fd5d42020-09-24 18:18:26 -07002055# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
2056# On device with dedicated recovery partition, the file should come from the boot
2057# ramdisk.
2058ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
2059INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
2060$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
2061 $(copy-file-to-target)
2062endif
2063
Yifan Hongc56931c2020-10-28 16:35:19 -07002064INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Yifan Hongaad34e52020-10-12 11:08:30 -07002065
Yifan Hong78860162020-10-28 14:15:21 -07002066ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
Yifan Hongc56931c2020-10-28 16:35:19 -07002067INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
Doug Zongker4647f122009-07-02 09:00:54 -07002068# Assumes this has already been stripped
Yifan Hongaad34e52020-10-12 11:08:30 -07002069ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07002070ifdef INTERNAL_KERNEL_CMDLINE
2071 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Yifan Hongaad34e52020-10-12 11:08:30 -07002072endif # INTERNAL_KERNEL_CMDLINE != ""
2073endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker4647f122009-07-02 09:00:54 -07002074ifdef BOARD_KERNEL_BASE
2075 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
2076endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07002077ifdef BOARD_KERNEL_PAGESIZE
2078 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
2079endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002080ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08002081ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2082 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2083else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07002084 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
2085endif
Steve Mucklee1b10862019-07-10 10:49:37 -07002086endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002087ifdef BOARD_INCLUDE_RECOVERY_ACPIO
2088 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
2089endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002090ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
2091 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
2092endif
Yifan Hong3941a872020-10-28 16:33:06 -07002093endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Steve Mucklef84668e2020-03-16 19:13:46 -07002094ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
2095 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
2096endif
Doug Zongker4647f122009-07-02 09:00:54 -07002097
Yifan Hong881df392020-10-09 14:29:39 -07002098$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002099 $(INTERNAL_ROOT_FILES) \
2100 $(INSTALLED_RAMDISK_TARGET) \
2101 $(INTERNAL_RECOVERYIMAGE_FILES) \
2102 $(recovery_sepolicy) \
2103 $(INSTALLED_2NDBOOTLOADER_TARGET) \
2104 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
Yifan Hong33fd5d42020-09-24 18:18:26 -07002105 $(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002106 $(recovery_resource_deps) \
2107 $(recovery_fstab)
2108 # Making recovery image
2109 mkdir -p $(TARGET_RECOVERY_OUT)
2110 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
2111 # Copying baseline ramdisk...
2112 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
2113 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
2114 # Modifying ramdisk contents...
2115 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
2116 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
2117 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
2118 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
2119 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
2120 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
2121 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
2122 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
2123 $(foreach recovery_text_file,$(generated_recovery_text_files), \
2124 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
2125 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
2126 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
2127 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
2128 $(foreach item,$(recovery_fstab), \
2129 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
2130 $(if $(strip $(recovery_wipe)), \
2131 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
2132 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
2133 $(BOARD_RECOVERY_IMAGE_PREPARE)
Yifan Hong881df392020-10-09 14:29:39 -07002134 $(hide) touch $@
2135
2136$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
J. Avila3f6560e2020-05-11 20:20:03 +00002137 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07002138
Ying Wang747b9f12015-01-30 14:05:22 -08002139# $(1): output file
Yifan Hong63c5ca12020-10-08 11:54:02 -07002140# $(2): optional kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08002141define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00002142 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002143 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002144 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002145 --output $(1).unsigned, \
Yifan Hong63c5ca12020-10-08 11:54:02 -07002146 $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07002147 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07002148 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00002149 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002150 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00002151 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
2152 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07002153 )\
2154 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00002155 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
2156 $(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 +08002157 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002158 $(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 -07002159 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05002160 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
2161 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002162 $(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 -07002163 $(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 -08002164endef
2165
Dan Willemsend120ac62020-06-12 02:39:34 +00002166recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00002167ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00002168 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002169endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00002170ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00002171 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08002172endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002173ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00002174 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07002175endif
Tao Baof4866c72018-08-22 14:35:09 -07002176ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00002177 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
2178 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
2179 else
2180 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
2181 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08002182endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002183ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00002184 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002185endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002186ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00002187 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08002188endif
Tao Baof4866c72018-08-22 14:35:09 -07002189
Dan Willemsend120ac62020-06-12 02:39:34 +00002190ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Yifan Hong3e0b5d02020-09-29 21:18:20 -07002191$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
Dan Willemsend120ac62020-06-12 02:39:34 +00002192$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07002193 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002194 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07002195endif # BOARD_USES_RECOVERY_AS_BOOT
2196
Dan Willemsend120ac62020-06-12 02:39:34 +00002197$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Yifan Hong63c5ca12020-10-08 11:54:02 -07002198 $(call build-recoveryimage-target, $@, \
2199 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Doug Zongker4647f122009-07-02 09:00:54 -07002200
Tao Bao4594d0e2015-12-22 09:47:46 -08002201ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07002202$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07002203 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07002204 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
2205 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07002206endif
Doug Zongker56588872012-08-20 15:38:58 -07002207
Ying Wang747b9f12015-01-30 14:05:22 -08002208.PHONY: recoveryimage-nodeps
2209recoveryimage-nodeps:
2210 @echo "make $@: ignoring dependencies"
Yifan Hong63c5ca12020-10-08 11:54:02 -07002211 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
2212 $(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
Ying Wang747b9f12015-01-30 14:05:22 -08002213
Chris Grossa784ef12019-04-22 11:09:57 -07002214else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07002215RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07002216endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07002217
2218.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07002219recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07002220
Jiyong Park03eb0612017-10-04 21:22:41 +09002221ifneq ($(BOARD_NAND_PAGE_SIZE),)
2222$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08002223endif
2224
Jiyong Park03eb0612017-10-04 21:22:41 +09002225ifneq ($(BOARD_NAND_SPARE_SIZE),)
2226$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07002227endif
2228
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002229ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07002230# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08002231# the debug ramdisk, which is the original ramdisk plus additional
2232# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
2233# When /force_debuggable is present, /init will load userdebug sepolicy
2234# and property files to allow adb root, if the device is unlocked.
2235
2236ifdef BUILDING_RAMDISK_IMAGE
2237BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
2238INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
2239
2240INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
2241 $(ALL_GENERATED_SOURCES) \
2242 $(ALL_DEFAULT_INSTALLED_MODULES))
2243
2244# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
2245# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
2246# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
2247my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
2248
2249INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
2250INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
2251$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
2252$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
2253
2254# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
2255# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
2256# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
2257$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002258$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08002259 @echo Installed file list: $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002260 mkdir -p $(dir $@)
2261 rm -f $@
2262 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002263 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002264
2265# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
2266# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
2267ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2268my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
2269else
2270my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
2271endif # BOARD_USES_RECOVERY_AS_BOOT
2272
2273$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2274$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002275
2276ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2277# 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 +08002278$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08002279else
2280# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
2281$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
2282endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00002283$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002284 $(call pretty,"Target debug ramdisk: $@")
Bowgo Tsai0013f552019-03-20 17:59:52 +08002285 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2286 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002287 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002288 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08002289
2290.PHONY: ramdisk_debug-nodeps
2291ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
2292ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00002293ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002294 echo "make $@: ignoring dependencies"
2295 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
2296 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08002297 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002298 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002299
2300my_debug_ramdisk_sync_dir :=
2301my_debug_ramdisk_root_dir :=
2302
2303endif # BUILDING_RAMDISK_IMAGE
2304
2305# -----------------------------------------------------------------
2306# the boot-debug.img, which is the kernel plus ramdisk-debug.img
2307#
2308# Note: it's intentional to skip signing for boot-debug.img, because it
2309# can only be used if the device is unlocked with verification error.
Daniel Normanaf670812020-10-12 11:31:35 -07002310ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002311ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07002312ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2313 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
2314 $(PRODUCT_OUT)/$(k).img)
2315else
2316 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2317endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002318
2319# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2320ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2321INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2322else
2323INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2324endif
2325
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002326# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2327# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2328# Using a test key to sign boot-debug.img to continue booting with the mismatched
2329# public key, if the device is unlocked.
2330ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002331$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002332endif
2333
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002334BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2335INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2336# $(1): the bootimage to sign
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002337# $(2): boot image variant (boot, boot-debug, boot-test-harness)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002338define test-key-sign-bootimage
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002339$(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 +08002340$(AVBTOOL) add_hash_footer \
2341 --image $(1) \
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002342 --partition_size $(call get-bootimage-partition-size,$(1),$(2))\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002343 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2344 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002345$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002346endef
2347
Steve Muckleb3dda772020-03-11 16:03:07 -07002348# $(1): output file
2349define build-debug-bootimage-target
2350 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2351 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002352 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
Steve Muckleb3dda772020-03-11 16:03:07 -07002353endef
2354
Bowgo Tsai0013f552019-03-20 17:59:52 +08002355# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2356$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2357 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002358 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002359
2360.PHONY: bootimage_debug-nodeps
2361bootimage_debug-nodeps: $(MKBOOTIMG)
2362 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002363 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002364
2365endif # TARGET_NO_KERNEL
Daniel Normanaf670812020-10-12 11:31:35 -07002366endif # INSTALLED_BOOTIMAGE_TARGET
Bowgo Tsai0013f552019-03-20 17:59:52 +08002367
Bowgo Tsai6a683672020-02-14 19:00:15 +08002368ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2369ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2370# -----------------------------------------------------------------
2371# vendor debug ramdisk
2372# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
Petri Gynther6a6d6212021-03-06 00:45:53 -08002373INTERNAL_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 +08002374$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2375$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002376
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002377ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002378$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002379endif
2380
Bowgo Tsai6a683672020-02-14 19:00:15 +08002381INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2382 $(ALL_GENERATED_SOURCES) \
2383 $(ALL_DEFAULT_INSTALLED_MODULES))
2384
2385# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2386# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2387# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2388# $(PRODUCT_OUT)/vendor_debug_ramdisk.
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002389$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/debug_ramdisk
2390$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2391$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2392$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002393 $(call pretty,"Target vendor debug ramdisk: $@")
Bowgo Tsai6a683672020-02-14 19:00:15 +08002394 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2395 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2396 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002397 cp -f $(debug_file) $(patsubst $(DEBUG_RAMDISK_DIR)/%,$(VENDOR_DEBUG_RAMDISK_DIR)/%,$(debug_file)) &&) true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002398 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_RAMDISK_DIR) $(VENDOR_DEBUG_RAMDISK_DIR) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002399
2400INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2401INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2402$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2403$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2404
2405# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2406# 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 +08002407$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002408$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08002409 @echo Installed file list: $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002410 mkdir -p $(dir $@)
2411 rm -f $@
2412 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2413 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2414
2415# -----------------------------------------------------------------
2416# vendor_boot-debug.img.
2417INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2418
2419# The util to sign vendor_boot-debug.img with a test key.
2420BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2421INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2422# $(1): the vendor bootimage to sign
2423define test-key-sign-vendor-bootimage
2424$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2425$(AVBTOOL) add_hash_footer \
2426 --image $(1) \
2427 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2428 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2429 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2430$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2431endef
2432
2433ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2434$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2435endif
2436
2437# 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 +08002438$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002439$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002440 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002441 $(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 +08002442 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2443 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2444
2445endif # BUILDING_RAMDISK_IMAGE
2446endif # BUILDING_VENDOR_BOOT_IMAGE
2447
Bowgo Tsai0013f552019-03-20 17:59:52 +08002448# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002449# The test harness ramdisk, which is based off debug_ramdisk, plus a
2450# few additional test-harness-specific properties in adb_debug.prop.
2451
2452ifdef BUILDING_RAMDISK_IMAGE
2453BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2454INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2455
2456# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2457# appends a few test harness specific properties into the adb_debug.prop.
2458TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2459TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2460
2461# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2462# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2463TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2464ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2465ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2466
2467# $(1): a list of key=value pairs for additional property assignments
2468# $(2): the target .prop file to append the properties from $(1)
2469define append-test-harness-props
2470 echo "#" >> $(2); \
2471 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2472 echo "#" >> $(2);
2473 $(foreach line,$(1), echo "$(line)" >> $(2);)
2474endef
2475
2476$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002477$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002478 $(call pretty,"Target test harness ramdisk: $@")
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002479 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2480 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002481 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002482
2483.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002484ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002485 echo "make $@: ignoring dependencies"
2486 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2487 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002488 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002489
2490endif # BUILDING_RAMDISK_IMAGE
2491
2492# -----------------------------------------------------------------
2493# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2494#
2495# Note: it's intentional to skip signing for boot-test-harness.img, because it
2496# can only be used if the device is unlocked with verification error.
2497ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2498
Steve Muckle4866bd62020-04-02 11:31:08 -07002499ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2500 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2501 $(PRODUCT_OUT)/$(k).img)
2502else
2503 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2504endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002505
2506# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2507INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2508
2509# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2510# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2511# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2512# public key, if the device is unlocked.
2513ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2514$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2515endif
2516
Steve Muckle4866bd62020-04-02 11:31:08 -07002517# $(1): output file
2518define build-boot-test-harness-target
2519 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2520 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002521 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002522endef
2523
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002524# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2525$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2526 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002527 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002528
2529.PHONY: bootimage_test_harness-nodeps
2530bootimage_test_harness-nodeps: $(MKBOOTIMG)
2531 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002532 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002533
2534endif # TARGET_NO_KERNEL
2535endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2536
Colin Crossbd382142020-08-26 15:08:57 -07002537# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2538# $1: from location (e.g $(TARGET_OUT)/vendor)
2539# $2: destination location (e.g. /vendor)
2540# $3: partition image name (e.g. vendor.img)
2541define create-partition-compat-symlink
2542$(eval \
2543$1:
2544 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2545 mkdir -p $(dir $1)
2546 if [ -d $1 ] && [ ! -h $1 ]; then \
2547 echo 'Non-symlink $1 detected!' 1>&2; \
2548 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2549 exit 1; \
2550 fi
2551 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002552$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002553)
2554$1
2555endef
2556
2557
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002558# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002559# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002560
Dan Willemsen37a19862018-10-31 16:31:46 -07002561INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002562 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002563 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002564
Colin Crossbd382142020-08-26 15:08:57 -07002565# Create symlink /system/vendor to /vendor if necessary.
2566ifdef BOARD_USES_VENDORIMAGE
2567 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2568endif
2569
2570# Create symlink /system/product to /product if necessary.
2571ifdef BOARD_USES_PRODUCTIMAGE
2572 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2573endif
2574
2575# Create symlink /system/system_ext to /system_ext if necessary.
2576ifdef BOARD_USES_SYSTEM_EXTIMAGE
2577 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2578endif
2579
Ying Wang82cceba2012-08-13 15:03:00 -07002580FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002581
2582# ASAN libraries in the system image - add dependency.
2583ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002584ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002585 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2586 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2587 endif
2588endif
2589
Tom Cherryd14b8952018-08-09 14:26:00 -07002590FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002591
Ying Wange5e8c5f2011-09-09 16:35:53 -07002592# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002593ifdef BUILDING_SYSTEM_IMAGE
2594
Kiyoung Kim36481e02020-11-16 10:50:05 +09002595# Install system linker configuration
2596# Collect all available stub libraries installed in system and install with predefined linker configuration
2597SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
2598$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(LINKER_CONFIG_PATH_system_linker_config) | conv_linker_config
2599 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(LINKER_CONFIG_PATH_system_linker_config)\
2600 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
2601
2602FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
2603
Ying Wange5e8c5f2011-09-09 16:35:53 -07002604# installed file list
2605# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2606# We put installed-files.txt ahead of image itself in the dependency graph
2607# so that we can get the size stat even if the build fails due to too large
2608# system image.
2609INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002610INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2611$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002612$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002613 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002614 mkdir -p $(dir $@)
2615 rm -f $@
2616 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
2617 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002618
2619.PHONY: installed-file-list
2620installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002621
2622$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002623
2624systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002625 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002626BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2627
The Android Open Source Project88b60792009-03-03 19:28:42 -08002628# $(1): output file
2629define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002630 @echo "Target system fs image: $(1)"
2631 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002632 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002633 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002634 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002635 $(BUILD_IMAGE) \
2636 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2637 || ( mkdir -p $${DIST_DIR}; \
2638 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2639 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002640endef
2641
Dan Willemsen6b72c732019-06-12 21:33:38 +00002642ifeq ($(BOARD_AVB_ENABLE),true)
2643$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2644endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002645$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002646 $(call build-systemimage-target,$@)
2647
Tao Baoe9d61b02018-08-20 21:09:07 -07002648INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002649SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002650
Tao Baoe9d61b02018-08-20 21:09:07 -07002651# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2652# compatibility, in case device-specific Makefiles still refer to the old name.
2653INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2654
Doug Zongker73ef8252009-07-23 15:12:53 -07002655# The system partition needs room for the recovery image as well. We
2656# now store the recovery image as a binary patch using the boot image
2657# as the source (since they are very similar). Generate the patch so
2658# we can see how big it's going to be, and include that in the system
2659# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002660ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002661ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002662ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002663ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002664diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2665else
2666diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2667endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002668intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2669RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002670$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2671$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002672 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002673 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002674 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002675 @echo "Construct recovery from boot"
2676 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002677 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002678else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2679RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002680endif # BOARD_USES_FULL_RECOVERY_IMAGE
2681endif # INSTALLED_RECOVERYIMAGE_TARGET
2682endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002683
Yifan Hong9a3cad92020-04-27 19:06:59 -07002684$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002685 @echo "Install system fs image: $@"
2686 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002687 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002688
Tao Baoe9d61b02018-08-20 21:09:07 -07002689systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002690
2691.PHONY: systemimage-nodeps snod
2692systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002693 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002694 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002695 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002696 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002697ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002698 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002699endif
2700
Dan Willemsen67495202019-01-16 12:42:05 -08002701endif # BUILDING_SYSTEM_IMAGE
2702
Anton Hansson30e061b2018-11-12 13:36:46 +00002703.PHONY: sync syncsys
2704sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002705
Ying Wang3a61eeb2016-03-11 10:32:01 -08002706# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002707# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002708.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002709platform:
2710 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002711
2712.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002713platform-java:
2714 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002715
Ying Wang3a61eeb2016-03-11 10:32:01 -08002716# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002717# data partition image
2718INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002719 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002720
Dan Willemsen67495202019-01-16 12:42:05 -08002721ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002722userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002723 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002724BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2725
Ying Wangbd93d422011-10-28 17:02:30 -07002726define build-userdataimage-target
2727 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2728 @mkdir -p $(TARGET_OUT_DATA)
2729 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002730 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002731 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002732 $(BUILD_IMAGE) \
2733 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2734 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2735 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002736endef
2737
Joe Onorato64d85d02009-04-09 19:31:12 -07002738# We just build this directly to the install location.
2739INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002740INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2741 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002742 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002743$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002744 $(build-userdataimage-target)
2745
2746.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002747userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002748 $(build-userdataimage-target)
2749
Dan Willemsen67495202019-01-16 12:42:05 -08002750endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002751
Andreas Gampe039b5c72017-03-24 16:06:31 -07002752# ASAN libraries in the system image - build rule.
2753ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2754 $(TARGET_OUT_SHARED_LIBRARIES) \
2755 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2756 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2757 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002758# Extra options: Enforce the system user for the files to avoid having to change ownership.
2759ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002760# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2761# enough space.
2762$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002763 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 -07002764
The Android Open Source Project88b60792009-03-03 19:28:42 -08002765# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002766# partition table image
2767ifdef BOARD_BPT_INPUT_FILES
2768
2769BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002770BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002771
2772INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2773 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002774 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002775 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2776
2777ifdef BOARD_BPT_DISK_SIZE
2778INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2779endif
2780
2781define build-bptimage-target
2782 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2783 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2784endef
2785
2786INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002787$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2788 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2789
David Zeuthen25328622016-04-08 15:08:03 -04002790$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2791 $(build-bptimage-target)
2792
2793.PHONY: bptimage-nodeps
2794bptimage-nodeps:
2795 $(build-bptimage-target)
2796
2797endif # BOARD_BPT_INPUT_FILES
2798
2799# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002800# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002801ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002802INTERNAL_CACHEIMAGE_FILES := \
2803 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2804
2805cacheimage_intermediates := \
2806 $(call intermediates-dir-for,PACKAGING,cache)
2807BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2808
2809define build-cacheimage-target
2810 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2811 @mkdir -p $(TARGET_OUT_CACHE)
2812 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002813 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002814 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002815 $(BUILD_IMAGE) \
2816 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2817 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2818 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002819endef
2820
2821# We just build this directly to the install location.
2822INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002823$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002824 $(build-cacheimage-target)
2825
2826.PHONY: cacheimage-nodeps
2827cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2828 $(build-cacheimage-target)
2829
Dan Willemsen67495202019-01-16 12:42:05 -08002830else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002831# we need to ignore the broken cache link when doing the rsync
2832IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002833endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002834
David Zeuthen0eb10972016-09-28 17:55:27 -04002835# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002836# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002837ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002838ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002839# Marker file to identify that odex files are installed
2840INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2841ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2842$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2843 $(hide) touch $@
2844endif
2845
Alex Light4e358ab2016-06-16 14:47:10 -07002846INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2847 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002848 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002849
Colin Cross6db5b0e2018-11-16 21:26:33 -08002850# system_other dex files are installed as a side-effect of installing system image files
2851INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2852
Alex Light4e358ab2016-06-16 14:47:10 -07002853INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002854INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2855$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002856$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002857 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002858 mkdir -p $(dir $@)
2859 rm -f $@
2860 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
2861 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002862
Bowgo Tsai867ab662019-01-29 13:30:18 +08002863# Determines partition size for system_other.img.
2864ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2865ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2866INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2867endif
2868endif
2869
2870ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2871INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2872endif
2873
Alex Light4e358ab2016-06-16 14:47:10 -07002874systemotherimage_intermediates := \
2875 $(call intermediates-dir-for,PACKAGING,system_other)
2876BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2877
2878# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2879define build-systemotherimage-target
2880 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2881 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2882 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002883 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002884 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002885 $(BUILD_IMAGE) \
2886 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2887 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2888 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002889endef
2890
2891# We just build this directly to the install location.
2892INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002893ifneq (true,$(SANITIZE_LITE))
2894# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002895$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2896 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002897endif
Alex Light4e358ab2016-06-16 14:47:10 -07002898
2899.PHONY: systemotherimage-nodeps
2900systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2901 $(build-systemotherimage-target)
2902
Dan Willemsen67495202019-01-16 12:42:05 -08002903endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002904
2905
2906# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002907# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002908ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002909INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002910 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002911 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002912
Ying Wang8da19e32015-09-15 14:22:12 -07002913
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002914# Create symlink /vendor/odm to /odm if necessary.
2915ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002916 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002917endif
2918
Yifan Honge51dff22020-06-23 17:26:57 -07002919# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2920# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2921#
2922# On devices with a vendor_dlkm partition,
2923# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2924# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2925# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2926# are hidden.
2927# On devices without a vendor_dlkm partition,
2928# - /vendor/lib/modules stores vendor DLKMs directly.
2929# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2930# See system/core/rootdir/Android.mk for a list of created symlinks.
2931# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2932# are not guaranteed to exist on all devices.
2933ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002934 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 -07002935endif
2936
Colin Crossbd382142020-08-26 15:08:57 -07002937INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2938INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2939$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2940$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2941 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002942 mkdir -p $(dir $@)
2943 rm -f $@
2944 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2945 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002946
Ying Wanga0febe52013-03-20 11:02:05 -07002947vendorimage_intermediates := \
2948 $(call intermediates-dir-for,PACKAGING,vendor)
2949BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002950define build-vendorimage-target
2951 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2952 @mkdir -p $(TARGET_OUT_VENDOR)
2953 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002954 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002955 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002956 $(BUILD_IMAGE) \
2957 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2958 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002959 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002960endef
2961
2962# We just build this directly to the install location.
2963INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002964$(INSTALLED_VENDORIMAGE_TARGET): \
2965 $(INTERNAL_USERIMAGES_DEPS) \
2966 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002967 $(INSTALLED_FILES_FILE_VENDOR) \
2968 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002969 $(build-vendorimage-target)
2970
Steven Morelanda2e734d2017-03-07 12:10:09 -08002971.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002972vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002973 $(build-vendorimage-target)
2974
Colin Cross91a52272017-06-20 16:57:52 -07002975sync: $(INTERNAL_VENDORIMAGE_FILES)
2976
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002977else ifdef BOARD_PREBUILT_VENDORIMAGE
2978INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2979$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2980endif
Ying Wanga0febe52013-03-20 11:02:05 -07002981
Ying Wang9f8e8db2011-11-04 11:37:01 -07002982# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002983# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002984ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002985INTERNAL_PRODUCTIMAGE_FILES := \
2986 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002987 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002988
2989INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002990INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2991$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002992$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002993 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002994 mkdir -p $(dir $@)
2995 rm -f $@
2996 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
2997 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002998
2999productimage_intermediates := \
3000 $(call intermediates-dir-for,PACKAGING,product)
3001BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3002define build-productimage-target
3003 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3004 @mkdir -p $(TARGET_OUT_PRODUCT)
3005 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003006 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,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_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3010 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3011 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003012endef
3013
3014# We just build this directly to the install location.
3015INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003016$(INSTALLED_PRODUCTIMAGE_TARGET): \
3017 $(INTERNAL_USERIMAGES_DEPS) \
3018 $(INTERNAL_PRODUCTIMAGE_FILES) \
3019 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003020 $(build-productimage-target)
3021
3022.PHONY: productimage-nodeps pnod
3023productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3024 $(build-productimage-target)
3025
3026sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3027
3028else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3029INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3030$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3031endif
3032
3033# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003034# system_ext partition image
3035ifdef BUILDING_SYSTEM_EXT_IMAGE
3036INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3037 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003038 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003039
Justin Yun6151e3f2019-06-25 15:58:13 +09003040INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3041INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3042$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3043$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003044 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003045 mkdir -p $(dir $@)
3046 rm -f $@
3047 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3048 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003049
Justin Yun6151e3f2019-06-25 15:58:13 +09003050system_extimage_intermediates := \
3051 $(call intermediates-dir-for,PACKAGING,system_ext)
3052BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3053define build-system_extimage-target
3054 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3055 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3056 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3057 $(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 -07003058 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003059 $(BUILD_IMAGE) \
3060 $(TARGET_OUT_SYSTEM_EXT) \
3061 $(system_extimage_intermediates)/system_ext_image_info.txt \
3062 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3063 $(TARGET_OUT)
3064 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003065endef
3066
3067# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003068INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003069$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3070 $(INTERNAL_USERIMAGES_DEPS) \
3071 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3072 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003073 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003074
Justin Yun6151e3f2019-06-25 15:58:13 +09003075.PHONY: systemextimage-nodeps senod
3076systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3077 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003078
Justin Yun6151e3f2019-06-25 15:58:13 +09003079sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003080
Justin Yun6151e3f2019-06-25 15:58:13 +09003081else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3082INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3083$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003084endif
3085
3086# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003087# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003088ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003089INTERNAL_ODMIMAGE_FILES := \
3090 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003091 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003092
Colin Crossbd382142020-08-26 15:08:57 -07003093# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3094# /odm/lib/modules -> /odm_dlkm/lib/modules
3095#
3096# On devices with a odm_dlkm partition,
3097# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3098# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3099# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3100# are hidden.
3101# On devices without a odm_dlkm partition,
3102# - /odm/lib/modules stores odm DLKMs directly.
3103# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3104# See system/core/rootdir/Android.mk for a list of created symlinks.
3105# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3106# are not guaranteed to exist on all devices.
3107ifdef BOARD_USES_ODM_DLKMIMAGE
3108 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3109endif
3110
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003111INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3112INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3113$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003114$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003115 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003116 mkdir -p $(dir $@)
3117 rm -f $@
3118 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3119 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003120
3121odmimage_intermediates := \
3122 $(call intermediates-dir-for,PACKAGING,odm)
3123BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3124define build-odmimage-target
3125 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3126 @mkdir -p $(TARGET_OUT_ODM)
3127 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
3128 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003129 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003130 $(BUILD_IMAGE) \
3131 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3132 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3133 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003134endef
3135
3136# We just build this directly to the install location.
3137INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003138$(INSTALLED_ODMIMAGE_TARGET): \
3139 $(INTERNAL_USERIMAGES_DEPS) \
3140 $(INTERNAL_ODMIMAGE_FILES) \
3141 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003142 $(build-odmimage-target)
3143
3144.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003145odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003146 $(build-odmimage-target)
3147
3148sync: $(INTERNAL_ODMIMAGE_FILES)
3149
3150else ifdef BOARD_PREBUILT_ODMIMAGE
3151INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3152$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3153endif
3154
3155# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003156# vendor_dlkm partition image
3157ifdef BUILDING_VENDOR_DLKM_IMAGE
3158INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3159 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003160 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003161
3162INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3163INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3164$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3165$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3166 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003167 mkdir -p $(dir $@)
3168 rm -f $@
3169 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3170 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003171
3172vendor_dlkmimage_intermediates := \
3173 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3174BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3175define build-vendor_dlkmimage-target
3176 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3177 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3178 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
3179 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
3180 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3181 $(BUILD_IMAGE) \
3182 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3183 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3184 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3185endef
3186
3187# We just build this directly to the install location.
3188INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3189$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3190 $(INTERNAL_USERIMAGES_DEPS) \
3191 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3192 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3193 $(build-vendor_dlkmimage-target)
3194
3195.PHONY: vendor_dlkmimage-nodeps vdnod
3196vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3197 $(build-vendor_dlkmimage-target)
3198
3199sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3200
3201else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3202INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3203$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3204endif
3205
3206# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003207# odm_dlkm partition image
3208ifdef BUILDING_ODM_DLKM_IMAGE
3209INTERNAL_ODM_DLKMIMAGE_FILES := \
3210 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003211 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003212
3213INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3214INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3215$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3216$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3217 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003218 mkdir -p $(dir $@)
3219 rm -f $@
3220 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3221 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003222
3223odm_dlkmimage_intermediates := \
3224 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3225BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3226define build-odm_dlkmimage-target
3227 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3228 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3229 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3230 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3231 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3232 $(BUILD_IMAGE) \
3233 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3234 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3235 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3236endef
3237
3238# We just build this directly to the install location.
3239INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3240$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3241 $(INTERNAL_USERIMAGES_DEPS) \
3242 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3243 $(INSTALLED_FILES_FILE_ODM_DLKM)
3244 $(build-odm_dlkmimage-target)
3245
3246.PHONY: odm_dlkmimage-nodeps odnod
3247odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3248 $(build-odm_dlkmimage-target)
3249
3250sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3251
3252else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3253INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3254$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3255endif
3256
3257
3258# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003259# dtbo image
3260ifdef BOARD_PREBUILT_DTBOIMAGE
3261INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3262
3263ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003264$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003265 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3266 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003267 --image $@ \
3268 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3269 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3270 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003271else
3272$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3273 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3274endif
3275
Tao Bao0da43472018-08-22 22:53:41 -07003276endif # BOARD_PREBUILT_DTBOIMAGE
3277
Andrew Scull9b103e42020-11-29 14:04:28 +00003278# -----------------------------------------------------------------
3279# Protected VM firmware image
3280ifdef BOARD_PREBUILT_PVMFWIMAGE
3281INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
3282
3283ifeq ($(BOARD_AVB_ENABLE),true)
3284$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH)
3285 cp $(BOARD_PREBUILT_PVMFWIMAGE) $@
3286 $(AVBTOOL) add_hash_footer \
3287 --image $@ \
3288 --partition_size $(BOARD_PVMFWIMG_PARTITION_SIZE) \
3289 --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \
3290 $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)
3291else
3292$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE)
3293 cp $(BOARD_PREBUILT_PVMFWIMAGE) $@
3294endif
3295
3296endif # BOARD_PREBUILT_PVMFWIMAGE
3297
Tao Bao0da43472018-08-22 22:53:41 -07003298# Returns a list of image targets corresponding to the given list of partitions. For example, it
3299# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3300# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003301# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003302define images-for-partitions
3303$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3304endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003305
3306# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003307# custom images
3308INSTALLED_CUSTOMIMAGES_TARGET :=
3309
3310ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3311INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3312
3313# Sign custom image.
3314# $(1): the prebuilt custom image.
3315# $(2): the mount point of the prebuilt custom image.
3316# $(3): the signed custom image target.
3317define sign_custom_image
3318$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3319 @echo Target custom image: $(3)
3320 mkdir -p $(dir $(3))
3321 cp $(1) $(3)
3322ifeq ($(BOARD_AVB_ENABLE),true)
3323 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3324 $(AVBTOOL) add_hashtree_footer \
3325 --image $(3) \
3326 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3327 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3328 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3329 --partition_name $(2) \
3330 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3331 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3332endif
3333INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3334endef
3335
3336$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3337 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3338 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3339endif
3340
3341# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003342# vbmeta image
3343ifeq ($(BOARD_AVB_ENABLE),true)
3344
3345BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003346AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003347
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003348ifdef BOARD_AVB_KEY_PATH
3349$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3350else
3351# If key path isn't specified, use the 4096-bit test key.
3352BOARD_AVB_ALGORITHM := SHA256_RSA4096
3353BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3354endif
3355
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003356# AVB signing for system_other.img.
3357ifdef BUILDING_SYSTEM_OTHER_IMAGE
3358ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3359$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3360else
3361# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3362BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3363BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3364endif
3365
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003366$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3367 @echo Extracting system_other avb key: $@
3368 @rm -f $@
3369 @mkdir -p $(dir $@)
3370 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003371
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003372ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3373BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3374endif
3375
3376BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3377endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3378
Tao Bao744c4c72018-08-20 21:09:07 -07003379INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003380 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003381 $(BOARD_AVB_VBMETA_VENDOR)
3382
3383# Not allowing the same partition to appear in multiple groups.
3384ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003385 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003386endif
3387
cfig1aeef722019-09-20 22:45:06 +08003388# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3389# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3390# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003391ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003392ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3393$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003394 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003395 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3396endif
3397endif
3398
Bowgo Tsai9b548012019-05-14 16:57:03 +08003399# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003400
3401BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003402 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003403 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003404 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3405
3406BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003407 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003408 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003409 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3410
Justin Yun6151e3f2019-06-25 15:58:13 +09003411BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003412 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003413 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003414 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003415
Bowgo Tsai9b548012019-05-14 16:57:03 +08003416BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003417 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003418 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003419
Tao Bao19b02fe2019-10-09 00:04:28 -07003420BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3421 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3422
3423BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3424 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3425
Bowgo Tsai9b548012019-05-14 16:57:03 +08003426BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003427 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003428 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003429
3430BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003431 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003432 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003433
Yifan Hongcfb917a2020-05-07 14:58:20 -07003434BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3435 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3436 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3437
Yifan Hongf496f1b2020-07-15 16:52:59 -07003438BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3439 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3440 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3441
Tao Bao19b02fe2019-10-09 00:04:28 -07003442BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3443 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3444
Andrew Scull9b103e42020-11-29 14:04:28 +00003445BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3446 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3447
Bowgo Tsai9b548012019-05-14 16:57:03 +08003448# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003449ifdef BOOT_SECURITY_PATCH
3450BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3451 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3452endif
3453
3454ifdef VENDOR_SECURITY_PATCH
3455BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3456 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3457endif
3458
3459ifdef ODM_SECURITY_PATCH
3460BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3461 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3462endif
3463
Yifan Hongcfb917a2020-05-07 14:58:20 -07003464ifdef VENDOR_DLKM_SECURITY_PATCH
3465BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3466 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3467endif
3468
Yifan Hongf496f1b2020-07-15 16:52:59 -07003469ifdef ODM_DLKM_SECURITY_PATCH
3470BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3471 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3472endif
3473
Andrew Scull9b103e42020-11-29 14:04:28 +00003474ifdef PVMFW_SECURITY_PATCH
3475BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3476 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
3477endif
3478
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003479BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003480VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003481DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00003482PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003483SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3484VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003485RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003486PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003487SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003488ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003489VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003490ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003491
Tao Bao0da43472018-08-22 22:53:41 -07003492# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003493# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003494define _check-and-set-avb-chain-args
3495$(eval part := $(1))
3496$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003497
3498$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3499$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3500$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3501$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3502$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3503$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3504$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3505$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3506
3507# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3508$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3509$(eval $(_signing_args) := \
3510 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3511
cfig1aeef722019-09-20 22:45:06 +08003512# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3513# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003514$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003515 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3516 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003517
Tao Bao744c4c72018-08-20 21:09:07 -07003518# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003519# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003520$(if $(filter $(part),$(part:vbmeta_%=%)),\
3521 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3522 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003523endef
3524
Tao Bao0da43472018-08-22 22:53:41 -07003525# Checks and sets the required build variables for an AVB partition. The partition will be
3526# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003527# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3528# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003529# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3530# but vbmeta would capture the image descriptor of only the first boot
3531# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003532# $(1): Partition name, e.g. boot or system.
3533define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003534$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003535$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003536 $(if $(_in_chained_vbmeta),\
3537 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003538 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003539 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003540 $(if $(filter boot,$(1)),\
3541 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3542 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3543 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3544 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003545endef
3546
Hongguang Chenf23364d2020-04-27 18:36:36 -07003547# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3548# $(1): the custom partition to enable AVB chain.
3549define check-and-set-custom-avb-chain-args
3550$(eval part := $(1))
3551$(eval PART=$(call to-upper,$(part)))
3552$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3553$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3554
3555INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3556 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3557endef
3558
Tao Baob1a2e352018-08-14 16:17:12 -07003559ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003560$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003561endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003562
Steve Mucklee1b10862019-07-10 10:49:37 -07003563ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3564$(eval $(call check-and-set-avb-args,vendor_boot))
3565endif
3566
Tao Bao0da43472018-08-22 22:53:41 -07003567$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003568
3569ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003570$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003571endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003572
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003573ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003574$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003575endif
3576
Justin Yun6151e3f2019-06-25 15:58:13 +09003577ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3578$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003579endif
3580
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003581ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003582$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003583endif
3584
Yifan Hongcfb917a2020-05-07 14:58:20 -07003585ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3586$(eval $(call check-and-set-avb-args,vendor_dlkm))
3587endif
3588
Yifan Hongf496f1b2020-07-15 16:52:59 -07003589ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3590$(eval $(call check-and-set-avb-args,odm_dlkm))
3591endif
3592
Yueyao Zhu211c9012017-04-27 00:34:50 -07003593ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003594$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003595endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003596
Andrew Scull9b103e42020-11-29 14:04:28 +00003597ifdef INSTALLED_PVMFWIMAGE_TARGET
3598$(eval $(call check-and-set-avb-args,pvmfw))
3599endif
3600
David Zeuthen8fecb282017-12-01 16:24:01 -05003601ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003602$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003603endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003604
David Anderson7709ab22018-10-15 14:41:34 -07003605# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3606ifdef BOARD_AVB_VBMETA_SYSTEM
3607$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003608endif
3609
3610ifdef BOARD_AVB_VBMETA_VENDOR
3611$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3612endif
3613
Hongguang Chenf23364d2020-04-27 18:36:36 -07003614ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3615$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3616 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3617endif
3618
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003619# Add kernel cmdline descriptor for kernel to mount system.img as root with
3620# dm-verity. This works when system.img is either chained or not-chained:
3621# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3622# cmdline descriptor to system.img
3623# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3624# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003625ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003626ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003627BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003628endif
David Anderson8916a2a2018-09-18 15:46:59 -07003629endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003630
Tao Bao0da43472018-08-22 22:53:41 -07003631BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003632BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003633BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3634
3635ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003636# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003637BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003638endif
Tao Bao0da43472018-08-22 22:53:41 -07003639
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003640ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003641BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003642endif
3643
David Anderson7709ab22018-10-15 14:41:34 -07003644ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3645BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3646 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003647endif
3648
3649ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3650BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3651 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003652endif
3653
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003654# $(1): the directory to extract public keys to
3655define extract-avb-chain-public-keys
3656 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3657 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3658 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003659 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3660 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3661 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003662 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3663 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3664 --output $(1)/system.avbpubkey)
3665 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3666 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3667 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003668 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3669 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3670 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003671 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3672 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3673 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003674 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3675 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3676 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003677 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3678 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3679 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003680 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3681 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3682 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003683 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3684 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3685 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00003686 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
3687 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
3688 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003689 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3690 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3691 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003692 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3693 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3694 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003695 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3696 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3697 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003698 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3699 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3700 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3701 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003702endef
3703
Tao Bao744c4c72018-08-20 21:09:07 -07003704# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3705# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003706# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003707# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3708# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003709# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003710# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003711# $(2): Output filename.
3712define build-chained-vbmeta-image
3713 $(call pretty,"Target chained vbmeta image: $@")
3714 $(hide) $(AVBTOOL) make_vbmeta_image \
3715 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3716 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3717 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3718 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3719 --output $@
3720endef
3721
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003722ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003723ifdef BOARD_AVB_VBMETA_SYSTEM
3724INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3725$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003726 $(AVBTOOL) \
3727 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3728 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003729 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003730endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003731endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003732
3733ifdef BOARD_AVB_VBMETA_VENDOR
3734INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3735$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003736 $(AVBTOOL) \
3737 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3738 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003739 $(call build-chained-vbmeta-image,vbmeta_vendor)
3740endif
3741
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003742define build-vbmetaimage-target
3743 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003744 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3745 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003746 $(hide) $(AVBTOOL) make_vbmeta_image \
3747 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003748 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003749 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3750 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003751 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003752endef
3753
Paul Trautrim4e143232019-08-13 16:30:57 +09003754ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003755INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003756$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3757 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3758
David Zeuthen8fecb282017-12-01 16:24:01 -05003759$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003760 $(AVBTOOL) \
3761 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003762 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003763 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3764 $(INSTALLED_VENDORIMAGE_TARGET) \
3765 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003766 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003767 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003768 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003769 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003770 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00003771 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003772 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003773 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3774 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3775 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3776 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3777 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3778 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003779 $(build-vbmetaimage-target)
3780
3781.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003782vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3783 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003784vbmetaimage-nodeps:
3785 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003786endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003787
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003788endif # BOARD_AVB_ENABLE
3789
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003790# List of files from all images
3791INTERNAL_ALLIMAGES_FILES := \
3792 $(FULL_SYSTEMIMAGE_DEPS) \
3793 $(INTERNAL_RAMDISK_FILES) \
3794 $(INTERNAL_USERDATAIMAGE_FILES) \
3795 $(INTERNAL_VENDORIMAGE_FILES) \
3796 $(INTERNAL_PRODUCTIMAGE_FILES) \
3797 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3798 $(INTERNAL_ODMIMAGE_FILES) \
3799 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3800 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3801
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003802# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003803# Check VINTF of build
3804
Yifan Hongc08cbf02020-09-15 19:07:39 +00003805# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003806ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003807
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003808intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3809check_vintf_all_deps :=
3810
Yifan Hongaf9b0702020-01-21 12:46:57 -08003811# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3812# because they are only used for prebuilt images.
3813check_vintf_common_srcs_patterns := \
3814 $(TARGET_OUT)/etc/vintf/% \
3815 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3816 $(TARGET_OUT_ODM)/etc/vintf/% \
3817 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3818 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3819
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003820check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08003821check_vintf_common_srcs_patterns :=
3822
3823check_vintf_has_system :=
3824check_vintf_has_vendor :=
3825
Yifan Hong28ffd732020-03-13 13:11:10 -07003826ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3827$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3828endif
3829ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3830$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3831endif
3832
Yifan Hong605ea042020-01-14 21:36:00 +00003833# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003834check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3835ifneq ($(check_vintf_system_deps),)
3836check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00003837
Yifan Hong605ea042020-01-14 21:36:00 +00003838check_vintf_system_log := $(intermediates)/check_vintf_system_log
3839check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003840$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003841 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3842check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00003843
3844vintffm_log := $(intermediates)/vintffm_log
3845check_vintf_all_deps += $(vintffm_log)
3846$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
3847 @( $< --check --dirmap /system:$(TARGET_OUT) \
3848 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3849
Yifan Hongaf9b0702020-01-21 12:46:57 -08003850endif # check_vintf_system_deps
3851check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003852
3853# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003854check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3855ifneq ($(check_vintf_vendor_deps),)
3856check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003857check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3858check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003859# Check vendor SKU=(empty) case when:
3860# - DEVICE_MANIFEST_FILE is not empty; OR
3861# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003862$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003863 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3864 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003865 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003866$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003867 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3868 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3869 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3870 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003871check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003872endif # check_vintf_vendor_deps
3873check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003874
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003875# -- Check VINTF compatibility of build.
3876# Skip partial builds; only check full builds. Only check if:
3877# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003878# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003879# - Building product / system_ext / odm images if board has product / system_ext / odm images
3880ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003881ifeq ($(check_vintf_has_system),true)
3882ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003883ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3884ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3885ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3886
3887check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3888check_vintf_all_deps += $(check_vintf_compatible_log)
3889
3890check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003891check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003892
3893# -- Kernel version and configurations.
3894ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3895
Yifan Hong605ea042020-01-14 21:36:00 +00003896BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3897BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3898
3899my_board_extracted_kernel :=
3900
3901# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3902# from INSTALLED_KERNEL_TARGET.
3903ifdef BOARD_KERNEL_CONFIG_FILE
3904ifdef BOARD_KERNEL_VERSION
3905$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3906 cp $< $@
3907$(BUILT_KERNEL_VERSION_FILE):
3908 echo $(BOARD_KERNEL_VERSION) > $@
3909
3910my_board_extracted_kernel := true
3911endif # BOARD_KERNEL_VERSION
3912endif # BOARD_KERNEL_CONFIG_FILE
3913
3914ifneq ($(my_board_extracted_kernel),true)
3915ifndef INSTALLED_KERNEL_TARGET
3916$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3917 is true. Information about the updated kernel cannot be built into OTA update package. \
3918 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3919 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3920 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3921 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3922 manually.)
3923else
3924
3925# Tools for decompression that is not in PATH.
3926# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3927# Algorithms that are in the script but not in this list will be found in PATH.
3928my_decompress_tools := \
3929 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3930
3931$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3932$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3933$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003934$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3935 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003936 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08003937 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00003938
3939my_decompress_tools :=
3940
3941endif # my_board_extracted_kernel
3942my_board_extracted_kernel :=
3943
3944endif # INSTALLED_KERNEL_TARGET
3945
Yifan Hong72e78f22020-11-13 18:30:06 -08003946check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003947check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3948
3949endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3950
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003951check_vintf_compatible_args += \
3952 --dirmap /system:$(TARGET_OUT) \
3953 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3954 --dirmap /odm:$(TARGET_OUT_ODM) \
3955 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3956 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3957
3958ifdef PRODUCT_SHIPPING_API_LEVEL
3959check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3960endif # PRODUCT_SHIPPING_API_LEVEL
3961
3962$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3963$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003964# Check ODM SKU=(empty) case when:
3965# - ODM_MANIFEST_FILES is not empty; OR
3966# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003967$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003968 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3969 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003970 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003971# Check vendor SKU=(empty) case when:
3972# - DEVICE_MANIFEST_FILE is not empty; OR
3973# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003974$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003975 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3976 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003977 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003978$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3979 @echo -n -e 'Deps: \n ' > $@
3980 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3981 @echo -n -e 'Args: \n ' >> $@
3982 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003983 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3984 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003985 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003986 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3987 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3988 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003989
3990check_vintf_compatible_log :=
3991check_vintf_compatible_args :=
3992check_vintf_compatible_deps :=
3993
3994endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3995endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3996endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003997endif # check_vintf_has_vendor
3998endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003999endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4000
4001# Add all logs of VINTF checks to dist builds
4002droid_targets: $(check_vintf_all_deps)
4003$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4004
4005# Helper alias to check all VINTF of current build.
4006.PHONY: check-vintf-all
4007check-vintf-all: $(check_vintf_all_deps)
4008 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4009
Yifan Hongaf9b0702020-01-21 12:46:57 -08004010check_vintf_has_vendor :=
4011check_vintf_has_system :=
4012check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004013check_vintf_all_deps :=
4014intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004015endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004016
4017# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004018# Check image sizes <= size of super partition
4019
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004020ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004021
4022ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004023
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004024# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004025# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004026define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004027 mkdir -p $(dir $(1))
4028 rm -f $(1)
4029 $(call dump-super-image-info, $(1))
4030 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4031 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004032 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004033endef
4034
Yifan Hong30910932019-10-25 20:36:55 -07004035check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
4036droid_targets: $(check_all_partition_sizes_log)
4037$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004038
Yifan Hong30910932019-10-25 20:36:55 -07004039$(check_all_partition_sizes_log): \
4040 $(CHECK_PARTITION_SIZES) \
4041 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
4042 $(call check-all-partition-sizes-target, \
4043 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4044 $@)
4045
4046.PHONY: check-all-partition-sizes
4047check-all-partition-sizes: $(check_all_partition_sizes_log)
4048
4049.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004050check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004051 $(call check-all-partition-sizes-target, \
4052 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004053
Yifan Hong2dae5722018-07-31 12:47:27 -07004054endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004055
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004056endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004057
4058# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004059# bring in the installer image generation defines if necessary
4060ifeq ($(TARGET_USE_DISKINSTALLER),true)
4061include bootable/diskinstaller/config.mk
4062endif
4063
4064# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004065# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004066
Ying Wangbd2d0242015-09-22 11:17:52 -07004067ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004068 build_ota_package := false
4069 build_otatools_package := false
4070else
Tao Bao9be20c72019-04-08 21:11:59 -07004071 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004072 build_ota_package := true
4073 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4074 build_ota_package := false
4075 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004076 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004077 build_ota_package := false
4078 endif
4079 ifeq ($(TARGET_PRODUCT),sdk)
4080 build_ota_package := false
4081 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004082 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4083 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4084 build_ota_package := false
4085 endif
4086 ifeq ($(TARGET_NO_KERNEL),true)
4087 build_ota_package := false
4088 endif
4089 ifeq ($(recovery_fstab),)
4090 build_ota_package := false
4091 endif
4092 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004093
Tao Bao9be20c72019-04-08 21:11:59 -07004094 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004095 build_otatools_package := true
4096 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4097 build_otatools_package := false
4098 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004099endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004100
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004101ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004102
4103INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004104 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004105 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07004106 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004107 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004108 append2simg \
4109 avbtool \
4110 blk_alloc_to_base_fs \
4111 boot_signer \
4112 brillo_update_payload \
4113 brotli \
4114 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004115 build_image \
4116 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004117 build_verity_metadata \
4118 build_verity_tree \
4119 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004120 check_ota_package_signature \
4121 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004122 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004123 checkvintf \
4124 delta_generator \
4125 e2fsck \
4126 e2fsdroid \
4127 fc_sort \
4128 fec \
4129 fs_config \
4130 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08004131 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07004132 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004133 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004134 imgdiff \
4135 libconscrypt_openjdk_jni \
4136 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004137 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07004138 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07004139 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07004140 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07004141 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004142 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004143 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004144 mkbootfs \
4145 mkbootimg \
4146 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004147 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08004148 mkfs.erofs \
4149 mkerofsimage.sh \
Tao Bao96daeeb2019-05-01 21:17:13 -07004150 mkf2fsuserimg.sh \
4151 mksquashfs \
4152 mksquashfsimage.sh \
4153 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07004154 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08004155 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08004156 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07004157 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004158 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004159 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004160 sign_apex \
4161 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07004162 signapk \
4163 simg2img \
4164 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07004165 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07004166 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08004167 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07004168 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07004169 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004170 verity_signer \
4171 verity_verifier \
4172 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08004173
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004174# Additional tools to unpack and repack the apex file.
4175INTERNAL_OTATOOLS_MODULES += \
4176 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00004177 apex_compression_tool \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004178 deapexer \
4179 debugfs_static \
4180 merge_zips \
4181 resize2fs \
4182 soong_zip \
4183
Anton Hansson8dab0a62019-03-28 15:45:40 +00004184ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004185INTERNAL_OTATOOLS_MODULES += \
4186 futility \
4187 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004188endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004189
Tao Bao96daeeb2019-05-01 21:17:13 -07004190INTERNAL_OTATOOLS_FILES := \
4191 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004192
Ying Wang06898662010-06-17 17:52:18 -07004193.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07004194otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07004195
Tao Bao96daeeb2019-05-01 21:17:13 -07004196# For each module, recursively resolve its host shared library dependencies. Then we have a full
4197# list of modules whose installed files need to be packed.
4198INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
4199 $(sort $(INTERNAL_OTATOOLS_MODULES) \
4200 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004201
Tao Bao96daeeb2019-05-01 21:17:13 -07004202INTERNAL_OTATOOLS_PACKAGE_FILES := \
4203 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
4204
4205INTERNAL_OTATOOLS_PACKAGE_FILES += \
4206 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
4207 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07004208
4209ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07004210INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07004211 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004212 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004213endif
4214ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004215INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004216 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4217 -name "atx_metadata.bin"))
4218endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004219ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004220INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004221 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004222endif
4223
Tao Bao96daeeb2019-05-01 21:17:13 -07004224INTERNAL_OTATOOLS_RELEASETOOLS := \
4225 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4226 \( -type f -o -type l \) -print))
4227
4228BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4229$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4230$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4231$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4232$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004233$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004234 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004235 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4236 mkdir -p $(dir $@)
4237 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4238 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004239 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004240 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004241
4242.PHONY: otatools-package
4243otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4244
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004245endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004246
The Android Open Source Project88b60792009-03-03 19:28:42 -08004247# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004248# misc_info.txt
4249
4250INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4251
4252ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4253# default to common dir for device vendor
4254tool_extensions := $(TARGET_DEVICE_DIR)/../common
4255else
4256tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4257endif
4258.KATI_READONLY := tool_extensions
4259
Steve Muckle903a1ca2020-05-07 17:32:10 -07004260# $1: boot image file name
4261define misc_boot_size
4262$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4263endef
4264
Daniel Normane1e48082019-06-27 13:55:23 -07004265$(INSTALLED_MISC_INFO_TARGET):
4266 rm -f $@
4267 $(call pretty,"Target misc_info.txt: $@")
4268 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4269 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4270ifdef BOARD_FLASH_BLOCK_SIZE
4271 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4272endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004273ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4274 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4275 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004276endif
4277ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4278 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004279else
4280 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004281endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004282ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4283 echo "lz4_ramdisks=true" >> $@
4284endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004285ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4286 echo "vendor_boot=true" >> $@
4287 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4288endif
Daniel Normane1e48082019-06-27 13:55:23 -07004289ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4290 $(hide) echo "no_recovery=true" >> $@
4291endif
4292ifdef BOARD_INCLUDE_RECOVERY_DTBO
4293 $(hide) echo "include_recovery_dtbo=true" >> $@
4294endif
4295ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4296 $(hide) echo "include_recovery_acpio=true" >> $@
4297endif
4298ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4299 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4300endif
4301ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4302 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4303 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4304else
4305 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4306endif
4307 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4308 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4309ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4310 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4311endif
4312 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004313 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004314 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4315 $(hide) echo "multistage_support=1" >> $@
4316 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4317ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4318 $(hide) echo "build_generic_ota_package=true" >> $@
4319endif
4320ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4321 # OTA scripts are only interested in fingerprint related properties
4322 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4323endif
4324ifneq (,$(filter address, $(SANITIZE_TARGET)))
4325 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4326 $(hide) echo "userdata_img_with_data=true" >> $@
4327endif
4328ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4329 $(hide) echo "full_recovery_image=true" >> $@
4330endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004331ifdef BOARD_USES_VENDORIMAGE
4332 $(hide) echo "board_uses_vendorimage=true" >> $@
4333endif
Daniel Normane1e48082019-06-27 13:55:23 -07004334ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08004335ifeq ($(BUILDING_VBMETA_IMAGE),true)
4336 $(hide) echo "avb_building_vbmeta_image=true" >> $@
4337endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004338 $(hide) echo "avb_enable=true" >> $@
4339 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4340 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4341 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4342 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4343ifdef BOARD_AVB_BOOT_KEY_PATH
4344 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4345 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4346 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4347endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004348 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4349ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4350 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4351 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4352 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4353endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004354 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4355ifdef BOARD_AVB_RECOVERY_KEY_PATH
4356 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4357 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4358 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4359endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004360ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4361 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4362 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4363 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4364 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4365 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4366 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4367 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4368 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4369endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004370ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4371 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4372 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4373 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4374 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4375 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4376endif # BOARD_AVB_VBMETA_SYSTEM
4377ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4378 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4379 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4380 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4381 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4382 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4383endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4384endif # BOARD_AVB_ENABLE
4385ifdef BOARD_BPT_INPUT_FILES
4386 $(hide) echo "board_bpt_enable=true" >> $@
4387 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4388 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4389endif
4390ifdef BOARD_BPT_DISK_SIZE
4391 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4392endif
4393 $(call generate-userimage-prop-dictionary, $@)
4394ifeq ($(AB_OTA_UPDATER),true)
4395 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4396 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4397 $(hide) echo "ab_update=true" >> $@
4398endif
Yifan Hong65afc072020-04-17 10:08:10 -07004399ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4400 $(hide) echo "allow_non_ab=true" >> $@
4401endif
Daniel Normane1e48082019-06-27 13:55:23 -07004402ifdef BOARD_PREBUILT_DTBOIMAGE
4403 $(hide) echo "has_dtbo=true" >> $@
4404ifeq ($(BOARD_AVB_ENABLE),true)
4405 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4406 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4407ifdef BOARD_AVB_DTBO_KEY_PATH
4408 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4409 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4410 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4411endif # BOARD_AVB_DTBO_KEY_PATH
4412endif # BOARD_AVB_ENABLE
4413endif # BOARD_PREBUILT_DTBOIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00004414ifdef BOARD_PREBUILT_PVMFWIMAGE
4415 $(hide) echo "has_pvmfw=true" >> $@
4416ifeq ($(BOARD_AVB_ENABLE),true)
4417 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMG_PARTITION_SIZE)" >> $@
4418 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
4419ifdef BOARD_AVB_PVMFW_KEY_PATH
4420 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
4421 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
4422 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
4423endif # BOARD_AVB_PVMFW_KEY_PATH
4424endif # BOARD_AVB_ENABLE
4425endif # BOARD_PREBUILT_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004426 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004427 @# VINTF checks
4428ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4429 $(hide) echo "vintf_enforce=true" >> $@
4430endif
4431ifdef ODM_MANIFEST_SKUS
4432 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4433endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004434ifdef ODM_MANIFEST_FILES
4435 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4436endif
4437ifdef DEVICE_MANIFEST_SKUS
4438 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4439endif
4440ifdef DEVICE_MANIFEST_FILE
4441 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4442endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004443ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4444 $(hide) echo "bootloader_in_update_package=true" >> $@
4445endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07004446ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
4447 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
4448endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05004449ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
4450 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
4451endif
Daniel Normane1e48082019-06-27 13:55:23 -07004452
4453.PHONY: misc_info
4454misc_info: $(INSTALLED_MISC_INFO_TARGET)
4455
4456droidcore: $(INSTALLED_MISC_INFO_TARGET)
4457
4458# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004459# A zip of the directories that map to the target filesystem.
4460# This zip can be used to create an OTA package or filesystem image
4461# as a post-build step.
4462#
4463name := $(TARGET_PRODUCT)
4464ifeq ($(TARGET_BUILD_TYPE),debug)
4465 name := $(name)_debug
4466endif
4467name := $(name)-target_files-$(FILE_NAME_TAG)
4468
4469intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4470BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4471$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4472$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004473 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004474
4475# $(1): Directory to copy
4476# $(2): Location to copy it to
4477# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4478define package_files-copy-root
4479 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4480 mkdir -p $(2) && \
4481 $(ACP) -rd $(strip $(1))/* $(2); \
4482 fi
4483endef
4484
Tao Baoa04fca32015-11-30 12:22:24 -08004485built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004486
4487# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004488ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004489built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004490 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004491endif
4492
The Android Open Source Project88b60792009-03-03 19:28:42 -08004493$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4494
Dan Willemsen653bea92017-03-21 15:47:37 -07004495tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004496$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004497
Sen Jiang4438fd92016-03-07 16:51:01 -08004498ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004499updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004500endif
4501
4502# Build OTA tools if non-A/B is allowed
4503ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004504updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004505endif
Yifan Hong65afc072020-04-17 10:08:10 -07004506
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004507$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004508
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004509# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07004510# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004511ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4512$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07004513else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
4514$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004515else
4516$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4517endif
4518
Dan Willemsen653bea92017-03-21 15:47:37 -07004519ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004520 ifdef OSRELEASED_DIRECTORY
4521 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4522 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4523 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4524 endif
Tao Baoa835f382019-07-18 15:55:30 -07004525
4526 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4527 # additionally include radio or bootloader partitions).
4528 ifeq ($(AB_OTA_PARTITIONS),)
4529 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4530 endif
4531endif
4532
4533ifneq ($(AB_OTA_PARTITIONS),)
4534 ifneq ($(AB_OTA_UPDATER),true)
4535 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4536 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004537endif
4538
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004539# Run fs_config while creating the target files package
4540# $1: root directory
4541# $2: add prefix
4542define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004543(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 -08004544endef
4545
Yifan Hong60bfcc42019-11-01 11:39:45 -07004546# Filter out vendor from the list for AOSP targets.
4547# $(1): list
4548define filter-out-missing-vendor
4549$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4550endef
4551
4552# Information related to dynamic partitions and virtual A/B. This information
4553# is needed for building the super image (see dump-super-image-info) and
4554# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004555# $(1): file
4556define dump-dynamic-partitions-info
4557 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4558 echo "use_dynamic_partitions=true" >> $(1))
4559 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4560 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004561 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4562 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4563 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004564 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4565 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004566 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4567 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4568 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4569 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4570 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4571 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004572 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004573 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4574 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4575 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4576 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4577 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004578 echo "super_$(group)_partition_list=$(call filter-out-missing-vendor,$(BOARD_$(call to-upper,$(group))_PARTITION_LIST))" >> $(1);))
Yifan Hongcb35bd92019-04-02 16:29:59 -07004579 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4580 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004581 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4582 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004583 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4584 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004585 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4586 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4587 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4588 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4589 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4590 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4591 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4592 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004593 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4594 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05004595 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
4596 echo "virtual_ab_compression=true" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004597 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4598 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004599endef
4600
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004601# By conditionally including the dependency of the target files package on the
4602# full system image deps, we speed up builds that do not build the system
4603# image.
4604ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004605 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4606endif
4607
4608ifdef BUILDING_USERDATA_IMAGE
4609 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4610endif
4611
4612ifdef BUILDING_SYSTEM_OTHER_IMAGE
4613 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4614endif
4615
4616ifdef BUILDING_VENDOR_BOOT_IMAGE
4617 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08004618 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Colin Crosse6431202021-02-24 11:44:55 -08004619 # The vendor ramdisk may be built from the recovery ramdisk.
4620 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
4621 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
4622 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07004623endif
4624
4625ifdef BUILDING_RECOVERY_IMAGE
4626 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08004627 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07004628 # commands in build-recoveryimage-target, which would touch the files under
4629 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4630 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4631 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4632 else
4633 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4634 endif
4635 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4636endif
4637
4638# Conditionally depend on the image files if the image is being built so the
4639# target-files.zip rule doesn't wait on the image creation rule, or the image
4640# if it is coming from a prebuilt.
4641
4642ifdef BUILDING_VENDOR_IMAGE
4643 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4644else ifdef BOARD_PREBUILT_VENDORIMAGE
4645 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4646endif
4647
4648ifdef BUILDING_PRODUCT_IMAGE
4649 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4650else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4651 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4652endif
4653
4654ifdef BUILDING_SYSTEM_EXT_IMAGE
4655 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4656else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4657 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4658endif
4659
4660ifdef BUILDING_BOOT_IMAGE
4661 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Yifan Hong49968aa2020-11-09 11:52:52 -08004662endif
4663ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07004664 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4665endif
4666
4667ifdef BUILDING_ODM_IMAGE
4668 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4669else ifdef BOARD_PREBUILT_ODMIMAGE
4670 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4671endif
4672
4673ifdef BUILDING_VENDOR_DLKM_IMAGE
4674 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
4675else ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4676 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4677endif
4678
4679ifdef BUILDING_ODM_DLKM_IMAGE
4680 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
4681else ifdef BOARD_ODM_VENDOR_DLKIMMAGE
4682 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004683endif
4684
Isaac Chen9e09d472019-07-05 17:30:41 +08004685ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004686 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4687 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004688endif
4689
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004690ifdef BOARD_PREBUILT_BOOTLOADER
4691$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004692droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004693endif
4694
The Android Open Source Project88b60792009-03-03 19:28:42 -08004695# Depending on the various images guarantees that the underlying
4696# directories are up-to-date.
4697$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004698 $(INSTALLED_RADIOIMAGE_TARGET) \
4699 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004700 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004701 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004702 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004703 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004704 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4705 $(INSTALLED_KERNEL_TARGET) \
Enrico Granata16059382020-10-14 15:17:20 -06004706 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004707 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004708 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4709 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004710 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004711 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004712 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4713 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4714 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004715 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004716 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004717 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004718 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004719 $(LPMAKE) \
4720 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004721 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004722 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004723 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004724 $(SOONG_ZIP) \
4725 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004726 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004727 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004728 $(BUILT_KERNEL_CONFIGS_FILE) \
4729 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004730 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004731 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004732 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004733 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07004734ifneq (,$(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 -08004735 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004736 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004737 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004738 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004739ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004740ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004741 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07004742else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07004743 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4744endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004745endif
Yifan Hong78860162020-10-28 14:15:21 -07004746ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004747ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004748 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004749endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004750ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004751ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004752 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004753else
Steve Mucklee1b10862019-07-10 10:49:37 -07004754 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004755endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004756endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004757ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004758 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004759endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004760ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004761 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004762endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004763ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004764ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004765 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07004766endif # INTERNAL_KERNEL_CMDLINE != ""
4767endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07004768ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004769 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004770endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004771ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004772 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004773endif
Yifan Hong3941a872020-10-28 16:33:06 -07004774endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004775endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004776 @# Components of the boot image
4777 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004778 $(hide) mkdir -p $(zip_root)/ROOT
4779 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004780 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004781 @# If we are using recovery as boot, this is already done when processing recovery.
4782ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004783ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004784 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004785 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004786endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004787ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004788 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004789endif
Yifan Hong46aff092020-10-28 13:50:47 -07004790ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07004791 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07004792else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07004793 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004794ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004795 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004796endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004797ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004798 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004799endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004800ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004801 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004802endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004803ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004804 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004805endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004806endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07004807endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004808 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4809 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004810 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004811ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4812 mkdir -p $(zip_root)/VENDOR_BOOT
4813 $(call package_files-copy-root, \
4814 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4815ifdef INSTALLED_DTBIMAGE_TARGET
4816 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4817endif
Devin Moore50509012021-01-13 10:45:04 -08004818ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
4819 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
4820endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004821ifdef BOARD_KERNEL_BASE
4822 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4823endif
4824ifdef BOARD_KERNEL_PAGESIZE
4825 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4826endif
4827 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yo Chiangd21e7dc2020-12-10 18:42:47 +08004828ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
4829 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
4830 $(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
4831 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
4832 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
4833 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
4834 $(if $(prebuilt_ramdisk), \
4835 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
4836 $(call package_files-copy-root, \
4837 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
4838 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
4839 ))
4840endif # BOARD_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07004841endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004842ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004843 @# Contents of the system image
4844 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004845 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004846endif
4847ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004848 @# Contents of the data image
4849 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004850 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004851endif
4852ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004853 @# Contents of the vendor image
4854 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004855 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004856endif
Dan Willemsen67495202019-01-16 12:42:05 -08004857ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004858 @# Contents of the product image
4859 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004860 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004861endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004862ifdef BUILDING_SYSTEM_EXT_IMAGE
4863 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004864 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004865 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004866endif
Dan Willemsen67495202019-01-16 12:42:05 -08004867ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004868 @# Contents of the odm image
4869 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004870 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004871endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004872ifdef BUILDING_VENDOR_DLKM_IMAGE
4873 @# Contents of the vendor_dlkm image
4874 $(hide) $(call package_files-copy-root, \
4875 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4876endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004877ifdef BUILDING_ODM_DLKM_IMAGE
4878 @# Contents of the odm_dlkm image
4879 $(hide) $(call package_files-copy-root, \
4880 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4881endif
Dan Willemsen67495202019-01-16 12:42:05 -08004882ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004883 @# Contents of the system_other image
4884 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004885 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004886endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004887 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004888 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004889 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granata16059382020-10-14 15:17:20 -06004890ifdef BUILDING_RAMDISK_IMAGE
4891ifeq (true,$(BOARD_IMG_USE_RAMDISK))
4892 @# Contents of the ramdisk image
4893 $(hide) mkdir -p $(zip_root)/IMAGES
4894 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
4895endif
4896endif
Yifan Hong65afc072020-04-17 10:08:10 -07004897ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004898ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004899 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004900 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004901endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004902endif
Doug Zongker8678df42009-06-15 14:30:14 -07004903 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004904 @# build them.
4905 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004906 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004907 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004908ifneq ($(tool_extension),)
4909 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4910endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004911 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004912 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004913 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004914ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4915 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4916 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004917endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004918ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4919 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4920 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004921endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004922ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4923 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4924 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004925endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004926ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4927 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4928 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004929endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004930ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4931 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4932 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004933endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004934ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4935 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4936 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4937endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004938ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4939 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4940 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4941endif
Yifan Hong65afc072020-04-17 10:08:10 -07004942ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004943ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004944 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004945 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004946endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004947endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004948ifeq ($(AB_OTA_UPDATER),true)
4949 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004950 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004951 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004952 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4953 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004954 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4955 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4956 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004957ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004958 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4959 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4960 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004961endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004962endif
Steve Fungdfbab492015-09-24 18:12:33 -07004963ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004964 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004965 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004966endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004967ifdef BOARD_PREBUILT_VENDORIMAGE
4968 $(hide) mkdir -p $(zip_root)/IMAGES
4969 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4970endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004971ifdef BOARD_PREBUILT_PRODUCTIMAGE
4972 $(hide) mkdir -p $(zip_root)/IMAGES
4973 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4974endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004975ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004976 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004977 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004978endif
Yifan Hong49968aa2020-11-09 11:52:52 -08004979ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
4980ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004981 $(hide) mkdir -p $(zip_root)/IMAGES
4982 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08004983endif # INSTALLED_BOOTIMAGE_TARGET
4984endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004985ifdef BOARD_PREBUILT_ODMIMAGE
4986 $(hide) mkdir -p $(zip_root)/IMAGES
4987 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4988endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004989ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004990 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004991 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4992endif
4993ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
4994 $(hide) mkdir -p $(zip_root)/IMAGES
4995 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07004996endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004997ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004998 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4999 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08005000endif # BOARD_PREBUILT_DTBOIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00005001ifdef BOARD_PREBUILT_PVMFWIMAGE
5002 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5003 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5004endif # BOARD_PREBUILT_PVMFWIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005005ifdef BOARD_PREBUILT_BOOTLOADER
5006 $(hide) mkdir -p $(zip_root)/IMAGES
5007 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
5008endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07005009ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
5010 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5011 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5012 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
5013endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07005014 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
5015 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
5016 @# INSTALLED_RADIOIMAGE_TARGET.
5017 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
5018 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005019 @# Run fs_config on all the system, vendor, boot ramdisk,
5020 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08005021ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005022 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08005023endif
5024ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005025 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
5026endif
Dan Willemsen67495202019-01-16 12:42:05 -08005027ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005028 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
5029endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005030ifdef BUILDING_SYSTEM_EXT_IMAGE
5031 $(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 +01005032endif
Dan Willemsen67495202019-01-16 12:42:05 -08005033ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005034 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
5035endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005036ifdef BUILDING_VENDOR_DLKM_IMAGE
5037 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
5038endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005039ifdef BUILDING_ODM_DLKM_IMAGE
5040 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
5041endif
Tom Cherryd14b8952018-08-09 14:26:00 -07005042 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005043 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005044ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07005045 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005046 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005047endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005048ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5049 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
5050endif
Tom Cherry2929cad2018-09-20 11:04:37 -07005051ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
5052 @# 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 -08005053 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
5054endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005055ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5056 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
5057endif
Dan Willemsen67495202019-01-16 12:42:05 -08005058ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005059 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
5060endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07005061 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07005062ifdef BUILT_KERNEL_CONFIGS_FILE
5063 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
5064endif
5065ifdef BUILT_KERNEL_VERSION_FILE
5066 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
5067endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07005068 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
5069ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5070 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
5071endif
Tao Baocbd6d492019-10-07 22:46:02 -07005072 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
5073 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08005074ifeq ($(BUILD_QEMU_IMAGES),true)
5075 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
5076 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
5077endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08005078 @# Zip everything up, preserving symlinks and placing META/ files first to
5079 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005080 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07005081 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08005082 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07005083
Ying Wanga0febe52013-03-20 11:02:05 -07005084.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08005085target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
5086
Ying Wang4709d7c2014-04-14 17:25:43 -07005087$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07005088
Dan Albert4d323332016-10-14 13:23:06 -07005089# -----------------------------------------------------------------
5090# NDK Sysroot Package
5091NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07005092$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07005093 @echo Package NDK sysroot...
5094 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
5095
5096$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
5097
Ying Wang09c4b682015-08-11 11:24:19 -07005098ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07005099# -----------------------------------------------------------------
5100# OTA update package
5101
Yifan Hong50e79542018-11-08 17:44:12 -08005102# $(1): output file
5103# $(2): additional args
5104define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07005105PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07005106 $(OTA_FROM_TARGET_FILES) \
5107 --verbose \
5108 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
5109 --path $(HOST_OUT) \
5110 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
5111 $(2) \
5112 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08005113endef
5114
Tianjie6bd3b1a2020-10-16 18:53:47 -07005115product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07005116ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005117 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07005118endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07005119name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07005120
5121INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08005122INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
5123
Doug Zongker8678df42009-06-15 14:30:14 -07005124$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08005125$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07005126$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07005127 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08005128 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07005129
5130.PHONY: otapackage
5131otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
5132
Tao Bao519d1822018-12-27 12:47:23 -08005133ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005134name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08005135
5136INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08005137$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07005138$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
5139 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07005140 $(OTA_FROM_TARGET_FILES) \
5141 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08005142 @echo "Package OTA (retrofit dynamic partitions): $@"
5143 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
5144
5145.PHONY: otardppackage
5146
5147otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
5148
Tao Bao519d1822018-12-27 12:47:23 -08005149endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08005150
Tianjie6bd3b1a2020-10-16 18:53:47 -07005151ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5152name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
5153
5154INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5155$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
5156$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
5157 @echo "Package partial OTA: $@"
5158 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
5159
5160.PHONY: partialotapackage
5161partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
5162
5163endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
5164
Ying Wang09c4b682015-08-11 11:24:19 -07005165endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07005166
Ying Wang09a00a62010-10-20 14:01:09 -07005167# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01005168# A zip of the appcompat directory containing logs
5169APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
5170# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005171ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07005172$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
5173 $(INTERNAL_RAMDISK_FILES) \
5174 $(INTERNAL_USERDATAIMAGE_FILES) \
5175 $(INTERNAL_VENDORIMAGE_FILES) \
5176 $(INTERNAL_PRODUCTIMAGE_FILES) \
5177 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01005178endif
5179$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
5180$(APPCOMPAT_ZIP): $(SOONG_ZIP)
5181 @echo "appcompat logs: $@"
5182 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5183 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
5184 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
5185 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
5186
Dario Frenid1011272018-07-23 20:20:15 +01005187# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005188# A zip of the symbols directory. Keep the full paths to make it
5189# more obvious where these files came from.
5190#
5191name := $(TARGET_PRODUCT)
5192ifeq ($(TARGET_BUILD_TYPE),debug)
5193 name := $(name)_debug
5194endif
5195name := $(name)-symbols-$(FILE_NAME_TAG)
5196
5197SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07005198# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005199ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005200$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07005201endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005202$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
5203$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005204 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005205 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5206 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09005207 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07005208 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005209# -----------------------------------------------------------------
5210# A zip of the coverage directory.
5211#
Oliver Nguyene91ab232019-04-30 15:14:44 -07005212name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07005213ifeq ($(TARGET_BUILD_TYPE),debug)
5214name := $(name)_debug
5215endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07005216COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005217ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005218$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005219endif
5220$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
5221$(COVERAGE_ZIP): $(SOONG_ZIP)
5222 @echo "Package coverage: $@"
5223 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5224 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
5225 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
5226 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005227
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08005228#------------------------------------------------------------------
5229# Export the LLVM profile data tool and dependencies for Clang coverage processing
5230#
5231ifeq (true,$(CLANG_COVERAGE))
5232 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
5233 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
5234 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
5235 $(PROFDATA_ZIP): $(SOONG_ZIP)
5236 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
5237
5238 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
5239endif
5240
The Android Open Source Project88b60792009-03-03 19:28:42 -08005241# -----------------------------------------------------------------
5242# A zip of the Android Apps. Not keeping full path so that we don't
5243# include product names when distributing
5244#
5245name := $(TARGET_PRODUCT)
5246ifeq ($(TARGET_BUILD_TYPE),debug)
5247 name := $(name)_debug
5248endif
5249name := $(name)-apps-$(FILE_NAME_TAG)
5250
5251APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07005252$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005253 @echo "Package apps: $@"
5254 $(hide) rm -rf $@
5255 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005256 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
5257 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00005258 echo "No apps to zip up. Generating empty apps archive." ; \
5259 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005260 else \
Anton Hansson6d814982018-11-26 18:12:05 +00005261 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005262 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07005263
Ying Wangbc415dd2012-08-15 12:22:44 -07005264ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07005265#------------------------------------------------------------------
5266# An archive of classes for use in generating code-coverage reports
5267# These are the uninstrumented versions of any classes that were
5268# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07005269# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005270
Colin Crossa6bc3a82017-09-27 14:28:41 -07005271JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005272$(JACOCO_REPORT_CLASSES_ALL) :
5273 @echo "Collecting uninstrumented classes"
Colin Crosse8ac9952020-10-09 18:41:58 -07005274 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 -08005275 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005276
Jiyong Park3c875602021-01-21 12:46:56 +09005277ifeq (,$(TARGET_BUILD_UNBUNDLED))
5278 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
5279endif
Ying Wangbc415dd2012-08-15 12:22:44 -07005280endif # EMMA_INSTRUMENT=true
5281
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005282
Ying Wangae9115a2013-08-22 20:52:47 -07005283#------------------------------------------------------------------
5284# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07005285#
Ying Wangc62c92c2013-08-28 18:38:25 -07005286PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07005287# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005288ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005289$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07005290endif
5291$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
5292$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07005293 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07005294 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5295 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
5296 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
5297 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07005298
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005299#------------------------------------------------------------------
5300# A zip of Proguard usage files.
5301#
5302PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
5303# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
5304ifeq (,$(TARGET_BUILD_UNBUNDLED))
5305$(PROGUARD_USAGE_ZIP): \
5306 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5307 $(INSTALLED_RAMDISK_TARGET) \
5308 $(INSTALLED_BOOTIMAGE_TARGET) \
5309 $(INSTALLED_USERDATAIMAGE_TARGET) \
5310 $(INSTALLED_VENDORIMAGE_TARGET) \
5311 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5312 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
5313 $(INSTALLED_ODMIMAGE_TARGET) \
5314 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
5315 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
5316 $(updater_dep)
5317endif
5318$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
5319$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
5320 @echo "Packaging Proguard usage files."
5321 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5322 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
5323 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07005324
5325ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5326
5327# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
5328# $(1): output file
5329define dump-super-image-info
5330 $(call dump-dynamic-partitions-info,$(1))
5331 $(if $(filter true,$(AB_OTA_UPDATER)), \
5332 echo "ab_update=true" >> $(1))
5333endef
5334
5335endif # PRODUCT_USE_DYNAMIC_PARTITIONS
5336
The Android Open Source Project88b60792009-03-03 19:28:42 -08005337# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005338# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005339
5340ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5341
5342# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5343ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5344
5345ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005346
5347# For real devices and for dist builds, build super image from target files to an intermediate directory.
5348INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5349$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5350$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5351 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005352 PATH=$(dir $(LPMAKE)):$$PATH \
5353 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005354
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005355# Skip packing it in dist package because it is in update package.
5356ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005357$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005358endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005359
5360.PHONY: superimage_dist
5361superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005362
5363endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005364endif # BOARD_SUPER_PARTITION_SIZE != ""
5365endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005366
Yifan Hongacd862a2019-04-16 15:44:30 -07005367# -----------------------------------------------------------------
5368# super partition image for development
5369
5370ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5371ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5372ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5373
5374# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5375# $(1): built image path
5376# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5377define build-superimage-target
5378 mkdir -p $(dir $(2))
5379 rm -rf $(2)
5380 $(call dump-super-image-info,$(2))
5381 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5382 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005383 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5384 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005385 mkdir -p $(dir $(1))
5386 PATH=$(dir $(LPMAKE)):$$PATH \
5387 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5388endef
5389
5390INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5391INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5392 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5393
changho.shina8f9f112019-10-15 13:26:19 +09005394ifdef BUILDING_SYSTEM_OTHER_IMAGE
5395ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5396INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5397endif
5398endif
5399
Yifan Hongacd862a2019-04-16 15:44:30 -07005400# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5401# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5402# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5403# virtual devices.
5404ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5405$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5406 $(call pretty,"Target super fs image for debug: $@")
5407 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005408 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005409
5410droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5411
5412# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5413.PHONY: superimage
5414superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005415
5416$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005417endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5418
5419# Build $(PRODUCT_OUT)/super.img without dependencies.
5420.PHONY: superimage-nodeps supernod
5421superimage-nodeps supernod: intermediates :=
5422superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5423 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5424 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5425 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5426
5427endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5428endif # BOARD_SUPER_PARTITION_SIZE != ""
5429endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5430
5431# -----------------------------------------------------------------
5432# super empty image
5433
Tao Bao48a2feb2019-06-28 11:00:05 -07005434ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005435ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005436
Yifan Hong8b79d162018-11-29 12:32:00 -08005437INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5438$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5439$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5440 $(call pretty,"Target empty super fs image: $@")
5441 mkdir -p $(intermediates)
5442 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005443 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005444 PATH=$(dir $(LPMAKE)):$$PATH \
5445 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005446
5447$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5448
Yifan Hong2b891ac2018-11-29 12:06:31 -08005449endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005450endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005451
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005452
5453# -----------------------------------------------------------------
5454# The update package
5455
5456name := $(TARGET_PRODUCT)
5457ifeq ($(TARGET_BUILD_TYPE),debug)
5458 name := $(name)_debug
5459endif
5460name := $(name)-img-$(FILE_NAME_TAG)
5461
5462INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5463
Tao Bao57f8ed62019-08-14 23:08:18 -07005464$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5465 $(call pretty,"Package: $@")
5466 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5467 $(IMG_FROM_TARGET_FILES) \
5468 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5469 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005470
5471.PHONY: updatepackage
5472updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005473$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005474
5475
Yifan Hong2b891ac2018-11-29 12:06:31 -08005476# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005477# dalvik something
5478.PHONY: dalvikfiles
5479dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5480
Bo Huf0d50bb2017-08-01 19:02:09 +00005481ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005482MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005483MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005484SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005485
5486ifdef INSTALLED_SYSTEMIMAGE_TARGET
5487INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005488INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5489$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5490 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5491 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005492$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005493 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5494 @echo Create system-qemu.img now
5495 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005496 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005497
5498systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5499droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005500endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005501ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005502INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005503$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005504 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005505 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005506
5507vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5508droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5509endif
bohu8fd437c2020-03-30 20:16:13 -07005510
5511ifdef INSTALLED_RAMDISK_TARGET
5512ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5513ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5514INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5515$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5516 @echo Create ramdisk-qemu.img
5517 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5518
5519droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5520endif
5521endif
5522endif
5523
Anton Hansson32c76fe2018-12-13 14:34:18 +00005524ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005525INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005526$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005527 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005528 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005529
5530productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5531droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5532endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005533ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5534INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5535$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5536 @echo Create system_ext-qemu.img
5537 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005538
Justin Yun6151e3f2019-06-25 15:58:13 +09005539systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5540droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005541endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005542ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005543INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5544$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5545 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005546 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005547
5548odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5549droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5550endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005551
Yifan Hongcfb917a2020-05-07 14:58:20 -07005552ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5553INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5554$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5555 @echo Create vendor_dlkm-qemu.img
5556 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5557
5558vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5559droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5560endif
5561
Yifan Hongf496f1b2020-07-15 16:52:59 -07005562ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5563INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5564$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5565 @echo Create odm_dlkm-qemu.img
5566 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5567
5568odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5569droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5570endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005571
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005572QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005573$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5574 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005575 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005576 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5577 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005578
5579systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5580droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005581
Bo Huf0d50bb2017-08-01 19:02:09 +00005582endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005583# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005584# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005585ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005586INTERNAL_EMULATOR_PACKAGE_FILES += \
5587 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005588 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005589 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005590 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5591 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005592
5593name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5594
5595INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5596
Ying Wang5d887702015-11-04 10:06:25 -08005597$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005598 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005599 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005600
Ying Wang7d8c5352012-07-26 10:15:21 -07005601endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005602
The Android Open Source Project88b60792009-03-03 19:28:42 -08005603
5604# -----------------------------------------------------------------
5605# The SDK
5606
The Android Open Source Project88b60792009-03-03 19:28:42 -08005607# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005608sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005609
5610# Build a name that looks like:
5611#
5612# linux-x86 --> android-sdk_12345_linux-x86
5613# darwin-x86 --> android-sdk_12345_mac-x86
5614# windows-x86 --> android-sdk_12345_windows
5615#
5616sdk_name := android-sdk_$(FILE_NAME_TAG)
5617ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005618 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005619else
Joe Onorato03fbe402009-04-13 08:31:16 -07005620 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005621endif
5622ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005623 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005624endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005625sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005626
5627sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5628
5629ATREE_FILES :=
5630-include $(sdk_dep_file)
5631
5632# if we don't have a real list, then use "everything"
5633ifeq ($(strip $(ATREE_FILES)),)
5634ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005635 $(ALL_DEFAULT_INSTALLED_MODULES) \
5636 $(INSTALLED_RAMDISK_TARGET) \
5637 $(ALL_DOCS) \
5638 $(ALL_SDK_FILES)
5639endif
5640
5641atree_dir := development/build
5642
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005643
The Android Open Source Project88b60792009-03-03 19:28:42 -08005644sdk_atree_files := \
5645 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005646 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005647
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005648# development/build/sdk-android-<abi>.atree is used to differentiate
5649# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5650# files like the kernel image. We use TARGET_CPU_ABI because we don't
5651# have a better way to distinguish between CPU models.
5652ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5653 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5654endif
5655
Anton Hansson8dab0a62019-03-28 15:45:40 +00005656ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5657sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005658else
5659sdk_atree_files += $(atree_dir)/sdk.atree
5660endif
5661
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005662include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005663
The Android Open Source Project88b60792009-03-03 19:28:42 -08005664deps := \
5665 $(target_notice_file_txt) \
5666 $(tools_notice_file_txt) \
5667 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005668 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005669 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005670 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005671 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005672 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005673 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005674 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005675 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005676 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005677 $(INSTALLED_USERDATAIMAGE_TARGET) \
5678 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005679 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005680 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005681 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005682 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005683 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005684 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005685 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005686
5687INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5688$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5689$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5690$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5691$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5692
5693# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5694#
5695#SDK_GNU_ERROR := true
5696
Ying Wang5d887702015-11-04 10:06:25 -08005697$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005698 @echo "Package SDK: $@"
5699 $(hide) rm -rf $(PRIVATE_DIR) $@
5700 $(hide) for f in $(target_gnu_MODULES); do \
5701 if [ -f $$f ]; then \
5702 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5703 including GNU target $$f >&2; \
5704 FAIL=$(SDK_GNU_ERROR); \
5705 fi; \
5706 done; \
5707 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005708 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005709 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005710 ATREE_STRIP="$(HOST_STRIP) -x" \
5711 $(HOST_OUT_EXECUTABLES)/atree \
5712 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5713 -m $(PRIVATE_DEP_FILE) \
5714 -I . \
5715 -I $(PRODUCT_OUT) \
5716 -I $(HOST_OUT) \
5717 -I $(TARGET_COMMON_OUT_ROOT) \
5718 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5719 -v "OUT_DIR=$(OUT_DIR)" \
5720 -v "HOST_OUT=$(HOST_OUT)" \
5721 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5722 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5723 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5724 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5725 -o $(PRIVATE_DIR) && \
5726 cp -f $(target_notice_file_txt) \
5727 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5728 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5729 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5730 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5731 chmod -R ug+rwX $(PRIVATE_DIR) && \
5732 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005733 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5734
Raphael3d224a02010-04-16 17:50:09 -07005735
5736# Is a Windows SDK requested? If so, we need some definitions from here
5737# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005738MAIN_SDK_NAME := $(sdk_name)
5739MAIN_SDK_DIR := $(sdk_dir)
5740MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005741ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005742include $(TOPDIR)development/build/tools/windows_sdk.mk
5743endif
5744
The Android Open Source Project88b60792009-03-03 19:28:42 -08005745# -----------------------------------------------------------------
5746# Findbugs
5747INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5748INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5749$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5750 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005751 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005752 > $@
5753$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5754 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005755 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005756 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005757
5758# -----------------------------------------------------------------
5759# Findbugs
5760
5761# -----------------------------------------------------------------
5762# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005763ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005764include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005765-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005766-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005767-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005768# Also the project-specific tasks
5769-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5770-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005771-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005772# Also add test specifc tasks
5773include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005774include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005775endif
Raphaelc4d47312011-02-15 16:09:36 -08005776
Ying Wang67132ba2015-10-28 16:42:39 -07005777include $(BUILD_SYSTEM)/product-graph.mk
5778
Raphaelc4d47312011-02-15 16:09:36 -08005779# -----------------------------------------------------------------
5780# Create SDK repository packages. Must be done after tasks/* since
5781# we need the addon rules defined.
5782ifneq ($(sdk_repo_goal),)
5783include $(TOPDIR)development/build/tools/sdk_repo.mk
5784endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005785
5786# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005787# Soong generates the list of all shared libraries that are depended on by fuzz
5788# targets. It saves this list as a source:destination pair to
5789# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5790# build of the unstripped shared library, and the destination is the
5791# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5792# where fuzz target shared libraries are to be "reinstalled". The
5793# copy-many-files below generates the rules to copy the unstripped shared
5794# libraries to the device or host "reinstallation" directory. These rules are
5795# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5796# a dependency on each shared library that it needs to be "reinstalled".
5797FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5798
5799# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005800# The rule to build all fuzz targets, and package them.
5801# Note: The packages are created in Soong, and in a perfect world,
5802# we'd be able to create the phony rule there. But, if we want to
5803# have dist goals for the fuzz target, we need to have the PHONY
5804# target defined in make. MakeVarsContext.DistForGoal doesn't take
5805# into account that a PHONY rule create by Soong won't be available
5806# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005807# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005808# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005809.PHONY: haiku
5810haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5811$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))