blob: 02f60cf9bbe0e657a17b4aa3e82848556f6cb831 [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)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002393 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2394 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2395 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002396 cp -f $(debug_file) $(patsubst $(DEBUG_RAMDISK_DIR)/%,$(VENDOR_DEBUG_RAMDISK_DIR)/%,$(debug_file)) &&) true
Bowgo Tsaiceaa4112021-01-19 13:55:42 +08002397 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_RAMDISK_DIR) $(VENDOR_DEBUG_RAMDISK_DIR) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002398
Petri Gyntherd7946d12021-03-10 12:38:15 -08002399ifeq (true,$(BOARD_BUILD_VENDOR_RAMDISK_IMAGE))
2400INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
2401$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
2402 $(call pretty,"Target vendor debug ramdisk: $@")
2403 $(copy-file-to-target)
2404endif
2405
Bowgo Tsai6a683672020-02-14 19:00:15 +08002406INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2407INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2408$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2409$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2410
2411# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2412# 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 +08002413$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002414$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Petri Gynther728e0bd2021-03-06 13:29:28 -08002415 @echo Installed file list: $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002416 mkdir -p $(dir $@)
2417 rm -f $@
2418 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2419 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2420
2421# -----------------------------------------------------------------
2422# vendor_boot-debug.img.
2423INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2424
2425# The util to sign vendor_boot-debug.img with a test key.
2426BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2427INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2428# $(1): the vendor bootimage to sign
2429define test-key-sign-vendor-bootimage
2430$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2431$(AVBTOOL) add_hash_footer \
2432 --image $(1) \
2433 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2434 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2435 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2436$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2437endef
2438
2439ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2440$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2441endif
2442
2443# 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 +08002444$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08002445$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002446 $(call pretty,"Target vendor_boot debug image: $@")
Bowgo Tsai7ac96032021-01-20 16:29:49 +08002447 $(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 +08002448 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2449 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2450
2451endif # BUILDING_RAMDISK_IMAGE
2452endif # BUILDING_VENDOR_BOOT_IMAGE
2453
Bowgo Tsai0013f552019-03-20 17:59:52 +08002454# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002455# The test harness ramdisk, which is based off debug_ramdisk, plus a
2456# few additional test-harness-specific properties in adb_debug.prop.
2457
2458ifdef BUILDING_RAMDISK_IMAGE
2459BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2460INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2461
2462# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2463# appends a few test harness specific properties into the adb_debug.prop.
2464TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2465TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2466
2467# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2468# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2469TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2470ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2471ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2472
2473# $(1): a list of key=value pairs for additional property assignments
2474# $(2): the target .prop file to append the properties from $(1)
2475define append-test-harness-props
2476 echo "#" >> $(2); \
2477 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2478 echo "#" >> $(2);
2479 $(foreach line,$(1), echo "$(line)" >> $(2);)
2480endef
2481
2482$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002483$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Petri Gynther4c063e32021-03-06 13:26:01 -08002484 $(call pretty,"Target test harness ramdisk: $@")
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002485 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2486 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002487 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002488
2489.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002490ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002491 echo "make $@: ignoring dependencies"
2492 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2493 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002494 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002495
2496endif # BUILDING_RAMDISK_IMAGE
2497
2498# -----------------------------------------------------------------
2499# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2500#
2501# Note: it's intentional to skip signing for boot-test-harness.img, because it
2502# can only be used if the device is unlocked with verification error.
2503ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2504
Steve Muckle4866bd62020-04-02 11:31:08 -07002505ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2506 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2507 $(PRODUCT_OUT)/$(k).img)
2508else
2509 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2510endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002511
2512# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2513INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2514
2515# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2516# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2517# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2518# public key, if the device is unlocked.
2519ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2520$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2521endif
2522
Steve Muckle4866bd62020-04-02 11:31:08 -07002523# $(1): output file
2524define build-boot-test-harness-target
2525 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2526 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsaif85e68f2021-03-04 14:41:16 +08002527 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
Steve Muckle4866bd62020-04-02 11:31:08 -07002528endef
2529
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002530# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2531$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2532 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002533 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002534
2535.PHONY: bootimage_test_harness-nodeps
2536bootimage_test_harness-nodeps: $(MKBOOTIMG)
2537 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002538 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002539
2540endif # TARGET_NO_KERNEL
2541endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2542
Colin Crossbd382142020-08-26 15:08:57 -07002543# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
2544# $1: from location (e.g $(TARGET_OUT)/vendor)
2545# $2: destination location (e.g. /vendor)
2546# $3: partition image name (e.g. vendor.img)
2547define create-partition-compat-symlink
2548$(eval \
2549$1:
2550 @echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
2551 mkdir -p $(dir $1)
2552 if [ -d $1 ] && [ ! -h $1 ]; then \
2553 echo 'Non-symlink $1 detected!' 1>&2; \
2554 echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
2555 exit 1; \
2556 fi
2557 ln -sfn $2 $1
Jingwen Chen7d7f9452020-09-22 13:47:13 +00002558$1: .KATI_SYMLINK_OUTPUTS := $1
Colin Crossbd382142020-08-26 15:08:57 -07002559)
2560$1
2561endef
2562
2563
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002564# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002565# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002566
Dan Willemsen37a19862018-10-31 16:31:46 -07002567INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002568 $(ALL_GENERATED_SOURCES) \
Dan Willemsena3f66322020-05-28 15:46:33 -07002569 $(ALL_DEFAULT_INSTALLED_MODULES)))
Ying Wang160b6702012-03-13 18:58:27 -07002570
Colin Crossbd382142020-08-26 15:08:57 -07002571# Create symlink /system/vendor to /vendor if necessary.
2572ifdef BOARD_USES_VENDORIMAGE
2573 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
2574endif
2575
2576# Create symlink /system/product to /product if necessary.
2577ifdef BOARD_USES_PRODUCTIMAGE
2578 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
2579endif
2580
2581# Create symlink /system/system_ext to /system_ext if necessary.
2582ifdef BOARD_USES_SYSTEM_EXTIMAGE
2583 INTERNAL_SYSTEMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
2584endif
2585
Ying Wang82cceba2012-08-13 15:03:00 -07002586FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002587
2588# ASAN libraries in the system image - add dependency.
2589ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002590ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002591 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2592 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2593 endif
2594endif
2595
Tom Cherryd14b8952018-08-09 14:26:00 -07002596FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002597
Ying Wange5e8c5f2011-09-09 16:35:53 -07002598# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002599ifdef BUILDING_SYSTEM_IMAGE
2600
Kiyoung Kim36481e02020-11-16 10:50:05 +09002601# Install system linker configuration
2602# Collect all available stub libraries installed in system and install with predefined linker configuration
2603SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
2604$(SYSTEM_LINKER_CONFIG) : $(INTERNAL_SYSTEMIMAGE_FILES) $(LINKER_CONFIG_PATH_system_linker_config) | conv_linker_config
2605 $(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $(LINKER_CONFIG_PATH_system_linker_config)\
2606 --output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
2607
2608FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
2609
Ying Wange5e8c5f2011-09-09 16:35:53 -07002610# installed file list
2611# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2612# We put installed-files.txt ahead of image itself in the dependency graph
2613# so that we can get the size stat even if the build fails due to too large
2614# system image.
2615INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002616INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2617$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002618$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002619 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002620 mkdir -p $(dir $@)
2621 rm -f $@
2622 $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
2623 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002624
2625.PHONY: installed-file-list
2626installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002627
2628$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002629
2630systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002631 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002632BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2633
The Android Open Source Project88b60792009-03-03 19:28:42 -08002634# $(1): output file
2635define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002636 @echo "Target system fs image: $(1)"
2637 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002638 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002639 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002640 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002641 $(BUILD_IMAGE) \
2642 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2643 || ( mkdir -p $${DIST_DIR}; \
2644 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2645 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002646endef
2647
Dan Willemsen6b72c732019-06-12 21:33:38 +00002648ifeq ($(BOARD_AVB_ENABLE),true)
2649$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2650endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002651$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002652 $(call build-systemimage-target,$@)
2653
Tao Baoe9d61b02018-08-20 21:09:07 -07002654INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002655SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002656
Tao Baoe9d61b02018-08-20 21:09:07 -07002657# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2658# compatibility, in case device-specific Makefiles still refer to the old name.
2659INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2660
Doug Zongker73ef8252009-07-23 15:12:53 -07002661# The system partition needs room for the recovery image as well. We
2662# now store the recovery image as a binary patch using the boot image
2663# as the source (since they are very similar). Generate the patch so
2664# we can see how big it's going to be, and include that in the system
2665# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002666ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002667ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002668ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002669ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002670diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2671else
2672diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2673endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002674intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2675RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002676$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2677$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002678 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Steve Muckle04b6f052020-08-09 14:36:56 -07002679 $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
Anton Hansson6d814982018-11-26 18:12:05 +00002680 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002681 @echo "Construct recovery from boot"
2682 mkdir -p $(dir $@)
Steve Muckle04b6f052020-08-09 14:36:56 -07002683 $(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002684else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2685RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002686endif # BOARD_USES_FULL_RECOVERY_IMAGE
2687endif # INSTALLED_RECOVERYIMAGE_TARGET
2688endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002689
Yifan Hong9a3cad92020-04-27 19:06:59 -07002690$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002691 @echo "Install system fs image: $@"
2692 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002693 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002694
Tao Baoe9d61b02018-08-20 21:09:07 -07002695systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002696
2697.PHONY: systemimage-nodeps snod
2698systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002699 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002700 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002701 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002702 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002703ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002704 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002705endif
2706
Dan Willemsen67495202019-01-16 12:42:05 -08002707endif # BUILDING_SYSTEM_IMAGE
2708
Anton Hansson30e061b2018-11-12 13:36:46 +00002709.PHONY: sync syncsys
2710sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002711
Ying Wang3a61eeb2016-03-11 10:32:01 -08002712# -----------------------------------------------------------------
Dan Willemsena3f66322020-05-28 15:46:33 -07002713# Old PDK fusion targets
Ying Wang4c289e52012-03-30 13:52:54 -07002714.PHONY: platform
Dan Willemsena3f66322020-05-28 15:46:33 -07002715platform:
2716 echo "Warning: 'platform' is obsolete"
Keun young Park816b9fd2012-05-16 10:32:41 -07002717
2718.PHONY: platform-java
Dan Willemsena3f66322020-05-28 15:46:33 -07002719platform-java:
2720 echo "Warning: 'platform-java' is obsolete"
Colin Cross53c8f972018-09-28 16:19:42 -07002721
Ying Wang3a61eeb2016-03-11 10:32:01 -08002722# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002723# data partition image
2724INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002725 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002726
Dan Willemsen67495202019-01-16 12:42:05 -08002727ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002728userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002729 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002730BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2731
Ying Wangbd93d422011-10-28 17:02:30 -07002732define build-userdataimage-target
2733 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2734 @mkdir -p $(TARGET_OUT_DATA)
2735 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002736 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002737 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002738 $(BUILD_IMAGE) \
2739 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2740 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2741 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002742endef
2743
Joe Onorato64d85d02009-04-09 19:31:12 -07002744# We just build this directly to the install location.
2745INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002746INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2747 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002748 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002749$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002750 $(build-userdataimage-target)
2751
2752.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002753userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002754 $(build-userdataimage-target)
2755
Dan Willemsen67495202019-01-16 12:42:05 -08002756endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002757
Andreas Gampe039b5c72017-03-24 16:06:31 -07002758# ASAN libraries in the system image - build rule.
2759ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2760 $(TARGET_OUT_SHARED_LIBRARIES) \
2761 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2762 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2763 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002764# Extra options: Enforce the system user for the files to avoid having to change ownership.
2765ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002766# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2767# enough space.
2768$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002769 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 -07002770
The Android Open Source Project88b60792009-03-03 19:28:42 -08002771# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002772# partition table image
2773ifdef BOARD_BPT_INPUT_FILES
2774
2775BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002776BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002777
2778INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2779 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002780 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002781 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2782
2783ifdef BOARD_BPT_DISK_SIZE
2784INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2785endif
2786
2787define build-bptimage-target
2788 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2789 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2790endef
2791
2792INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002793$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2794 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2795
David Zeuthen25328622016-04-08 15:08:03 -04002796$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2797 $(build-bptimage-target)
2798
2799.PHONY: bptimage-nodeps
2800bptimage-nodeps:
2801 $(build-bptimage-target)
2802
2803endif # BOARD_BPT_INPUT_FILES
2804
2805# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002806# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002807ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002808INTERNAL_CACHEIMAGE_FILES := \
2809 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2810
2811cacheimage_intermediates := \
2812 $(call intermediates-dir-for,PACKAGING,cache)
2813BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2814
2815define build-cacheimage-target
2816 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2817 @mkdir -p $(TARGET_OUT_CACHE)
2818 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002819 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002820 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002821 $(BUILD_IMAGE) \
2822 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2823 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2824 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002825endef
2826
2827# We just build this directly to the install location.
2828INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002829$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002830 $(build-cacheimage-target)
2831
2832.PHONY: cacheimage-nodeps
2833cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2834 $(build-cacheimage-target)
2835
Dan Willemsen67495202019-01-16 12:42:05 -08002836else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002837# we need to ignore the broken cache link when doing the rsync
2838IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002839endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002840
David Zeuthen0eb10972016-09-28 17:55:27 -04002841# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002842# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002843ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002844ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002845# Marker file to identify that odex files are installed
2846INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2847ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2848$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2849 $(hide) touch $@
2850endif
2851
Alex Light4e358ab2016-06-16 14:47:10 -07002852INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2853 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002854 $(ALL_DEFAULT_INSTALLED_MODULES))
Alex Light4e358ab2016-06-16 14:47:10 -07002855
Colin Cross6db5b0e2018-11-16 21:26:33 -08002856# system_other dex files are installed as a side-effect of installing system image files
2857INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2858
Alex Light4e358ab2016-06-16 14:47:10 -07002859INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002860INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2861$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002862$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002863 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002864 mkdir -p $(dir $@)
2865 rm -f $@
2866 $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
2867 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002868
Bowgo Tsai867ab662019-01-29 13:30:18 +08002869# Determines partition size for system_other.img.
2870ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2871ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2872INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2873endif
2874endif
2875
2876ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2877INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2878endif
2879
Alex Light4e358ab2016-06-16 14:47:10 -07002880systemotherimage_intermediates := \
2881 $(call intermediates-dir-for,PACKAGING,system_other)
2882BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2883
2884# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2885define build-systemotherimage-target
2886 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2887 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2888 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002889 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002890 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002891 $(BUILD_IMAGE) \
2892 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2893 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2894 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002895endef
2896
2897# We just build this directly to the install location.
2898INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002899ifneq (true,$(SANITIZE_LITE))
2900# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002901$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2902 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002903endif
Alex Light4e358ab2016-06-16 14:47:10 -07002904
2905.PHONY: systemotherimage-nodeps
2906systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2907 $(build-systemotherimage-target)
2908
Dan Willemsen67495202019-01-16 12:42:05 -08002909endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002910
2911
2912# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002913# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002914ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002915INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002916 $(filter $(TARGET_OUT_VENDOR)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002917 $(ALL_DEFAULT_INSTALLED_MODULES))
Ying Wanga0febe52013-03-20 11:02:05 -07002918
Ying Wang8da19e32015-09-15 14:22:12 -07002919
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002920# Create symlink /vendor/odm to /odm if necessary.
2921ifdef BOARD_USES_ODMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002922 INTERNAL_VENDORIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002923endif
2924
Yifan Honge51dff22020-06-23 17:26:57 -07002925# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
2926# /vendor/lib/modules -> /vendor_dlkm/lib/modules
2927#
2928# On devices with a vendor_dlkm partition,
2929# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
2930# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
2931# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
2932# are hidden.
2933# On devices without a vendor_dlkm partition,
2934# - /vendor/lib/modules stores vendor DLKMs directly.
2935# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
2936# See system/core/rootdir/Android.mk for a list of created symlinks.
2937# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
2938# are not guaranteed to exist on all devices.
2939ifdef BOARD_USES_VENDOR_DLKMIMAGE
Colin Crossbd382142020-08-26 15:08:57 -07002940 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 -07002941endif
2942
Colin Crossbd382142020-08-26 15:08:57 -07002943INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
2944INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2945$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
2946$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2947 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08002948 mkdir -p $(dir $@)
2949 rm -f $@
2950 $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
2951 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hong3d5e2c22020-07-15 17:01:14 -07002952
Ying Wanga0febe52013-03-20 11:02:05 -07002953vendorimage_intermediates := \
2954 $(call intermediates-dir-for,PACKAGING,vendor)
2955BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002956define build-vendorimage-target
2957 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2958 @mkdir -p $(TARGET_OUT_VENDOR)
2959 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002960 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002961 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002962 $(BUILD_IMAGE) \
2963 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2964 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002965 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002966endef
2967
2968# We just build this directly to the install location.
2969INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002970$(INSTALLED_VENDORIMAGE_TARGET): \
2971 $(INTERNAL_USERIMAGES_DEPS) \
2972 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002973 $(INSTALLED_FILES_FILE_VENDOR) \
2974 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002975 $(build-vendorimage-target)
2976
Steven Morelanda2e734d2017-03-07 12:10:09 -08002977.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002978vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002979 $(build-vendorimage-target)
2980
Colin Cross91a52272017-06-20 16:57:52 -07002981sync: $(INTERNAL_VENDORIMAGE_FILES)
2982
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002983else ifdef BOARD_PREBUILT_VENDORIMAGE
2984INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2985$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2986endif
Ying Wanga0febe52013-03-20 11:02:05 -07002987
Ying Wang9f8e8db2011-11-04 11:37:01 -07002988# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002989# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002990ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002991INTERNAL_PRODUCTIMAGE_FILES := \
2992 $(filter $(TARGET_OUT_PRODUCT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07002993 $(ALL_DEFAULT_INSTALLED_MODULES))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002994
2995INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002996INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2997$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002998$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002999 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003000 mkdir -p $(dir $@)
3001 rm -f $@
3002 $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
3003 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003004
3005productimage_intermediates := \
3006 $(call intermediates-dir-for,PACKAGING,product)
3007BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3008define build-productimage-target
3009 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
3010 @mkdir -p $(TARGET_OUT_PRODUCT)
3011 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07003012 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003013 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003014 $(BUILD_IMAGE) \
3015 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
3016 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
3017 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003018endef
3019
3020# We just build this directly to the install location.
3021INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003022$(INSTALLED_PRODUCTIMAGE_TARGET): \
3023 $(INTERNAL_USERIMAGES_DEPS) \
3024 $(INTERNAL_PRODUCTIMAGE_FILES) \
3025 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003026 $(build-productimage-target)
3027
3028.PHONY: productimage-nodeps pnod
3029productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
3030 $(build-productimage-target)
3031
3032sync: $(INTERNAL_PRODUCTIMAGE_FILES)
3033
3034else ifdef BOARD_PREBUILT_PRODUCTIMAGE
3035INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
3036$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
3037endif
3038
3039# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09003040# system_ext partition image
3041ifdef BUILDING_SYSTEM_EXT_IMAGE
3042INTERNAL_SYSTEM_EXTIMAGE_FILES := \
3043 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003044 $(ALL_DEFAULT_INSTALLED_MODULES))
Dario Freni5f681e12018-05-29 13:09:01 +01003045
Justin Yun6151e3f2019-06-25 15:58:13 +09003046INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
3047INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
3048$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
3049$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01003050 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003051 mkdir -p $(dir $@)
3052 rm -f $@
3053 $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
3054 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01003055
Justin Yun6151e3f2019-06-25 15:58:13 +09003056system_extimage_intermediates := \
3057 $(call intermediates-dir-for,PACKAGING,system_ext)
3058BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3059define build-system_extimage-target
3060 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
3061 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
3062 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
3063 $(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 -07003064 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003065 $(BUILD_IMAGE) \
3066 $(TARGET_OUT_SYSTEM_EXT) \
3067 $(system_extimage_intermediates)/system_ext_image_info.txt \
3068 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
3069 $(TARGET_OUT)
3070 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01003071endef
3072
3073# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09003074INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003075$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
3076 $(INTERNAL_USERIMAGES_DEPS) \
3077 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3078 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09003079 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003080
Justin Yun6151e3f2019-06-25 15:58:13 +09003081.PHONY: systemextimage-nodeps senod
3082systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
3083 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01003084
Justin Yun6151e3f2019-06-25 15:58:13 +09003085sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01003086
Justin Yun6151e3f2019-06-25 15:58:13 +09003087else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
3088INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
3089$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01003090endif
3091
3092# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003093# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08003094ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003095INTERNAL_ODMIMAGE_FILES := \
3096 $(filter $(TARGET_OUT_ODM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003097 $(ALL_DEFAULT_INSTALLED_MODULES))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003098
Colin Crossbd382142020-08-26 15:08:57 -07003099# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
3100# /odm/lib/modules -> /odm_dlkm/lib/modules
3101#
3102# On devices with a odm_dlkm partition,
3103# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
3104# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
3105# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
3106# are hidden.
3107# On devices without a odm_dlkm partition,
3108# - /odm/lib/modules stores odm DLKMs directly.
3109# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
3110# See system/core/rootdir/Android.mk for a list of created symlinks.
3111# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
3112# are not guaranteed to exist on all devices.
3113ifdef BOARD_USES_ODM_DLKMIMAGE
3114 INTERNAL_ODMIMAGE_FILES += $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
3115endif
3116
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003117INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
3118INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
3119$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07003120$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003121 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003122 mkdir -p $(dir $@)
3123 rm -f $@
3124 $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
3125 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003126
3127odmimage_intermediates := \
3128 $(call intermediates-dir-for,PACKAGING,odm)
3129BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3130define build-odmimage-target
3131 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
3132 @mkdir -p $(TARGET_OUT_ODM)
3133 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
3134 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07003135 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003136 $(BUILD_IMAGE) \
3137 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
3138 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
3139 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003140endef
3141
3142# We just build this directly to the install location.
3143INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07003144$(INSTALLED_ODMIMAGE_TARGET): \
3145 $(INTERNAL_USERIMAGES_DEPS) \
3146 $(INTERNAL_ODMIMAGE_FILES) \
3147 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003148 $(build-odmimage-target)
3149
3150.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07003151odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003152 $(build-odmimage-target)
3153
3154sync: $(INTERNAL_ODMIMAGE_FILES)
3155
3156else ifdef BOARD_PREBUILT_ODMIMAGE
3157INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
3158$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
3159endif
3160
3161# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07003162# vendor_dlkm partition image
3163ifdef BUILDING_VENDOR_DLKM_IMAGE
3164INTERNAL_VENDOR_DLKMIMAGE_FILES := \
3165 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003166 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003167
3168INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
3169INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
3170$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
3171$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3172 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003173 mkdir -p $(dir $@)
3174 rm -f $@
3175 $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
3176 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongcfb917a2020-05-07 14:58:20 -07003177
3178vendor_dlkmimage_intermediates := \
3179 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
3180BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3181define build-vendor_dlkmimage-target
3182 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
3183 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
3184 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
3185 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
3186 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3187 $(BUILD_IMAGE) \
3188 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
3189 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
3190 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
3191endef
3192
3193# We just build this directly to the install location.
3194INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
3195$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
3196 $(INTERNAL_USERIMAGES_DEPS) \
3197 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3198 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
3199 $(build-vendor_dlkmimage-target)
3200
3201.PHONY: vendor_dlkmimage-nodeps vdnod
3202vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
3203 $(build-vendor_dlkmimage-target)
3204
3205sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
3206
3207else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
3208INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
3209$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
3210endif
3211
3212# -----------------------------------------------------------------
Yifan Hongf496f1b2020-07-15 16:52:59 -07003213# odm_dlkm partition image
3214ifdef BUILDING_ODM_DLKM_IMAGE
3215INTERNAL_ODM_DLKMIMAGE_FILES := \
3216 $(filter $(TARGET_OUT_ODM_DLKM)/%,\
Dan Willemsena3f66322020-05-28 15:46:33 -07003217 $(ALL_DEFAULT_INSTALLED_MODULES))
Yifan Hongf496f1b2020-07-15 16:52:59 -07003218
3219INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
3220INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
3221$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
3222$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
3223 @echo Installed file list: $@
Petri Gynther728e0bd2021-03-06 13:29:28 -08003224 mkdir -p $(dir $@)
3225 rm -f $@
3226 $(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
3227 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Yifan Hongf496f1b2020-07-15 16:52:59 -07003228
3229odm_dlkmimage_intermediates := \
3230 $(call intermediates-dir-for,PACKAGING,odm_dlkm)
3231BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3232define build-odm_dlkmimage-target
3233 $(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
3234 @mkdir -p $(TARGET_OUT_ODM_DLKM)
3235 @mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
3236 $(call generate-userimage-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, skip_fsck=true)
3237 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
3238 $(BUILD_IMAGE) \
3239 $(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
3240 $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
3241 $(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
3242endef
3243
3244# We just build this directly to the install location.
3245INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
3246$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
3247 $(INTERNAL_USERIMAGES_DEPS) \
3248 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3249 $(INSTALLED_FILES_FILE_ODM_DLKM)
3250 $(build-odm_dlkmimage-target)
3251
3252.PHONY: odm_dlkmimage-nodeps odnod
3253odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS)
3254 $(build-odm_dlkmimage-target)
3255
3256sync: $(INTERNAL_ODM_DLKMIMAGE_FILES)
3257
3258else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
3259INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
3260$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
3261endif
3262
3263
3264# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07003265# dtbo image
3266ifdef BOARD_PREBUILT_DTBOIMAGE
3267INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
3268
3269ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003270$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003271 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3272 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00003273 --image $@ \
3274 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
3275 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
3276 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003277else
3278$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3279 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3280endif
3281
Tao Bao0da43472018-08-22 22:53:41 -07003282endif # BOARD_PREBUILT_DTBOIMAGE
3283
Andrew Scull9b103e42020-11-29 14:04:28 +00003284# -----------------------------------------------------------------
3285# Protected VM firmware image
3286ifdef BOARD_PREBUILT_PVMFWIMAGE
3287INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
3288
3289ifeq ($(BOARD_AVB_ENABLE),true)
3290$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE) $(AVBTOOL) $(BOARD_AVB_PVMFW_KEY_PATH)
3291 cp $(BOARD_PREBUILT_PVMFWIMAGE) $@
3292 $(AVBTOOL) add_hash_footer \
3293 --image $@ \
3294 --partition_size $(BOARD_PVMFWIMG_PARTITION_SIZE) \
3295 --partition_name pvmfw $(INTERNAL_AVB_PVMFW_SIGNING_ARGS) \
3296 $(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)
3297else
3298$(INSTALLED_PVMFWIMAGE_TARGET): $(BOARD_PREBUILT_PVMFWIMAGE)
3299 cp $(BOARD_PREBUILT_PVMFWIMAGE) $@
3300endif
3301
3302endif # BOARD_PREBUILT_PVMFWIMAGE
3303
Tao Bao0da43472018-08-22 22:53:41 -07003304# Returns a list of image targets corresponding to the given list of partitions. For example, it
3305# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3306# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003307# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003308define images-for-partitions
3309$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3310endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003311
3312# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003313# custom images
3314INSTALLED_CUSTOMIMAGES_TARGET :=
3315
3316ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3317INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3318
3319# Sign custom image.
3320# $(1): the prebuilt custom image.
3321# $(2): the mount point of the prebuilt custom image.
3322# $(3): the signed custom image target.
3323define sign_custom_image
3324$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3325 @echo Target custom image: $(3)
3326 mkdir -p $(dir $(3))
3327 cp $(1) $(3)
3328ifeq ($(BOARD_AVB_ENABLE),true)
3329 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3330 $(AVBTOOL) add_hashtree_footer \
3331 --image $(3) \
3332 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3333 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3334 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3335 --partition_name $(2) \
3336 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3337 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3338endif
3339INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3340endef
3341
3342$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3343 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3344 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3345endif
3346
3347# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003348# vbmeta image
3349ifeq ($(BOARD_AVB_ENABLE),true)
3350
3351BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003352AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003353
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003354ifdef BOARD_AVB_KEY_PATH
3355$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3356else
3357# If key path isn't specified, use the 4096-bit test key.
3358BOARD_AVB_ALGORITHM := SHA256_RSA4096
3359BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3360endif
3361
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003362# AVB signing for system_other.img.
3363ifdef BUILDING_SYSTEM_OTHER_IMAGE
3364ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3365$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3366else
3367# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3368BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3369BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3370endif
3371
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003372$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3373 @echo Extracting system_other avb key: $@
3374 @rm -f $@
3375 @mkdir -p $(dir $@)
3376 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003377
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003378ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3379BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3380endif
3381
3382BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3383endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3384
Tao Bao744c4c72018-08-20 21:09:07 -07003385INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003386 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003387 $(BOARD_AVB_VBMETA_VENDOR)
3388
3389# Not allowing the same partition to appear in multiple groups.
3390ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003391 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003392endif
3393
cfig1aeef722019-09-20 22:45:06 +08003394# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3395# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3396# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003397ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003398ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3399$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003400 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003401 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3402endif
3403endif
3404
Bowgo Tsai9b548012019-05-14 16:57:03 +08003405# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003406
3407BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003408 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003409 --prop com.android.build.system.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003410 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3411
3412BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003413 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003414 --prop com.android.build.product.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003415 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3416
Justin Yun6151e3f2019-06-25 15:58:13 +09003417BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003418 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003419 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION_LAST_STABLE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003420 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003421
Bowgo Tsai9b548012019-05-14 16:57:03 +08003422BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003423 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003424 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003425
Tao Bao19b02fe2019-10-09 00:04:28 -07003426BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3427 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3428
3429BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3430 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3431
Bowgo Tsai9b548012019-05-14 16:57:03 +08003432BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003433 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003434 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003435
3436BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003437 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Dianne Hackborn25648e62019-10-22 15:58:17 -07003438 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
Bowgo Tsai9b548012019-05-14 16:57:03 +08003439
Yifan Hongcfb917a2020-05-07 14:58:20 -07003440BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3441 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3442 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3443
Yifan Hongf496f1b2020-07-15 16:52:59 -07003444BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3445 --prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3446 --prop com.android.build.odm_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3447
Tao Bao19b02fe2019-10-09 00:04:28 -07003448BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3449 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3450
Andrew Scull9b103e42020-11-29 14:04:28 +00003451BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3452 --prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3453
Bowgo Tsai9b548012019-05-14 16:57:03 +08003454# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003455ifdef BOOT_SECURITY_PATCH
3456BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3457 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3458endif
3459
3460ifdef VENDOR_SECURITY_PATCH
3461BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3462 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3463endif
3464
3465ifdef ODM_SECURITY_PATCH
3466BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3467 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3468endif
3469
Yifan Hongcfb917a2020-05-07 14:58:20 -07003470ifdef VENDOR_DLKM_SECURITY_PATCH
3471BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3472 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3473endif
3474
Yifan Hongf496f1b2020-07-15 16:52:59 -07003475ifdef ODM_DLKM_SECURITY_PATCH
3476BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3477 --prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
3478endif
3479
Andrew Scull9b103e42020-11-29 14:04:28 +00003480ifdef PVMFW_SECURITY_PATCH
3481BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
3482 --prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
3483endif
3484
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003485BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003486VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003487DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
Andrew Scull9b103e42020-11-29 14:04:28 +00003488PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003489SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3490VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003491RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003492PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003493SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003494ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003495VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongf496f1b2020-07-15 16:52:59 -07003496ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003497
Tao Bao0da43472018-08-22 22:53:41 -07003498# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003499# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003500define _check-and-set-avb-chain-args
3501$(eval part := $(1))
3502$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003503
3504$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3505$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3506$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3507$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3508$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3509$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3510$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3511$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3512
3513# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3514$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3515$(eval $(_signing_args) := \
3516 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3517
cfig1aeef722019-09-20 22:45:06 +08003518# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3519# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003520$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003521 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3522 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003523
Tao Bao744c4c72018-08-20 21:09:07 -07003524# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003525# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003526$(if $(filter $(part),$(part:vbmeta_%=%)),\
3527 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3528 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003529endef
3530
Tao Bao0da43472018-08-22 22:53:41 -07003531# Checks and sets the required build variables for an AVB partition. The partition will be
3532# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003533# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3534# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003535# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3536# but vbmeta would capture the image descriptor of only the first boot
3537# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003538# $(1): Partition name, e.g. boot or system.
3539define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003540$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003541$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003542 $(if $(_in_chained_vbmeta),\
3543 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003544 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003545 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003546 $(if $(filter boot,$(1)),\
3547 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3548 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3549 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3550 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003551endef
3552
Hongguang Chenf23364d2020-04-27 18:36:36 -07003553# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3554# $(1): the custom partition to enable AVB chain.
3555define check-and-set-custom-avb-chain-args
3556$(eval part := $(1))
3557$(eval PART=$(call to-upper,$(part)))
3558$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3559$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3560
3561INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3562 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3563endef
3564
Tao Baob1a2e352018-08-14 16:17:12 -07003565ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003566$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003567endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003568
Steve Mucklee1b10862019-07-10 10:49:37 -07003569ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3570$(eval $(call check-and-set-avb-args,vendor_boot))
3571endif
3572
Tao Bao0da43472018-08-22 22:53:41 -07003573$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003574
3575ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003576$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003577endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003578
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003579ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003580$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003581endif
3582
Justin Yun6151e3f2019-06-25 15:58:13 +09003583ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3584$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003585endif
3586
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003587ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003588$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003589endif
3590
Yifan Hongcfb917a2020-05-07 14:58:20 -07003591ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3592$(eval $(call check-and-set-avb-args,vendor_dlkm))
3593endif
3594
Yifan Hongf496f1b2020-07-15 16:52:59 -07003595ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
3596$(eval $(call check-and-set-avb-args,odm_dlkm))
3597endif
3598
Yueyao Zhu211c9012017-04-27 00:34:50 -07003599ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003600$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003601endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003602
Andrew Scull9b103e42020-11-29 14:04:28 +00003603ifdef INSTALLED_PVMFWIMAGE_TARGET
3604$(eval $(call check-and-set-avb-args,pvmfw))
3605endif
3606
David Zeuthen8fecb282017-12-01 16:24:01 -05003607ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003608$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003609endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003610
David Anderson7709ab22018-10-15 14:41:34 -07003611# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3612ifdef BOARD_AVB_VBMETA_SYSTEM
3613$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003614endif
3615
3616ifdef BOARD_AVB_VBMETA_VENDOR
3617$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3618endif
3619
Hongguang Chenf23364d2020-04-27 18:36:36 -07003620ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3621$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3622 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3623endif
3624
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003625# Add kernel cmdline descriptor for kernel to mount system.img as root with
3626# dm-verity. This works when system.img is either chained or not-chained:
3627# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3628# cmdline descriptor to system.img
3629# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3630# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003631ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003632ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003633BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003634endif
David Anderson8916a2a2018-09-18 15:46:59 -07003635endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003636
Tao Bao0da43472018-08-22 22:53:41 -07003637BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003638BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003639BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3640
3641ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003642# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003643BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003644endif
Tao Bao0da43472018-08-22 22:53:41 -07003645
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003646ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003647BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003648endif
3649
David Anderson7709ab22018-10-15 14:41:34 -07003650ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3651BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3652 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003653endif
3654
3655ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3656BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3657 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003658endif
3659
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003660# $(1): the directory to extract public keys to
3661define extract-avb-chain-public-keys
3662 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3663 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3664 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003665 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3666 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3667 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003668 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3669 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3670 --output $(1)/system.avbpubkey)
3671 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3672 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3673 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003674 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3675 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3676 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003677 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3678 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3679 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003680 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3681 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3682 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003683 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3684 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3685 --output $(1)/vendor_dlkm.avbpubkey)
Yifan Hongf496f1b2020-07-15 16:52:59 -07003686 $(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
3687 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
3688 --output $(1)/odm_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003689 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3690 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3691 --output $(1)/dtbo.avbpubkey)
Andrew Scull9b103e42020-11-29 14:04:28 +00003692 $(if $(BOARD_AVB_PVMFW_KEY_PATH),\
3693 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
3694 --output $(1)/pvmfw.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003695 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3696 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3697 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003698 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3699 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3700 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003701 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3702 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3703 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003704 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3705 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3706 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3707 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003708endef
3709
Tao Bao744c4c72018-08-20 21:09:07 -07003710# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3711# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003712# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003713# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3714# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003715# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003716# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003717# $(2): Output filename.
3718define build-chained-vbmeta-image
3719 $(call pretty,"Target chained vbmeta image: $@")
3720 $(hide) $(AVBTOOL) make_vbmeta_image \
3721 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3722 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3723 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3724 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3725 --output $@
3726endef
3727
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003728ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003729ifdef BOARD_AVB_VBMETA_SYSTEM
3730INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3731$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003732 $(AVBTOOL) \
3733 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3734 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003735 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003736endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003737endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003738
3739ifdef BOARD_AVB_VBMETA_VENDOR
3740INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3741$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003742 $(AVBTOOL) \
3743 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3744 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003745 $(call build-chained-vbmeta-image,vbmeta_vendor)
3746endif
3747
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003748define build-vbmetaimage-target
3749 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003750 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3751 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003752 $(hide) $(AVBTOOL) make_vbmeta_image \
3753 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003754 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003755 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3756 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003757 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003758endef
3759
Paul Trautrim4e143232019-08-13 16:30:57 +09003760ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003761INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003762$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3763 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3764
David Zeuthen8fecb282017-12-01 16:24:01 -05003765$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003766 $(AVBTOOL) \
3767 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003768 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003769 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3770 $(INSTALLED_VENDORIMAGE_TARGET) \
3771 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003772 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003773 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003774 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07003775 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003776 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00003777 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003778 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003779 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3780 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3781 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3782 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3783 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3784 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003785 $(build-vbmetaimage-target)
3786
3787.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003788vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3789 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003790vbmetaimage-nodeps:
3791 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003792endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003793
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003794endif # BOARD_AVB_ENABLE
3795
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003796# List of files from all images
3797INTERNAL_ALLIMAGES_FILES := \
3798 $(FULL_SYSTEMIMAGE_DEPS) \
3799 $(INTERNAL_RAMDISK_FILES) \
3800 $(INTERNAL_USERDATAIMAGE_FILES) \
3801 $(INTERNAL_VENDORIMAGE_FILES) \
3802 $(INTERNAL_PRODUCTIMAGE_FILES) \
3803 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3804 $(INTERNAL_ODMIMAGE_FILES) \
3805 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
3806 $(INTERNAL_ODM_DLKMIMAGE_FILES) \
3807
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003808# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003809# Check VINTF of build
3810
Yifan Hongc08cbf02020-09-15 19:07:39 +00003811# Note: vendor_dlkm and odm_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003812ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003813
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003814intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3815check_vintf_all_deps :=
3816
Yifan Hongaf9b0702020-01-21 12:46:57 -08003817# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3818# because they are only used for prebuilt images.
3819check_vintf_common_srcs_patterns := \
3820 $(TARGET_OUT)/etc/vintf/% \
3821 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3822 $(TARGET_OUT_ODM)/etc/vintf/% \
3823 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3824 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3825
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09003826check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
Yifan Hongaf9b0702020-01-21 12:46:57 -08003827check_vintf_common_srcs_patterns :=
3828
3829check_vintf_has_system :=
3830check_vintf_has_vendor :=
3831
Yifan Hong28ffd732020-03-13 13:11:10 -07003832ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3833$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3834endif
3835ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3836$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3837endif
3838
Yifan Hong605ea042020-01-14 21:36:00 +00003839# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003840check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3841ifneq ($(check_vintf_system_deps),)
3842check_vintf_has_system := true
Yifan Hong7a157b02020-10-20 17:08:11 +00003843
Yifan Hong605ea042020-01-14 21:36:00 +00003844check_vintf_system_log := $(intermediates)/check_vintf_system_log
3845check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003846$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003847 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3848check_vintf_system_log :=
Yifan Hong7a157b02020-10-20 17:08:11 +00003849
3850vintffm_log := $(intermediates)/vintffm_log
3851check_vintf_all_deps += $(vintffm_log)
3852$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps)
3853 @( $< --check --dirmap /system:$(TARGET_OUT) \
3854 $(VINTF_FRAMEWORK_MANIFEST_FROZEN_DIR) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3855
Yifan Hongaf9b0702020-01-21 12:46:57 -08003856endif # check_vintf_system_deps
3857check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003858
3859# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003860check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3861ifneq ($(check_vintf_vendor_deps),)
3862check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003863check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3864check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003865# Check vendor SKU=(empty) case when:
3866# - DEVICE_MANIFEST_FILE is not empty; OR
3867# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003868$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003869 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3870 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003871 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003872$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003873 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3874 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3875 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3876 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003877check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003878endif # check_vintf_vendor_deps
3879check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003880
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003881# -- Check VINTF compatibility of build.
3882# Skip partial builds; only check full builds. Only check if:
3883# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003884# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003885# - Building product / system_ext / odm images if board has product / system_ext / odm images
3886ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003887ifeq ($(check_vintf_has_system),true)
3888ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003889ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3890ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3891ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3892
3893check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3894check_vintf_all_deps += $(check_vintf_compatible_log)
3895
3896check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003897check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003898
3899# -- Kernel version and configurations.
3900ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3901
Yifan Hong605ea042020-01-14 21:36:00 +00003902BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3903BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3904
3905my_board_extracted_kernel :=
3906
3907# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3908# from INSTALLED_KERNEL_TARGET.
3909ifdef BOARD_KERNEL_CONFIG_FILE
3910ifdef BOARD_KERNEL_VERSION
3911$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3912 cp $< $@
3913$(BUILT_KERNEL_VERSION_FILE):
3914 echo $(BOARD_KERNEL_VERSION) > $@
3915
3916my_board_extracted_kernel := true
3917endif # BOARD_KERNEL_VERSION
3918endif # BOARD_KERNEL_CONFIG_FILE
3919
3920ifneq ($(my_board_extracted_kernel),true)
3921ifndef INSTALLED_KERNEL_TARGET
3922$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3923 is true. Information about the updated kernel cannot be built into OTA update package. \
3924 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3925 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3926 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3927 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3928 manually.)
3929else
3930
3931# Tools for decompression that is not in PATH.
3932# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3933# Algorithms that are in the script but not in this list will be found in PATH.
3934my_decompress_tools := \
3935 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3936
3937$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3938$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3939$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003940$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3941 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003942 --output-configs $@ \
Yifan Hongb95d02e2020-11-13 18:33:01 -08003943 --output-release $(BUILT_KERNEL_VERSION_FILE)
Yifan Hong605ea042020-01-14 21:36:00 +00003944
3945my_decompress_tools :=
3946
3947endif # my_board_extracted_kernel
3948my_board_extracted_kernel :=
3949
3950endif # INSTALLED_KERNEL_TARGET
3951
Yifan Hong72e78f22020-11-13 18:30:06 -08003952check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003953check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3954
3955endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3956
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003957check_vintf_compatible_args += \
3958 --dirmap /system:$(TARGET_OUT) \
3959 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3960 --dirmap /odm:$(TARGET_OUT_ODM) \
3961 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3962 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3963
3964ifdef PRODUCT_SHIPPING_API_LEVEL
3965check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3966endif # PRODUCT_SHIPPING_API_LEVEL
3967
3968$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3969$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003970# Check ODM SKU=(empty) case when:
3971# - ODM_MANIFEST_FILES is not empty; OR
3972# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003973$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003974 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3975 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003976 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003977# Check vendor SKU=(empty) case when:
3978# - DEVICE_MANIFEST_FILE is not empty; OR
3979# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003980$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003981 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3982 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003983 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003984$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3985 @echo -n -e 'Deps: \n ' > $@
3986 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3987 @echo -n -e 'Args: \n ' >> $@
3988 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003989 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3990 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003991 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003992 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3993 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3994 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003995
3996check_vintf_compatible_log :=
3997check_vintf_compatible_args :=
3998check_vintf_compatible_deps :=
3999
4000endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
4001endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
4002endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08004003endif # check_vintf_has_vendor
4004endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004005endif # PRODUCT_ENFORCE_VINTF_MANIFEST
4006
4007# Add all logs of VINTF checks to dist builds
4008droid_targets: $(check_vintf_all_deps)
4009$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
4010
4011# Helper alias to check all VINTF of current build.
4012.PHONY: check-vintf-all
4013check-vintf-all: $(check_vintf_all_deps)
4014 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
4015
Yifan Hongaf9b0702020-01-21 12:46:57 -08004016check_vintf_has_vendor :=
4017check_vintf_has_system :=
4018check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004019check_vintf_all_deps :=
4020intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004021endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00004022
4023# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08004024# Check image sizes <= size of super partition
4025
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004026ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004027
4028ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07004029
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004030# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07004031# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07004032define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004033 mkdir -p $(dir $(1))
4034 rm -f $(1)
4035 $(call dump-super-image-info, $(1))
4036 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4037 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07004038 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07004039endef
4040
Yifan Hong30910932019-10-25 20:36:55 -07004041check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
4042droid_targets: $(check_all_partition_sizes_log)
4043$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07004044
Yifan Hong30910932019-10-25 20:36:55 -07004045$(check_all_partition_sizes_log): \
4046 $(CHECK_PARTITION_SIZES) \
4047 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
4048 $(call check-all-partition-sizes-target, \
4049 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
4050 $@)
4051
4052.PHONY: check-all-partition-sizes
4053check-all-partition-sizes: $(check_all_partition_sizes_log)
4054
4055.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07004056check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004057 $(call check-all-partition-sizes-target, \
4058 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07004059
Yifan Hong2dae5722018-07-31 12:47:27 -07004060endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07004061
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004062endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07004063
4064# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08004065# bring in the installer image generation defines if necessary
4066ifeq ($(TARGET_USE_DISKINSTALLER),true)
4067include bootable/diskinstaller/config.mk
4068endif
4069
4070# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07004071# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08004072
Ying Wangbd2d0242015-09-22 11:17:52 -07004073ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004074 build_ota_package := false
4075 build_otatools_package := false
4076else
Tao Bao9be20c72019-04-08 21:11:59 -07004077 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004078 build_ota_package := true
4079 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
4080 build_ota_package := false
4081 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004082 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004083 build_ota_package := false
4084 endif
4085 ifeq ($(TARGET_PRODUCT),sdk)
4086 build_ota_package := false
4087 endif
Tao Bao9be20c72019-04-08 21:11:59 -07004088 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4089 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
4090 build_ota_package := false
4091 endif
4092 ifeq ($(TARGET_NO_KERNEL),true)
4093 build_ota_package := false
4094 endif
4095 ifeq ($(recovery_fstab),)
4096 build_ota_package := false
4097 endif
4098 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004099
Tao Bao9be20c72019-04-08 21:11:59 -07004100 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004101 build_otatools_package := true
4102 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
4103 build_otatools_package := false
4104 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08004105endif
Ying Wangbd2d0242015-09-22 11:17:52 -07004106
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004107ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07004108
4109INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09004110 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07004111 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07004112 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00004113 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07004114 append2simg \
4115 avbtool \
4116 blk_alloc_to_base_fs \
4117 boot_signer \
4118 brillo_update_payload \
4119 brotli \
4120 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07004121 build_image \
4122 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07004123 build_verity_metadata \
4124 build_verity_tree \
4125 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07004126 check_ota_package_signature \
4127 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004128 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07004129 checkvintf \
4130 delta_generator \
4131 e2fsck \
4132 e2fsdroid \
4133 fc_sort \
4134 fec \
4135 fs_config \
4136 generate_verity_key \
Daniel Normanee33b4e2020-12-02 16:18:25 -08004137 host_init_verifier \
Tao Bao96daeeb2019-05-01 21:17:13 -07004138 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07004139 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004140 imgdiff \
4141 libconscrypt_openjdk_jni \
4142 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08004143 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07004144 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07004145 make_f2fs \
Jaegeuk Kim8ba4bab2020-07-17 20:18:10 -07004146 make_f2fs_casefold \
Tao Baoc1966a82019-06-25 11:42:12 -07004147 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004148 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08004149 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07004150 mkbootfs \
4151 mkbootimg \
4152 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08004153 mke2fs.conf \
Gao Xiang961041a2020-06-17 13:59:16 +08004154 mkfs.erofs \
4155 mkerofsimage.sh \
Tao Bao96daeeb2019-05-01 21:17:13 -07004156 mkf2fsuserimg.sh \
4157 mksquashfs \
4158 mksquashfsimage.sh \
4159 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07004160 ota_from_target_files \
Bowgo Tsai6c37c172021-02-05 18:01:15 +08004161 repack_bootimg \
Daniel Norman48603ff2021-02-22 15:15:24 -08004162 secilc \
Tao Bao96daeeb2019-05-01 21:17:13 -07004163 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08004164 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07004165 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07004166 sign_apex \
4167 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07004168 signapk \
4169 simg2img \
4170 sload_f2fs \
Yifan Hong125d0b62020-09-24 17:07:03 -07004171 toybox \
Tao Bao96daeeb2019-05-01 21:17:13 -07004172 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08004173 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07004174 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07004175 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07004176 verity_signer \
4177 verity_verifier \
4178 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08004179
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004180# Additional tools to unpack and repack the apex file.
4181INTERNAL_OTATOOLS_MODULES += \
4182 apexer \
Nikita Ioffe36081482021-01-20 01:32:28 +00004183 apex_compression_tool \
Tianjie Xueb8a0a02020-01-23 13:59:13 -08004184 deapexer \
4185 debugfs_static \
4186 merge_zips \
4187 resize2fs \
4188 soong_zip \
4189
Anton Hansson8dab0a62019-03-28 15:45:40 +00004190ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004191INTERNAL_OTATOOLS_MODULES += \
4192 futility \
4193 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08004194endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08004195
Tao Bao96daeeb2019-05-01 21:17:13 -07004196INTERNAL_OTATOOLS_FILES := \
4197 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004198
Ying Wang06898662010-06-17 17:52:18 -07004199.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07004200otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07004201
Tao Bao96daeeb2019-05-01 21:17:13 -07004202# For each module, recursively resolve its host shared library dependencies. Then we have a full
4203# list of modules whose installed files need to be packed.
4204INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
4205 $(sort $(INTERNAL_OTATOOLS_MODULES) \
4206 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004207
Tao Bao96daeeb2019-05-01 21:17:13 -07004208INTERNAL_OTATOOLS_PACKAGE_FILES := \
4209 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
4210
4211INTERNAL_OTATOOLS_PACKAGE_FILES += \
4212 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
4213 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07004214
4215ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07004216INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07004217 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07004218 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07004219endif
4220ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07004221INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07004222 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
4223 -name "atx_metadata.bin"))
4224endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004225ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07004226INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00004227 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07004228endif
4229
Tao Bao96daeeb2019-05-01 21:17:13 -07004230INTERNAL_OTATOOLS_RELEASETOOLS := \
4231 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
4232 \( -type f -o -type l \) -print))
4233
4234BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
4235$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
4236$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
4237$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
4238$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07004239$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004240 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07004241 rm -rf $@ $(PRIVATE_ZIP_ROOT)
4242 mkdir -p $(dir $@)
4243 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
4244 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08004245 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07004246 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004247
4248.PHONY: otatools-package
4249otatools-package: $(BUILT_OTATOOLS_PACKAGE)
4250
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08004251endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07004252
The Android Open Source Project88b60792009-03-03 19:28:42 -08004253# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07004254# misc_info.txt
4255
4256INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
4257
4258ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
4259# default to common dir for device vendor
4260tool_extensions := $(TARGET_DEVICE_DIR)/../common
4261else
4262tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
4263endif
4264.KATI_READONLY := tool_extensions
4265
Steve Muckle903a1ca2020-05-07 17:32:10 -07004266# $1: boot image file name
4267define misc_boot_size
4268$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
4269endef
4270
Daniel Normane1e48082019-06-27 13:55:23 -07004271$(INSTALLED_MISC_INFO_TARGET):
4272 rm -f $@
4273 $(call pretty,"Target misc_info.txt: $@")
4274 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
4275 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
4276ifdef BOARD_FLASH_BLOCK_SIZE
4277 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
4278endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07004279ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
4280 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
4281 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07004282endif
4283ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
4284 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07004285else
4286 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004287endif
J. Avila98cd4cc2020-06-10 20:09:10 +00004288ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
4289 echo "lz4_ramdisks=true" >> $@
4290endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004291ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4292 echo "vendor_boot=true" >> $@
4293 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
4294endif
Daniel Normane1e48082019-06-27 13:55:23 -07004295ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4296 $(hide) echo "no_recovery=true" >> $@
4297endif
4298ifdef BOARD_INCLUDE_RECOVERY_DTBO
4299 $(hide) echo "include_recovery_dtbo=true" >> $@
4300endif
4301ifdef BOARD_INCLUDE_RECOVERY_ACPIO
4302 $(hide) echo "include_recovery_acpio=true" >> $@
4303endif
4304ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
4305 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
4306endif
4307ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
4308 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
4309 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4310else
4311 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
4312endif
4313 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
4314 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
4315ifdef PRODUCT_EXTRA_RECOVERY_KEYS
4316 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
4317endif
4318 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07004319 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07004320 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
4321 $(hide) echo "multistage_support=1" >> $@
4322 $(hide) echo "blockimgdiff_versions=3,4" >> $@
4323ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
4324 $(hide) echo "build_generic_ota_package=true" >> $@
4325endif
4326ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
4327 # OTA scripts are only interested in fingerprint related properties
4328 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
4329endif
4330ifneq (,$(filter address, $(SANITIZE_TARGET)))
4331 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
4332 $(hide) echo "userdata_img_with_data=true" >> $@
4333endif
4334ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
4335 $(hide) echo "full_recovery_image=true" >> $@
4336endif
Bill Peckhame868aec2019-09-17 17:06:47 -07004337ifdef BOARD_USES_VENDORIMAGE
4338 $(hide) echo "board_uses_vendorimage=true" >> $@
4339endif
Daniel Normane1e48082019-06-27 13:55:23 -07004340ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai82182252020-11-13 11:28:17 +08004341ifeq ($(BUILDING_VBMETA_IMAGE),true)
4342 $(hide) echo "avb_building_vbmeta_image=true" >> $@
4343endif # BUILDING_VBMETA_IMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004344 $(hide) echo "avb_enable=true" >> $@
4345 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
4346 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
4347 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
4348 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4349ifdef BOARD_AVB_BOOT_KEY_PATH
4350 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
4351 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
4352 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4353endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004354 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4355ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4356 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4357 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4358 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4359endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004360 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4361ifdef BOARD_AVB_RECOVERY_KEY_PATH
4362 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4363 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4364 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4365endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004366ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4367 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4368 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4369 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4370 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4371 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4372 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4373 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4374 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4375endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004376ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4377 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4378 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4379 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4380 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4381 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4382endif # BOARD_AVB_VBMETA_SYSTEM
4383ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4384 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4385 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4386 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4387 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4388 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4389endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4390endif # BOARD_AVB_ENABLE
4391ifdef BOARD_BPT_INPUT_FILES
4392 $(hide) echo "board_bpt_enable=true" >> $@
4393 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4394 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4395endif
4396ifdef BOARD_BPT_DISK_SIZE
4397 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4398endif
4399 $(call generate-userimage-prop-dictionary, $@)
4400ifeq ($(AB_OTA_UPDATER),true)
4401 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4402 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4403 $(hide) echo "ab_update=true" >> $@
4404endif
Yifan Hong65afc072020-04-17 10:08:10 -07004405ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4406 $(hide) echo "allow_non_ab=true" >> $@
4407endif
Daniel Normane1e48082019-06-27 13:55:23 -07004408ifdef BOARD_PREBUILT_DTBOIMAGE
4409 $(hide) echo "has_dtbo=true" >> $@
4410ifeq ($(BOARD_AVB_ENABLE),true)
4411 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4412 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4413ifdef BOARD_AVB_DTBO_KEY_PATH
4414 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4415 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4416 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4417endif # BOARD_AVB_DTBO_KEY_PATH
4418endif # BOARD_AVB_ENABLE
4419endif # BOARD_PREBUILT_DTBOIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00004420ifdef BOARD_PREBUILT_PVMFWIMAGE
4421 $(hide) echo "has_pvmfw=true" >> $@
4422ifeq ($(BOARD_AVB_ENABLE),true)
4423 $(hide) echo "pvmfw_size=$(BOARD_PVMFWIMG_PARTITION_SIZE)" >> $@
4424 $(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
4425ifdef BOARD_AVB_PVMFW_KEY_PATH
4426 $(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
4427 $(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
4428 $(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
4429endif # BOARD_AVB_PVMFW_KEY_PATH
4430endif # BOARD_AVB_ENABLE
4431endif # BOARD_PREBUILT_PVMFWIMAGE
Daniel Normane1e48082019-06-27 13:55:23 -07004432 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004433 @# VINTF checks
4434ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4435 $(hide) echo "vintf_enforce=true" >> $@
4436endif
4437ifdef ODM_MANIFEST_SKUS
4438 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4439endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004440ifdef ODM_MANIFEST_FILES
4441 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4442endif
4443ifdef DEVICE_MANIFEST_SKUS
4444 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4445endif
4446ifdef DEVICE_MANIFEST_FILE
4447 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4448endif
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004449ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
4450 $(hide) echo "bootloader_in_update_package=true" >> $@
4451endif
Yifan Hong63c5ca12020-10-08 11:54:02 -07004452ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
4453 $(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
4454endif
Kelvin Zhang5a65f692020-11-03 16:40:18 -05004455ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
4456 $(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
4457endif
Daniel Normane1e48082019-06-27 13:55:23 -07004458
4459.PHONY: misc_info
4460misc_info: $(INSTALLED_MISC_INFO_TARGET)
4461
4462droidcore: $(INSTALLED_MISC_INFO_TARGET)
4463
4464# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004465# A zip of the directories that map to the target filesystem.
4466# This zip can be used to create an OTA package or filesystem image
4467# as a post-build step.
4468#
4469name := $(TARGET_PRODUCT)
4470ifeq ($(TARGET_BUILD_TYPE),debug)
4471 name := $(name)_debug
4472endif
4473name := $(name)-target_files-$(FILE_NAME_TAG)
4474
4475intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4476BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4477$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4478$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004479 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004480
4481# $(1): Directory to copy
4482# $(2): Location to copy it to
4483# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4484define package_files-copy-root
4485 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4486 mkdir -p $(2) && \
4487 $(ACP) -rd $(strip $(1))/* $(2); \
4488 fi
4489endef
4490
Tao Baoa04fca32015-11-30 12:22:24 -08004491built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004492
4493# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004494ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004495built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004496 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004497endif
4498
The Android Open Source Project88b60792009-03-03 19:28:42 -08004499$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4500
Dan Willemsen653bea92017-03-21 15:47:37 -07004501tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004502$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004503
Sen Jiang4438fd92016-03-07 16:51:01 -08004504ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004505updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004506endif
4507
4508# Build OTA tools if non-A/B is allowed
4509ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004510updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004511endif
Yifan Hong65afc072020-04-17 10:08:10 -07004512
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004513$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004514
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004515# If we are using recovery as boot, output recovery files to BOOT/.
Yifan Hong881df392020-10-09 14:29:39 -07004516# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004517ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4518$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
Yifan Hong881df392020-10-09 14:29:39 -07004519else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
4520$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004521else
4522$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4523endif
4524
Dan Willemsen653bea92017-03-21 15:47:37 -07004525ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004526 ifdef OSRELEASED_DIRECTORY
4527 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4528 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4529 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4530 endif
Tao Baoa835f382019-07-18 15:55:30 -07004531
4532 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4533 # additionally include radio or bootloader partitions).
4534 ifeq ($(AB_OTA_PARTITIONS),)
4535 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4536 endif
4537endif
4538
4539ifneq ($(AB_OTA_PARTITIONS),)
4540 ifneq ($(AB_OTA_UPDATER),true)
4541 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4542 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004543endif
4544
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004545# Run fs_config while creating the target files package
4546# $1: root directory
4547# $2: add prefix
4548define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004549(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 -08004550endef
4551
Yifan Hong60bfcc42019-11-01 11:39:45 -07004552# Filter out vendor from the list for AOSP targets.
4553# $(1): list
4554define filter-out-missing-vendor
4555$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4556endef
4557
4558# Information related to dynamic partitions and virtual A/B. This information
4559# is needed for building the super image (see dump-super-image-info) and
4560# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004561# $(1): file
4562define dump-dynamic-partitions-info
4563 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4564 echo "use_dynamic_partitions=true" >> $(1))
4565 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4566 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004567 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4568 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4569 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004570 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4571 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004572 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4573 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4574 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4575 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4576 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4577 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004578 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004579 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4580 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4581 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4582 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4583 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004584 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 -07004585 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4586 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004587 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4588 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004589 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4590 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004591 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4592 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4593 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4594 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4595 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4596 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4597 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4598 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004599 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4600 echo "virtual_ab=true" >> $(1))
Kelvin Zhang239a79a2021-01-15 13:47:52 -05004601 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
4602 echo "virtual_ab_compression=true" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004603 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4604 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004605endef
4606
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004607# By conditionally including the dependency of the target files package on the
4608# full system image deps, we speed up builds that do not build the system
4609# image.
4610ifdef BUILDING_SYSTEM_IMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004611 $(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4612endif
4613
4614ifdef BUILDING_USERDATA_IMAGE
4615 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_USERDATAIMAGE_FILES)
4616endif
4617
4618ifdef BUILDING_SYSTEM_OTHER_IMAGE
4619 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
4620endif
4621
4622ifdef BUILDING_VENDOR_BOOT_IMAGE
4623 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FILES)
Yo Chiangd21e7dc2020-12-10 18:42:47 +08004624 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
Colin Crosse6431202021-02-24 11:44:55 -08004625 # The vendor ramdisk may be built from the recovery ramdisk.
4626 ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
4627 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
4628 endif
Colin Cross43f2eb22020-08-26 18:41:29 -07004629endif
4630
4631ifdef BUILDING_RECOVERY_IMAGE
4632 # TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
Colin Crosse6431202021-02-24 11:44:55 -08004633 # BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
Colin Cross43f2eb22020-08-26 18:41:29 -07004634 # commands in build-recoveryimage-target, which would touch the files under
4635 # TARGET_RECOVERY_OUT and race with packaging target-files.zip.
4636 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4637 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4638 else
4639 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_RECOVERYIMAGE_TARGET)
4640 endif
4641 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RECOVERYIMAGE_FILES)
4642endif
4643
4644# Conditionally depend on the image files if the image is being built so the
4645# target-files.zip rule doesn't wait on the image creation rule, or the image
4646# if it is coming from a prebuilt.
4647
4648ifdef BUILDING_VENDOR_IMAGE
4649 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDORIMAGE_FILES)
4650else ifdef BOARD_PREBUILT_VENDORIMAGE
4651 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDORIMAGE_TARGET)
4652endif
4653
4654ifdef BUILDING_PRODUCT_IMAGE
4655 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_PRODUCTIMAGE_FILES)
4656else ifdef BOARD_PREBUILT_PRODUCTIMAGE
4657 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_PRODUCTIMAGE_TARGET)
4658endif
4659
4660ifdef BUILDING_SYSTEM_EXT_IMAGE
4661 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
4662else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
4663 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
4664endif
4665
4666ifdef BUILDING_BOOT_IMAGE
4667 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_RAMDISK_FILES)
Yifan Hong49968aa2020-11-09 11:52:52 -08004668endif
4669ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
Colin Cross43f2eb22020-08-26 18:41:29 -07004670 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTIMAGE_TARGET)
4671endif
4672
4673ifdef BUILDING_ODM_IMAGE
4674 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODMIMAGE_FILES)
4675else ifdef BOARD_PREBUILT_ODMIMAGE
4676 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODMIMAGE_TARGET)
4677endif
4678
4679ifdef BUILDING_VENDOR_DLKM_IMAGE
4680 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08004681else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004682 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
4683endif
4684
4685ifdef BUILDING_ODM_DLKM_IMAGE
4686 $(BUILT_TARGET_FILES_PACKAGE): $(INTERNAL_ODM_DLKMIMAGE_FILES)
Petri Gynther689e11a2021-03-10 20:53:23 -08004687else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
Colin Cross43f2eb22020-08-26 18:41:29 -07004688 $(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004689endif
4690
Isaac Chen9e09d472019-07-05 17:30:41 +08004691ifeq ($(BUILD_QEMU_IMAGES),true)
Colin Cross43f2eb22020-08-26 18:41:29 -07004692 MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4693 $(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
Isaac Chen9e09d472019-07-05 17:30:41 +08004694endif
4695
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004696ifdef BOARD_PREBUILT_BOOTLOADER
4697$(BUILT_TARGET_FILES_PACKAGE): $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah9fe40ca2020-08-31 12:29:09 -07004698droidcore: $(INSTALLED_BOOTLOADER_MODULE)
Ram Muthiah0c4a3522020-08-27 00:54:13 +00004699endif
4700
The Android Open Source Project88b60792009-03-03 19:28:42 -08004701# Depending on the various images guarantees that the underlying
4702# directories are up-to-date.
4703$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004704 $(INSTALLED_RADIOIMAGE_TARGET) \
4705 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004706 $(INSTALLED_CACHEIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004707 $(INSTALLED_DTBOIMAGE_TARGET) \
Andrew Scull9b103e42020-11-29 14:04:28 +00004708 $(INSTALLED_PVMFWIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004709 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004710 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4711 $(INSTALLED_KERNEL_TARGET) \
Enrico Granata16059382020-10-14 15:17:20 -06004712 $(INSTALLED_RAMDISK_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004713 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004714 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4715 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004716 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004717 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004718 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4719 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4720 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004721 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004722 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004723 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Yifan Hongf496f1b2020-07-15 16:52:59 -07004724 $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004725 $(LPMAKE) \
4726 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004727 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004728 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004729 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004730 $(SOONG_ZIP) \
4731 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004732 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004733 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004734 $(BUILT_KERNEL_CONFIGS_FILE) \
4735 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004736 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004737 @echo "Package target files: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004738 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004739 $(hide) mkdir -p $(dir $@) $(zip_root)
Yifan Hong881df392020-10-09 14:29:39 -07004740ifneq (,$(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 -08004741 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004742 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004743 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004744 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004745ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004746ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
Steve Muckleb3dda772020-03-11 16:03:07 -07004747 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
Yifan Hong63c5ca12020-10-08 11:54:02 -07004748else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Steve Muckle04b6f052020-08-09 14:36:56 -07004749 cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
4750endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004751endif
Yifan Hong78860162020-10-28 14:15:21 -07004752ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004753ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004754 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004755endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004756ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004757ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004758 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004759else
Steve Mucklee1b10862019-07-10 10:49:37 -07004760 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004761endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004762endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004763ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004764 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004765endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004766ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004767 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004768endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004769ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004770ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004771 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Yifan Hongaad34e52020-10-12 11:08:30 -07004772endif # INTERNAL_KERNEL_CMDLINE != ""
4773endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
Doug Zongker38a649f2009-06-17 09:07:09 -07004774ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004775 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004776endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004777ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004778 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004779endif
Yifan Hong3941a872020-10-28 16:33:06 -07004780endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004781endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004782 @# Components of the boot image
4783 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004784 $(hide) mkdir -p $(zip_root)/ROOT
4785 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004786 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004787 @# If we are using recovery as boot, this is already done when processing recovery.
4788ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004789ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004790 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004791 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004792endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004793ifdef INSTALLED_KERNEL_TARGET
Steve Muckle04b6f052020-08-09 14:36:56 -07004794 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004795endif
Yifan Hong46aff092020-10-28 13:50:47 -07004796ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
Yifan Hongaad34e52020-10-12 11:08:30 -07004797 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Yifan Hong46aff092020-10-28 13:50:47 -07004798else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Yifan Hongaad34e52020-10-12 11:08:30 -07004799 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004800ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004801 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004802endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004803ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004804 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004805endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004806ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004807 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004808endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004809ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004810 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004811endif
Yifan Hongaad34e52020-10-12 11:08:30 -07004812endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
Steve Mucklee1b10862019-07-10 10:49:37 -07004813endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004814 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4815 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004816 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004817ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4818 mkdir -p $(zip_root)/VENDOR_BOOT
4819 $(call package_files-copy-root, \
4820 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4821ifdef INSTALLED_DTBIMAGE_TARGET
4822 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4823endif
Devin Moore50509012021-01-13 10:45:04 -08004824ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
4825 cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
4826endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004827ifdef BOARD_KERNEL_BASE
4828 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4829endif
4830ifdef BOARD_KERNEL_PAGESIZE
4831 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4832endif
4833 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
Yo Chiangd21e7dc2020-12-10 18:42:47 +08004834ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
4835 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
4836 $(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
4837 mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
4838 echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
4839 $(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
4840 $(if $(prebuilt_ramdisk), \
4841 cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
4842 $(call package_files-copy-root, \
4843 $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
4844 $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
4845 ))
4846endif # BOARD_VENDOR_RAMDISK_FRAGMENTS != ""
Steve Mucklee1b10862019-07-10 10:49:37 -07004847endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004848ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004849 @# Contents of the system image
4850 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004851 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004852endif
4853ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004854 @# Contents of the data image
4855 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004856 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004857endif
4858ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004859 @# Contents of the vendor image
4860 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004861 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004862endif
Dan Willemsen67495202019-01-16 12:42:05 -08004863ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004864 @# Contents of the product image
4865 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004866 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004867endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004868ifdef BUILDING_SYSTEM_EXT_IMAGE
4869 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004870 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004871 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004872endif
Dan Willemsen67495202019-01-16 12:42:05 -08004873ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004874 @# Contents of the odm image
4875 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004876 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004877endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004878ifdef BUILDING_VENDOR_DLKM_IMAGE
4879 @# Contents of the vendor_dlkm image
4880 $(hide) $(call package_files-copy-root, \
4881 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4882endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004883ifdef BUILDING_ODM_DLKM_IMAGE
4884 @# Contents of the odm_dlkm image
4885 $(hide) $(call package_files-copy-root, \
4886 $(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
4887endif
Dan Willemsen67495202019-01-16 12:42:05 -08004888ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004889 @# Contents of the system_other image
4890 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004891 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004892endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004893 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004894 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004895 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Enrico Granata16059382020-10-14 15:17:20 -06004896ifdef BUILDING_RAMDISK_IMAGE
4897ifeq (true,$(BOARD_IMG_USE_RAMDISK))
4898 @# Contents of the ramdisk image
4899 $(hide) mkdir -p $(zip_root)/IMAGES
4900 $(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
4901endif
4902endif
Yifan Hong65afc072020-04-17 10:08:10 -07004903ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004904ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004905 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004906 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004907endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004908endif
Doug Zongker8678df42009-06-15 14:30:14 -07004909 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004910 @# build them.
4911 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004912 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004913 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004914ifneq ($(tool_extension),)
4915 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4916endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004917 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004918 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004919 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004920ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4921 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4922 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004923endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004924ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4925 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4926 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004927endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004928ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4929 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4930 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004931endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004932ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4933 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4934 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004935endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004936ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4937 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4938 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004939endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004940ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4941 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4942 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4943endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07004944ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
4945 $(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
4946 $(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
4947endif
Yifan Hong65afc072020-04-17 10:08:10 -07004948ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004949ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004950 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004951 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004952endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004953endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004954ifeq ($(AB_OTA_UPDATER),true)
4955 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004956 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004957 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004958 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4959 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004960 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4961 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4962 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004963ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004964 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4965 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4966 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004967endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004968endif
Steve Fungdfbab492015-09-24 18:12:33 -07004969ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004970 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004971 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004972endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004973ifdef BOARD_PREBUILT_VENDORIMAGE
4974 $(hide) mkdir -p $(zip_root)/IMAGES
4975 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4976endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004977ifdef BOARD_PREBUILT_PRODUCTIMAGE
4978 $(hide) mkdir -p $(zip_root)/IMAGES
4979 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4980endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004981ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004982 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004983 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004984endif
Yifan Hong49968aa2020-11-09 11:52:52 -08004985ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
4986ifdef INSTALLED_BOOTIMAGE_TARGET
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004987 $(hide) mkdir -p $(zip_root)/IMAGES
4988 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hong49968aa2020-11-09 11:52:52 -08004989endif # INSTALLED_BOOTIMAGE_TARGET
4990endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004991ifdef BOARD_PREBUILT_ODMIMAGE
4992 $(hide) mkdir -p $(zip_root)/IMAGES
4993 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4994endif
Colin Cross6af7cbe2020-08-26 18:41:04 -07004995ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
Yifan Hongcfb917a2020-05-07 14:58:20 -07004996 $(hide) mkdir -p $(zip_root)/IMAGES
Colin Cross6af7cbe2020-08-26 18:41:04 -07004997 $(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
4998endif
4999ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
5000 $(hide) mkdir -p $(zip_root)/IMAGES
5001 $(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
Yifan Hongcfb917a2020-05-07 14:58:20 -07005002endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07005003ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07005004 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5005 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08005006endif # BOARD_PREBUILT_DTBOIMAGE
Andrew Scull9b103e42020-11-29 14:04:28 +00005007ifdef BOARD_PREBUILT_PVMFWIMAGE
5008 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5009 $(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
5010endif # BOARD_PREBUILT_PVMFWIMAGE
Ram Muthiah0c4a3522020-08-27 00:54:13 +00005011ifdef BOARD_PREBUILT_BOOTLOADER
5012 $(hide) mkdir -p $(zip_root)/IMAGES
5013 $(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
5014endif
Hongguang Chenf23364d2020-04-27 18:36:36 -07005015ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
5016 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
5017 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
5018 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
5019endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07005020 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
5021 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
5022 @# INSTALLED_RADIOIMAGE_TARGET.
5023 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
5024 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005025 @# Run fs_config on all the system, vendor, boot ramdisk,
5026 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08005027ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005028 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08005029endif
5030ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005031 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
5032endif
Dan Willemsen67495202019-01-16 12:42:05 -08005033ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005034 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
5035endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005036ifdef BUILDING_SYSTEM_EXT_IMAGE
5037 $(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 +01005038endif
Dan Willemsen67495202019-01-16 12:42:05 -08005039ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005040 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
5041endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005042ifdef BUILDING_VENDOR_DLKM_IMAGE
5043 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
5044endif
Yifan Hongf496f1b2020-07-15 16:52:59 -07005045ifdef BUILDING_ODM_DLKM_IMAGE
5046 $(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
5047endif
Tom Cherryd14b8952018-08-09 14:26:00 -07005048 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005049 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005050ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07005051 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005052 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08005053endif
Steve Mucklee1b10862019-07-10 10:49:37 -07005054ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
5055 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
5056endif
Tom Cherry2929cad2018-09-20 11:04:37 -07005057ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
5058 @# 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 -08005059 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
5060endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005061ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
5062 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
5063endif
Dan Willemsen67495202019-01-16 12:42:05 -08005064ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08005065 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
5066endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07005067 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07005068ifdef BUILT_KERNEL_CONFIGS_FILE
5069 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
5070endif
5071ifdef BUILT_KERNEL_VERSION_FILE
5072 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
5073endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07005074 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
5075ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5076 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
5077endif
Tao Baocbd6d492019-10-07 22:46:02 -07005078 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
5079 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08005080ifeq ($(BUILD_QEMU_IMAGES),true)
5081 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
5082 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
5083endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08005084 @# Zip everything up, preserving symlinks and placing META/ files first to
5085 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005086 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07005087 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Colin Cross17e98b72021-02-03 16:03:55 -08005088 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07005089
Ying Wanga0febe52013-03-20 11:02:05 -07005090.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08005091target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
5092
Ying Wang4709d7c2014-04-14 17:25:43 -07005093$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
Doug Zongker367910f2009-06-15 18:56:51 -07005094
Dan Albert4d323332016-10-14 13:23:06 -07005095# -----------------------------------------------------------------
5096# NDK Sysroot Package
5097NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07005098$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07005099 @echo Package NDK sysroot...
5100 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
5101
5102$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
5103
Ying Wang09c4b682015-08-11 11:24:19 -07005104ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07005105# -----------------------------------------------------------------
5106# OTA update package
5107
Yifan Hong50e79542018-11-08 17:44:12 -08005108# $(1): output file
5109# $(2): additional args
5110define build-ota-package-target
Tianjie6bd3b1a2020-10-16 18:53:47 -07005111PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07005112 $(OTA_FROM_TARGET_FILES) \
5113 --verbose \
5114 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
5115 --path $(HOST_OUT) \
5116 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
5117 $(2) \
5118 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08005119endef
5120
Tianjie6bd3b1a2020-10-16 18:53:47 -07005121product_name := $(TARGET_PRODUCT)
Doug Zongker8678df42009-06-15 14:30:14 -07005122ifeq ($(TARGET_BUILD_TYPE),debug)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005123 product_name := $(product_name)_debug
Doug Zongker8678df42009-06-15 14:30:14 -07005124endif
Tianjie6bd3b1a2020-10-16 18:53:47 -07005125name := $(product_name)-ota-$(FILE_NAME_TAG)
Doug Zongker8678df42009-06-15 14:30:14 -07005126
5127INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08005128INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
5129
Doug Zongker8678df42009-06-15 14:30:14 -07005130$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08005131$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Yifan Hong5c1b1992020-10-08 09:36:29 -07005132$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07005133 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08005134 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07005135
5136.PHONY: otapackage
5137otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
5138
Tao Bao519d1822018-12-27 12:47:23 -08005139ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Tianjie6bd3b1a2020-10-16 18:53:47 -07005140name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG)
Yifan Hong50e79542018-11-08 17:44:12 -08005141
5142INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08005143$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07005144$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
5145 $(BUILT_TARGET_FILES_PACKAGE) \
Yifan Hong5c1b1992020-10-08 09:36:29 -07005146 $(OTA_FROM_TARGET_FILES) \
5147 $(INTERNAL_OTATOOLS_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08005148 @echo "Package OTA (retrofit dynamic partitions): $@"
5149 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
5150
5151.PHONY: otardppackage
5152
5153otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
5154
Tao Bao519d1822018-12-27 12:47:23 -08005155endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08005156
Tianjie6bd3b1a2020-10-16 18:53:47 -07005157ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
5158name := $(product_name)-partial-ota-$(FILE_NAME_TAG)
5159
5160INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5161$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
5162$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
5163 @echo "Package partial OTA: $@"
5164 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
5165
5166.PHONY: partialotapackage
5167partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
5168
5169endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
5170
Ying Wang09c4b682015-08-11 11:24:19 -07005171endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07005172
Ying Wang09a00a62010-10-20 14:01:09 -07005173# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01005174# A zip of the appcompat directory containing logs
5175APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
5176# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005177ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Crosscda30c72020-08-26 18:43:21 -07005178$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
5179 $(INTERNAL_RAMDISK_FILES) \
5180 $(INTERNAL_USERDATAIMAGE_FILES) \
5181 $(INTERNAL_VENDORIMAGE_FILES) \
5182 $(INTERNAL_PRODUCTIMAGE_FILES) \
5183 $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Frenid1011272018-07-23 20:20:15 +01005184endif
5185$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
5186$(APPCOMPAT_ZIP): $(SOONG_ZIP)
5187 @echo "appcompat logs: $@"
5188 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5189 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
5190 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
5191 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
5192
Dario Frenid1011272018-07-23 20:20:15 +01005193# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005194# A zip of the symbols directory. Keep the full paths to make it
5195# more obvious where these files came from.
5196#
5197name := $(TARGET_PRODUCT)
5198ifeq ($(TARGET_BUILD_TYPE),debug)
5199 name := $(name)_debug
5200endif
5201name := $(name)-symbols-$(FILE_NAME_TAG)
5202
5203SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07005204# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005205ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005206$(SYMBOLS_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07005207endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005208$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
5209$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005210 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07005211 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5212 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09005213 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07005214 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005215# -----------------------------------------------------------------
5216# A zip of the coverage directory.
5217#
Oliver Nguyene91ab232019-04-30 15:14:44 -07005218name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07005219ifeq ($(TARGET_BUILD_TYPE),debug)
5220name := $(name)_debug
5221endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07005222COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005223ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005224$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
Ryan Campbell81c9d292016-09-12 13:56:50 -07005225endif
5226$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
5227$(COVERAGE_ZIP): $(SOONG_ZIP)
5228 @echo "Package coverage: $@"
5229 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
5230 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
5231 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
5232 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005233
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08005234#------------------------------------------------------------------
5235# Export the LLVM profile data tool and dependencies for Clang coverage processing
5236#
5237ifeq (true,$(CLANG_COVERAGE))
5238 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
5239 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
5240 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
5241 $(PROFDATA_ZIP): $(SOONG_ZIP)
5242 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
5243
5244 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
5245endif
5246
The Android Open Source Project88b60792009-03-03 19:28:42 -08005247# -----------------------------------------------------------------
5248# A zip of the Android Apps. Not keeping full path so that we don't
5249# include product names when distributing
5250#
5251name := $(TARGET_PRODUCT)
5252ifeq ($(TARGET_BUILD_TYPE),debug)
5253 name := $(name)_debug
5254endif
5255name := $(name)-apps-$(FILE_NAME_TAG)
5256
5257APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Crosscda30c72020-08-26 18:43:21 -07005258$(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005259 @echo "Package apps: $@"
5260 $(hide) rm -rf $@
5261 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005262 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
5263 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00005264 echo "No apps to zip up. Generating empty apps archive." ; \
5265 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005266 else \
Anton Hansson6d814982018-11-26 18:12:05 +00005267 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07005268 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07005269
Ying Wangbc415dd2012-08-15 12:22:44 -07005270ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07005271#------------------------------------------------------------------
5272# An archive of classes for use in generating code-coverage reports
5273# These are the uninstrumented versions of any classes that were
5274# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07005275# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005276
Colin Crossa6bc3a82017-09-27 14:28:41 -07005277JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005278$(JACOCO_REPORT_CLASSES_ALL) :
5279 @echo "Collecting uninstrumented classes"
Colin Crosse8ac9952020-10-09 18:41:58 -07005280 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 -08005281 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005282
Jiyong Park3c875602021-01-21 12:46:56 +09005283ifeq (,$(TARGET_BUILD_UNBUNDLED))
5284 $(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
5285endif
Ying Wangbc415dd2012-08-15 12:22:44 -07005286endif # EMMA_INSTRUMENT=true
5287
Jeff Gastonaaae43c2017-04-11 16:36:46 -07005288
Ying Wangae9115a2013-08-22 20:52:47 -07005289#------------------------------------------------------------------
5290# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07005291#
Ying Wangc62c92c2013-08-28 18:38:25 -07005292PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07005293# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01005294ifeq (,$(TARGET_BUILD_UNBUNDLED))
Jiyong Parkf66f0ec2021-01-14 11:19:54 +09005295$(PROGUARD_DICT_ZIP): $(INTERNAL_ALLIMAGES_FILES) $(updater_dep)
Colin Cross114e8df2019-09-05 17:19:35 -07005296endif
5297$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
5298$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07005299 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07005300 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5301 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
5302 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
5303 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07005304
Colin Crossa9b9e6e2020-08-14 17:43:35 -07005305#------------------------------------------------------------------
5306# A zip of Proguard usage files.
5307#
5308PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip
5309# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
5310ifeq (,$(TARGET_BUILD_UNBUNDLED))
5311$(PROGUARD_USAGE_ZIP): \
5312 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5313 $(INSTALLED_RAMDISK_TARGET) \
5314 $(INSTALLED_BOOTIMAGE_TARGET) \
5315 $(INSTALLED_USERDATAIMAGE_TARGET) \
5316 $(INSTALLED_VENDORIMAGE_TARGET) \
5317 $(INSTALLED_PRODUCTIMAGE_TARGET) \
5318 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
5319 $(INSTALLED_ODMIMAGE_TARGET) \
5320 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
5321 $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
5322 $(updater_dep)
5323endif
5324$(PROGUARD_USAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard_usage)/filelist
5325$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS)
5326 @echo "Packaging Proguard usage files."
5327 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
5328 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_usage.zip > $(PRIVATE_LIST_FILE)
5329 $(MERGE_ZIPS) $@ @$(PRIVATE_LIST_FILE)
Tao Bao48a2feb2019-06-28 11:00:05 -07005330
5331ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
5332
5333# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
5334# $(1): output file
5335define dump-super-image-info
5336 $(call dump-dynamic-partitions-info,$(1))
5337 $(if $(filter true,$(AB_OTA_UPDATER)), \
5338 echo "ab_update=true" >> $(1))
5339endef
5340
5341endif # PRODUCT_USE_DYNAMIC_PARTITIONS
5342
The Android Open Source Project88b60792009-03-03 19:28:42 -08005343# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07005344# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005345
5346ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5347
5348# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
5349ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5350
5351ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005352
5353# For real devices and for dist builds, build super image from target files to an intermediate directory.
5354INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
5355$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
5356$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
5357 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08005358 PATH=$(dir $(LPMAKE)):$$PATH \
5359 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07005360
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005361# Skip packing it in dist package because it is in update package.
5362ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07005363$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005364endif
Yifan Hongacd862a2019-04-16 15:44:30 -07005365
5366.PHONY: superimage_dist
5367superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07005368
5369endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07005370endif # BOARD_SUPER_PARTITION_SIZE != ""
5371endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005372
Yifan Hongacd862a2019-04-16 15:44:30 -07005373# -----------------------------------------------------------------
5374# super partition image for development
5375
5376ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
5377ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
5378ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
5379
5380# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
5381# $(1): built image path
5382# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
5383define build-superimage-target
5384 mkdir -p $(dir $(2))
5385 rm -rf $(2)
5386 $(call dump-super-image-info,$(2))
5387 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
5388 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09005389 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
5390 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07005391 mkdir -p $(dir $(1))
5392 PATH=$(dir $(LPMAKE)):$$PATH \
5393 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
5394endef
5395
5396INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
5397INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
5398 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
5399
changho.shina8f9f112019-10-15 13:26:19 +09005400ifdef BUILDING_SYSTEM_OTHER_IMAGE
5401ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
5402INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
5403endif
5404endif
5405
Yifan Hongacd862a2019-04-16 15:44:30 -07005406# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
5407# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
5408# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
5409# virtual devices.
5410ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
5411$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5412 $(call pretty,"Target super fs image for debug: $@")
5413 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08005414 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005415
5416droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
5417
5418# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
5419.PHONY: superimage
5420superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08005421
5422$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07005423endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
5424
5425# Build $(PRODUCT_OUT)/super.img without dependencies.
5426.PHONY: superimage-nodeps supernod
5427superimage-nodeps supernod: intermediates :=
5428superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
5429 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
5430 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
5431 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
5432
5433endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
5434endif # BOARD_SUPER_PARTITION_SIZE != ""
5435endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
5436
5437# -----------------------------------------------------------------
5438# super empty image
5439
Tao Bao48a2feb2019-06-28 11:00:05 -07005440ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07005441ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08005442
Yifan Hong8b79d162018-11-29 12:32:00 -08005443INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
5444$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
5445$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
5446 $(call pretty,"Target empty super fs image: $@")
5447 mkdir -p $(intermediates)
5448 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07005449 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08005450 PATH=$(dir $(LPMAKE)):$$PATH \
5451 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08005452
5453$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
5454
Yifan Hong2b891ac2018-11-29 12:06:31 -08005455endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07005456endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08005457
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005458
5459# -----------------------------------------------------------------
5460# The update package
5461
5462name := $(TARGET_PRODUCT)
5463ifeq ($(TARGET_BUILD_TYPE),debug)
5464 name := $(name)_debug
5465endif
5466name := $(name)-img-$(FILE_NAME_TAG)
5467
5468INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5469
Tao Bao57f8ed62019-08-14 23:08:18 -07005470$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
5471 $(call pretty,"Package: $@")
5472 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
5473 $(IMG_FROM_TARGET_FILES) \
5474 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
5475 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005476
5477.PHONY: updatepackage
5478updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07005479$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07005480
5481
Yifan Hong2b891ac2018-11-29 12:06:31 -08005482# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005483# dalvik something
5484.PHONY: dalvikfiles
5485dalvikfiles: $(INTERNAL_DALVIK_MODULES)
5486
Bo Huf0d50bb2017-08-01 19:02:09 +00005487ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00005488MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08005489MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00005490SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08005491
5492ifdef INSTALLED_SYSTEMIMAGE_TARGET
5493INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08005494INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
5495$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
5496 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
5497 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08005498$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08005499 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
5500 @echo Create system-qemu.img now
5501 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08005502 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00005503
5504systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
5505droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08005506endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005507ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00005508INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005509$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00005510 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005511 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005512
5513vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5514droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5515endif
bohu8fd437c2020-03-30 20:16:13 -07005516
5517ifdef INSTALLED_RAMDISK_TARGET
5518ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5519ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5520INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5521$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5522 @echo Create ramdisk-qemu.img
5523 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5524
5525droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5526endif
5527endif
5528endif
5529
Anton Hansson32c76fe2018-12-13 14:34:18 +00005530ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005531INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005532$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005533 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005534 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005535
5536productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5537droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5538endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005539ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5540INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5541$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5542 @echo Create system_ext-qemu.img
5543 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005544
Justin Yun6151e3f2019-06-25 15:58:13 +09005545systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5546droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005547endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005548ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005549INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5550$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5551 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005552 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005553
5554odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5555droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5556endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005557
Yifan Hongcfb917a2020-05-07 14:58:20 -07005558ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5559INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5560$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5561 @echo Create vendor_dlkm-qemu.img
5562 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5563
5564vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5565droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5566endif
5567
Yifan Hongf496f1b2020-07-15 16:52:59 -07005568ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
5569INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
5570$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5571 @echo Create odm_dlkm-qemu.img
5572 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
5573
5574odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5575droidcore: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
5576endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07005577
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005578QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005579$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5580 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005581 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005582 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5583 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005584
5585systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5586droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005587
Bo Huf0d50bb2017-08-01 19:02:09 +00005588endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005589# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005590# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005591ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005592INTERNAL_EMULATOR_PACKAGE_FILES += \
5593 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005594 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005595 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005596 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5597 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005598
5599name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5600
5601INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5602
Ying Wang5d887702015-11-04 10:06:25 -08005603$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005604 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005605 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005606
Ying Wang7d8c5352012-07-26 10:15:21 -07005607endif
Keun young Park7fc7aad2012-02-27 15:49:23 -08005608
The Android Open Source Project88b60792009-03-03 19:28:42 -08005609
5610# -----------------------------------------------------------------
5611# The SDK
5612
The Android Open Source Project88b60792009-03-03 19:28:42 -08005613# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005614sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005615
5616# Build a name that looks like:
5617#
5618# linux-x86 --> android-sdk_12345_linux-x86
5619# darwin-x86 --> android-sdk_12345_mac-x86
5620# windows-x86 --> android-sdk_12345_windows
5621#
5622sdk_name := android-sdk_$(FILE_NAME_TAG)
5623ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005624 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005625else
Joe Onorato03fbe402009-04-13 08:31:16 -07005626 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005627endif
5628ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005629 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005630endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005631sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005632
5633sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5634
5635ATREE_FILES :=
5636-include $(sdk_dep_file)
5637
5638# if we don't have a real list, then use "everything"
5639ifeq ($(strip $(ATREE_FILES)),)
5640ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005641 $(ALL_DEFAULT_INSTALLED_MODULES) \
5642 $(INSTALLED_RAMDISK_TARGET) \
5643 $(ALL_DOCS) \
5644 $(ALL_SDK_FILES)
5645endif
5646
5647atree_dir := development/build
5648
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005649
The Android Open Source Project88b60792009-03-03 19:28:42 -08005650sdk_atree_files := \
5651 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005652 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005653
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005654# development/build/sdk-android-<abi>.atree is used to differentiate
5655# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5656# files like the kernel image. We use TARGET_CPU_ABI because we don't
5657# have a better way to distinguish between CPU models.
5658ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5659 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5660endif
5661
Anton Hansson8dab0a62019-03-28 15:45:40 +00005662ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5663sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005664else
5665sdk_atree_files += $(atree_dir)/sdk.atree
5666endif
5667
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005668include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005669
The Android Open Source Project88b60792009-03-03 19:28:42 -08005670deps := \
5671 $(target_notice_file_txt) \
5672 $(tools_notice_file_txt) \
5673 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005674 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005675 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005676 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005677 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005678 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005679 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005680 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005681 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005682 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005683 $(INSTALLED_USERDATAIMAGE_TARGET) \
5684 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005685 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005686 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005687 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005688 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005689 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005690 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005691 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005692
5693INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5694$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5695$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5696$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5697$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5698
5699# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5700#
5701#SDK_GNU_ERROR := true
5702
Ying Wang5d887702015-11-04 10:06:25 -08005703$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005704 @echo "Package SDK: $@"
5705 $(hide) rm -rf $(PRIVATE_DIR) $@
5706 $(hide) for f in $(target_gnu_MODULES); do \
5707 if [ -f $$f ]; then \
5708 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5709 including GNU target $$f >&2; \
5710 FAIL=$(SDK_GNU_ERROR); \
5711 fi; \
5712 done; \
5713 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005714 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005715 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005716 ATREE_STRIP="$(HOST_STRIP) -x" \
5717 $(HOST_OUT_EXECUTABLES)/atree \
5718 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5719 -m $(PRIVATE_DEP_FILE) \
5720 -I . \
5721 -I $(PRODUCT_OUT) \
5722 -I $(HOST_OUT) \
5723 -I $(TARGET_COMMON_OUT_ROOT) \
5724 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5725 -v "OUT_DIR=$(OUT_DIR)" \
5726 -v "HOST_OUT=$(HOST_OUT)" \
5727 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5728 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5729 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5730 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5731 -o $(PRIVATE_DIR) && \
5732 cp -f $(target_notice_file_txt) \
5733 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5734 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5735 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5736 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5737 chmod -R ug+rwX $(PRIVATE_DIR) && \
5738 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005739 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5740
Raphael3d224a02010-04-16 17:50:09 -07005741
5742# Is a Windows SDK requested? If so, we need some definitions from here
5743# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005744MAIN_SDK_NAME := $(sdk_name)
5745MAIN_SDK_DIR := $(sdk_dir)
5746MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005747ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005748include $(TOPDIR)development/build/tools/windows_sdk.mk
5749endif
5750
The Android Open Source Project88b60792009-03-03 19:28:42 -08005751# -----------------------------------------------------------------
5752# Findbugs
5753INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5754INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5755$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5756 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005757 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005758 > $@
5759$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5760 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005761 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005762 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005763
5764# -----------------------------------------------------------------
5765# Findbugs
5766
5767# -----------------------------------------------------------------
5768# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005769ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005770include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005771-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005772-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005773-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005774# Also the project-specific tasks
5775-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5776-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005777-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005778# Also add test specifc tasks
5779include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005780include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005781endif
Raphaelc4d47312011-02-15 16:09:36 -08005782
Ying Wang67132ba2015-10-28 16:42:39 -07005783include $(BUILD_SYSTEM)/product-graph.mk
5784
Raphaelc4d47312011-02-15 16:09:36 -08005785# -----------------------------------------------------------------
5786# Create SDK repository packages. Must be done after tasks/* since
5787# we need the addon rules defined.
5788ifneq ($(sdk_repo_goal),)
5789include $(TOPDIR)development/build/tools/sdk_repo.mk
5790endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005791
5792# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005793# Soong generates the list of all shared libraries that are depended on by fuzz
5794# targets. It saves this list as a source:destination pair to
5795# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5796# build of the unstripped shared library, and the destination is the
5797# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5798# where fuzz target shared libraries are to be "reinstalled". The
5799# copy-many-files below generates the rules to copy the unstripped shared
5800# libraries to the device or host "reinstallation" directory. These rules are
5801# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5802# a dependency on each shared library that it needs to be "reinstalled".
5803FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5804
5805# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005806# The rule to build all fuzz targets, and package them.
5807# Note: The packages are created in Soong, and in a perfect world,
5808# we'd be able to create the phony rule there. But, if we want to
5809# have dist goals for the fuzz target, we need to have the PHONY
5810# target defined in make. MakeVarsContext.DistForGoal doesn't take
5811# into account that a PHONY rule create by Soong won't be available
5812# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005813# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005814# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005815.PHONY: haiku
5816haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5817$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))