blob: f647f43406d2924d7a909382d587b32335e3db02 [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 Chiang0b49c032020-03-17 17:49:49 +080043check_elf_prebuilt_product_copy_files := true
Yo Chiang73d31482020-04-07 15:59:59 +080044ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
45check_elf_prebuilt_product_copy_files :=
Yo Chiang0b49c032020-03-17 17:49:49 +080046endif
47check_elf_prebuilt_product_copy_files_hint := \
48 found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
49
Ying Wang619fccf2012-09-05 18:08:29 -070050# filter out the duplicate <source file>:<dest file> pairs.
51unique_product_copy_files_pairs :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080052$(foreach cf,$(PRODUCT_COPY_FILES), \
Ying Wang619fccf2012-09-05 18:08:29 -070053 $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
54 $(eval unique_product_copy_files_pairs += $(cf))))
55unique_product_copy_files_destinations :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080056product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070057$(foreach cf,$(unique_product_copy_files_pairs), \
Ying Wang462d26b2010-11-02 21:31:47 -070058 $(eval _src := $(call word-colon,1,$(cf))) \
59 $(eval _dest := $(call word-colon,2,$(cf))) \
Dan Willemsen7d957c92018-04-30 16:01:33 -070060 $(call check-product-copy-files,$(cf),$(_dest)) \
Ying Wang193010c2011-12-16 11:54:25 -080061 $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
Dan Willemsen403b98a2017-11-15 11:13:23 -080062 $(eval product_copy_files_ignored += $(cf)), \
Ying Wang462d26b2010-11-02 21:31:47 -070063 $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
Ying Wang3ceecfa2012-05-14 14:39:00 -070064 $(if $(filter %.xml,$(_dest)),\
65 $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +010066 $(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
67 $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
Tom Cherryfc977642018-06-13 14:51:05 -070068 $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\
69 $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
Yo Chiang0b49c032020-03-17 17:49:49 +080070 $(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
71 $(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
72 $(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
73 $(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
Ying Wang7e8d4422011-06-17 17:05:35 -070074 $(eval unique_product_copy_files_destinations += $(_dest))))
Dan Willemsen403b98a2017-11-15 11:13:23 -080075
76# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
Dan Willemsen7537fd02018-10-16 23:15:08 -070077pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
78$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
79$(pcf_ignored_file):
80 echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
Dan Willemsen403b98a2017-11-15 11:13:23 -080081
Dan Willemsen7537fd02018-10-16 23:15:08 -070082$(call dist-for-goals,droidcore,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
83
84pcf_ignored_file :=
Dan Willemsen403b98a2017-11-15 11:13:23 -080085product_copy_files_ignored :=
Ying Wang619fccf2012-09-05 18:08:29 -070086unique_product_copy_files_pairs :=
Ying Wang7e8d4422011-06-17 17:05:35 -070087unique_product_copy_files_destinations :=
The Android Open Source Project88b60792009-03-03 19:28:42 -080088
89# -----------------------------------------------------------------
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +080090# Returns the max allowed size for an image suitable for hash verification
91# (e.g., boot.img, recovery.img, etc).
92# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
93# $(1): partition size to flash the image
94define get-hash-image-max-size
95$(if $(1), \
96 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
97 $(eval _hash_meta_size := 69632), \
98 $(eval _hash_meta_size := 0)) \
99 $(1)-$(_hash_meta_size))
100endef
101
102# -----------------------------------------------------------------
Dan Willemsen6f60f022016-02-23 13:40:07 -0800103# Define rules to copy headers defined in copy_headers.mk
104# If more than one makefile declared a header, print a warning,
105# then copy the last one defined. This matches the previous make
106# behavior.
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700107has_dup_copy_headers :=
Dan Willemsen6f60f022016-02-23 13:40:07 -0800108$(foreach dest,$(ALL_COPIED_HEADERS), \
109 $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800110 $(eval _src := $(lastword $(_srcs))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800111 $(if $(call streq,$(_src),$(_srcs)),, \
112 $(warning Duplicate header copy: $(dest)) \
Dan Willemsenf4249d12019-02-07 17:34:57 -0800113 $(warning _ Using $(_src)) \
114 $(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
115 $(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
116 $(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
117 $(warning _ Ignoring $(src)) \
118 $(warning __ from $(firstword $(_makefiles))) \
119 $(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
120 $(eval has_dup_copy_headers := true)) \
Dan Willemsen6f60f022016-02-23 13:40:07 -0800121 $(eval $(call copy-one-header,$(_src),$(dest))))
122all_copied_headers: $(ALL_COPIED_HEADERS)
123
Dan Willemsen7f9bd562018-08-15 14:28:01 -0700124ifdef has_dup_copy_headers
125 has_dup_copy_headers :=
Dan Willemsen1d4a56f2019-04-18 09:38:25 -0700126 $(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 -0700127endif
128
Dan Willemsen79a0caf2019-12-13 18:55:18 -0800129$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
130
Dan Willemsen6f60f022016-02-23 13:40:07 -0800131# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800132# docs/index.html
Martin Stjernholm7a430fd2020-06-04 15:16:39 +0100133ifeq (,$(TARGET_BUILD_UNBUNDLED))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800134gen := $(OUT_DOCS)/index.html
135ALL_DOCS += $(gen)
136$(gen): frameworks/base/docs/docs-redirect-index.html
137 @mkdir -p $(dir $@)
138 @cp -f $< $@
Ying Wang3f45b3c2012-04-02 18:21:36 -0700139endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800140
Dan Albert303e6032017-10-04 10:20:20 -0700141ndk_doxygen_out := $(OUT_NDK_DOCS)
142ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
143ndk_docs_src_dir := frameworks/native/docs
144ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
145ifneq ($(wildcard $(ndk_docs_src_dir)),)
146ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
147 $(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
148$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
149 @mkdir -p $(ndk_doxygen_out)
150 @echo "Generating NDK docs to $(ndk_doxygen_out)"
151 @( cat $(ndk_doxyfile); \
152 echo "INPUT=$(ndk_headers)"; \
153 echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
154 ) | doxygen -
155
156# Note: Not a part of the docs target because we don't have doxygen available.
157# You can run this target locally if you have doxygen installed.
158ndk-docs: $(ndk_doxygen_out)/index.html
159.PHONY: ndk-docs
160endif
161
Colin Crossd60401a2019-04-18 14:46:48 -0700162$(call dist-for-goals,sdk,$(API_FINGERPRINT))
Dan Willemsenad6a1542018-12-14 01:04:19 -0800163
Andres Moralesb8876e12015-05-06 20:44:22 -0700164INSTALLED_RECOVERYIMAGE_TARGET :=
Chris Grossa784ef12019-04-22 11:09:57 -0700165ifdef BUILDING_RECOVERY_IMAGE
166ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
167INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
168endif
Andres Moralesb8876e12015-05-06 20:44:22 -0700169endif
170
Jiyong Parke1346862020-05-18 14:31:30 +0900171include $(BUILD_SYSTEM)/sysprop.mk
Dario Freni5f681e12018-05-29 13:09:01 +0100172
173# ----------------------------------------------------------------
174
175# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800176# sdk-build.prop
177#
178# There are certain things in build.prop that we don't want to
179# ship with the sdk; remove them.
180
181# This must be a list of entire property keys followed by
182# "=" characters, without any internal spaces.
183sdk_build_prop_remove := \
184 ro.build.user= \
185 ro.build.host= \
186 ro.product.brand= \
187 ro.product.manufacturer= \
188 ro.product.device=
189# TODO: Remove this soon-to-be obsolete property
190sdk_build_prop_remove += ro.build.product=
191INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
192$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
193 @echo SDK buildinfo: $@
194 @mkdir -p $(dir $@)
195 $(hide) grep -v "$(subst $(space),\|,$(strip \
Anton Hansson6d814982018-11-26 18:12:05 +0000196 $(sdk_build_prop_remove)))" $< > $@.tmp
The Android Open Source Project88b60792009-03-03 19:28:42 -0800197 $(hide) for x in $(sdk_build_prop_remove); do \
Anton Hansson6d814982018-11-26 18:12:05 +0000198 echo "$$x"generic >> $@.tmp; done
The Android Open Source Project88b60792009-03-03 19:28:42 -0800199 $(hide) mv $@.tmp $@
200
201# -----------------------------------------------------------------
Colin Cross4f60e362019-06-05 11:53:43 -0700202# kernel modules
203
204# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
205DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
206
J. Avilaa2ceec62020-05-12 23:40:02 +0000207define copy-and-strip-kernel-module
208$(2): $(1)
J. Avilaf7586022020-06-19 20:42:17 +0000209 $(LLVM_STRIP) -o $(2) --strip-debug $(1)
J. Avilaa2ceec62020-05-12 23:40:02 +0000210endef
211
Colin Cross4f60e362019-06-05 11:53:43 -0700212# $(1): modules list
213# $(2): output dir
214# $(3): mount point
215# $(4): staging dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700216# $(5): module load list
217# $(6): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800218# $(7): module archive
J. Avilaa2ceec62020-05-12 23:40:02 +0000219# $(8): staging dir for stripped modules
Steve Muckle2335d762020-05-28 18:39:38 -0700220# $(9): module directory name
Colin Cross4f60e362019-06-05 11:53:43 -0700221# Returns the a list of src:dest pairs to install the modules using copy-many-files.
222define build-image-kernel-modules
Steve Muckle950d7232020-06-05 11:31:22 -0700223 $(if $(9), \
224 $(eval _dir := $(9)/), \
225 $(eval _dir :=)) \
J. Avilaa2ceec62020-05-12 23:40:02 +0000226 $(foreach module,$(1), \
227 $(eval _src := $(module)) \
228 $(if $(8), \
229 $(eval _src := $(8)/$(notdir $(module))) \
230 $(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700231 $(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700232 $(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9))) \
Steve Muckle950d7232020-06-05 11:31:22 -0700233 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
234 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
235 $(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
236 $(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700237endef
238
239# $(1): modules list
Steve Muckle474e4d02019-06-19 12:56:48 -0700240# $(2): mount point
241# $(3): staging dir
242# $(4): module load list
243# $(5): module load list filename
Steve Muckle810a0ba2019-11-13 13:29:02 -0800244# $(6): module archive
245# $(7): output dir
Steve Muckle2335d762020-05-28 18:39:38 -0700246# $(8): module directory name
Steve Muckle810a0ba2019-11-13 13:29:02 -0800247# TODO(b/144844424): If a module archive is being used, this step (which
248# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
249# the output directory. This should be moved to a module with a
250# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
251# the archive modules are restored along with modules.dep.
Colin Cross4f60e362019-06-05 11:53:43 -0700252define build-image-kernel-modules-depmod
Steve Muckle0f7bb1b2019-07-11 17:42:13 -0700253$(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 -0700254$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
255$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(1)
256$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
Steve Muckle2335d762020-05-28 18:39:38 -0700257$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
Steve Muckle474e4d02019-06-19 12:56:48 -0700258$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
259$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(4)
260$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800261$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
262$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
263$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
Colin Cross4f60e362019-06-05 11:53:43 -0700264 @echo depmod $$(PRIVATE_STAGING_DIR)
265 rm -rf $$(PRIVATE_STAGING_DIR)
Steve Muckle474e4d02019-06-19 12:56:48 -0700266 mkdir -p $$(PRIVATE_MODULE_DIR)
Steve Muckle810a0ba2019-11-13 13:29:02 -0800267 $(if $(6),\
Colin Crossc27d7952020-07-11 22:33:30 -0700268 unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800269 mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
Steve Muckle2335d762020-05-28 18:39:38 -0700270 cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
Steve Muckle810a0ba2019-11-13 13:29:02 -0800271 find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
272 )
273 $(if $(1),\
274 cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
275 for MODULE in $$(PRIVATE_LOAD_MODULES); do \
276 basename $$$$MODULE >> $$(PRIVATE_LOAD_FILE); \
277 done; \
278 )
Colin Cross4f60e362019-06-05 11:53:43 -0700279 $(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
280 # Turn paths in modules.dep into absolute paths
Steve Muckle474e4d02019-06-19 12:56:48 -0700281 sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
282 touch $$(PRIVATE_LOAD_FILE)
Colin Cross4f60e362019-06-05 11:53:43 -0700283endef
284
Steve Muckle474e4d02019-06-19 12:56:48 -0700285# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700286# $(2): modules list
287# $(3): module load list
288# $(4): module load list filename
289# $(5): output dir
Steve Muckle474e4d02019-06-19 12:56:48 -0700290define module-load-list-copy-paths
Mark Salyzyn4e209652020-05-15 09:10:29 -0700291 $(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
292 $(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
Steve Muckle474e4d02019-06-19 12:56:48 -0700293endef
294
295# $(1): staging dir
Mark Salyzyn4e209652020-05-15 09:10:29 -0700296# $(2): modules list
297# $(3): module load list
298# $(4): module load list filename
Steve Muckle474e4d02019-06-19 12:56:48 -0700299define build-image-module-load-list
Mark Salyzyn4e209652020-05-15 09:10:29 -0700300$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
301$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
302 @echo load-list $$(@)
303 @echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
Steve Muckle474e4d02019-06-19 12:56:48 -0700304endef
305
Steve Muckle2335d762020-05-28 18:39:38 -0700306# $(1): image name
307# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
308# $(3): mount point
309# $(4): module load filename
310# $(5): stripped staging directory
311# $(6): kernel module directory name (top is an out of band value for no directory)
312define build-image-kernel-modules-dir
313$(if $(filter top,$(6)),\
314 $(eval _kver :=)$(eval _sep :=),\
315 $(eval _kver := $(6))$(eval _sep :=_))\
316$(if $(5),\
317 $(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
318 $(eval _stripped_staging_dir :=))\
319$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
320 $(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
321 $(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
322 $(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))))
323endef
324
325# $(1): kernel module directory name (top is an out of band value for no directory)
326define build-recovery-as-boot-load
327$(if $(filter top,$(1)),\
328 $(eval _kver :=)$(eval _sep :=),\
329 $(eval _kver := $(1))$(eval _sep :=_))\
330 $(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
331 $(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))))
332endef
333
334# $(1): kernel module directory name (top is an out of band value for no directory)
335define build-vendor-ramdisk-recovery-load
336$(if $(filter top,$(1)),\
337 $(eval _kver :=)$(eval _sep :=),\
338 $(eval _kver := $(1))$(eval _sep :=_))\
339 $(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
340 $(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))))
341endef
342
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700343# $(1): kernel module directory name (top is an out of band value for no directory)
344define build-vendor-charger-load
345$(if $(filter top,$(1)),\
346 $(eval _kver :=)$(eval _sep :=),\
347 $(eval _kver := $(1))$(eval _sep :=_))\
348 $(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
349 $(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))))
350endef
351
Steve Mucklee1b10862019-07-10 10:49:37 -0700352ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
353 # If there is no vendor boot partition, store vendor ramdisk kernel modules in the
354 # boot ramdisk.
Steve Muckle69280d22019-07-11 12:23:38 -0700355 BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
Steve Muckle69280d22019-07-11 12:23:38 -0700356 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
357endif
Steve Muckle474e4d02019-06-19 12:56:48 -0700358
Steve Muckle69280d22019-07-11 12:23:38 -0700359ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
360 BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700361endif
362
Steve Mucklee1b10862019-07-10 10:49:37 -0700363ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
Steve Muckle474e4d02019-06-19 12:56:48 -0700364 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
Steve Muckle69280d22019-07-11 12:23:38 -0700365 BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
Steve Muckle474e4d02019-06-19 12:56:48 -0700366 endif
367endif
368
J. Avilaa2ceec62020-05-12 23:40:02 +0000369ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
370 VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
371else
372 VENDOR_STRIPPED_MODULE_STAGING_DIR :=
373endif
Colin Cross4f60e362019-06-05 11:53:43 -0700374
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700375ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
376 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
377else
378 VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
379endif
380
Steve Muckle2335d762020-05-28 18:39:38 -0700381BOARD_KERNEL_MODULE_DIRS += top
382$(foreach dir,$(BOARD_KERNEL_MODULE_DIRS), \
383 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,,$(dir))) \
Pierre Couillaudd99da8f2020-06-02 13:13:32 -0700384 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(TARGET_VENDOR_RAMDISK_OUT),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700385 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(dir))) \
386 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(TARGET_OUT_VENDOR),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(dir))) \
Mark Salyzyn46a9c022020-06-25 04:35:16 -0700387 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(dir))) \
Steve Muckle2335d762020-05-28 18:39:38 -0700388 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(TARGET_OUT_ODM),odm,modules.load,,$(dir))) \
389 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
390 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(dir))),\
391 $(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 -0700392
393# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800394# Cert-to-package mapping. Used by the post-build signing tools.
Ying Wangd9a88d52012-10-26 09:21:28 -0700395# Use a macro to add newline to each echo command
Jiyong Park7b96c592020-05-01 10:29:09 +0900396# $1 stem name of the package
Bill Peckham19c3feb2020-03-20 18:31:43 -0700397# $2 certificate
398# $3 private key
399# $4 compressed
400# $5 partition tag
401# $6 output file
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100402define _apkcerts_write_line
Bill Peckham19c3feb2020-03-20 18:31:43 -0700403$(hide) echo -n 'name="$(1).apk" certificate="$2" private_key="$3"' >> $6
404$(if $(4), $(hide) echo -n ' compressed="$4"' >> $6)
405$(if $(5), $(hide) echo -n ' partition="$5"' >> $6)
406$(hide) echo '' >> $6
Ying Wangd9a88d52012-10-26 09:21:28 -0700407
408endef
409
Jaewoong Jung704b4542020-06-29 19:37:53 -0700410# -----------------------------------------------------------------
411# Merge an individual apkcerts output into the final apkcerts.txt output.
412# Use a macro to make it compatible with _apkcerts_write_line
413# $1 apkcerts file to be merged
414# $2 output file
415define _apkcerts_merge
416$(hide) cat $1 >> $2
417
418endef
419
The Android Open Source Project88b60792009-03-03 19:28:42 -0800420name := $(TARGET_PRODUCT)
421ifeq ($(TARGET_BUILD_TYPE),debug)
422 name := $(name)_debug
423endif
424name := $(name)-apkcerts-$(FILE_NAME_TAG)
425intermediates := \
426 $(call intermediates-dir-for,PACKAGING,apkcerts)
427APKCERTS_FILE := $(intermediates)/$(name).txt
Jaewoong Jung704b4542020-06-29 19:37:53 -0700428all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
429$(APKCERTS_FILE): $(all_apkcerts_files)
Ying Wang15e487a2011-02-15 10:56:18 -0800430# We don't need to really build all the modules.
431# TODO: rebuild APKCERTS_FILE if any app change its cert.
Ying Wangefb21682010-07-23 16:42:13 -0700432$(APKCERTS_FILE):
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433 @echo APK certs list: $@
434 @mkdir -p $(dir $@)
435 @rm -f $@
Chris Grossfabf50a2019-05-02 12:42:09 -0700436 $(foreach p,$(sort $(PACKAGES)),\
Jaewoong Jung704b4542020-06-29 19:37:53 -0700437 $(if $(PACKAGES.$(p).APKCERTS_FILE),\
438 $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
439 $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
440 $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
441 $(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 -0700442 # In case value of PACKAGES is empty.
Ying Wangf272cd62011-09-26 12:05:06 -0700443 $(hide) touch $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800444
445.PHONY: apkcerts-list
446apkcerts-list: $(APKCERTS_FILE)
447
Ying Wang15e487a2011-02-15 10:56:18 -0800448ifneq (,$(TARGET_BUILD_APPS))
449 $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900450 $(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
Ying Wang15e487a2011-02-15 10:56:18 -0800451endif
Ying Wangefb21682010-07-23 16:42:13 -0700452
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +0900453
The Android Open Source Project88b60792009-03-03 19:28:42 -0800454# -----------------------------------------------------------------
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700455# build system stats
456BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
457$(BUILD_SYSTEM_STATS):
458 @rm -f $@
459 @$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
460 @$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
461$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
Doug Zongker8678df42009-06-15 14:30:14 -0700462
Dan Willemsen3bf15e72016-07-25 16:03:53 -0700463# -----------------------------------------------------------------
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800464# build /product/etc/security/avb/system_other.avbpubkey if needed
465ifdef BUILDING_SYSTEM_OTHER_IMAGE
Bowgo Tsai8802b712019-03-21 14:24:31 +0800466ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800467INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
468ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
Bowgo Tsai8802b712019-03-21 14:24:31 +0800469endif # BOARD_AVB_ENABLE
Bowgo Tsaie4544b12019-02-27 10:15:51 +0800470endif # BUILDING_SYSTEM_OTHER_IMAGE
471
472# -----------------------------------------------------------------
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700473# Modules ready to be converted to Soong, ordered by how many
474# modules depend on them.
475SOONG_CONV := $(sort $(SOONG_CONV))
476SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
477$(SOONG_CONV_DATA):
478 @rm -f $@
Colin Cross3277ba32017-12-06 14:37:06 -0800479 @$(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)))" >>$@;)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700480
Colin Crossfdea8932017-12-06 14:38:40 -0800481SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700482SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
483$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
484 @rm -f $@
485 $(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
486$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
487
488# -----------------------------------------------------------------
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -0800489# Modules use -Wno-error, or added default -Wall -Werror
490WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
491$(WALL_WERROR):
492 @rm -f $@
493 echo "# Modules using -Wno-error" >> $@
494 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 -0800495 echo "# Modules added default -Wall" >> $@
496 for m in $(sort $(SOONG_MODULES_ADDED_WALL) $(MODULES_ADDED_WALL)); do echo $$m >> $@; done
497
498$(call dist-for-goals,droidcore,$(WALL_WERROR))
499
500# -----------------------------------------------------------------
Jesse Paid0046922019-09-13 17:02:32 -0700501# C/C++ flag information for modules
502$(call dist-for-goals,droidcore,$(SOONG_MODULES_CFLAG_ARTIFACTS))
503
504# -----------------------------------------------------------------
Pirama Arumuga Nainarae959562018-01-29 09:22:24 -0800505# Modules missing profile files
506PGO_PROFILE_MISSING := $(PRODUCT_OUT)/pgo_profile_file_missing.txt
507$(PGO_PROFILE_MISSING):
508 @rm -f $@
509 echo "# Modules missing PGO profile files" >> $@
510 for m in $(SOONG_MODULES_MISSING_PGO_PROFILE_FILE); do echo $$m >> $@; done
511
512$(call dist-for-goals,droidcore,$(PGO_PROFILE_MISSING))
513
514# -----------------------------------------------------------------
Ying Wang3c21fe52011-10-04 10:50:08 -0700515# The dev key is used to sign this package, and as the key required
Doug Zongker8678df42009-06-15 14:30:14 -0700516# for future OTA packages installed by this system. Actual product
517# deliverables will be re-signed by hand. We expect this file to
518# exist with the suffixes ".x509.pem" and ".pk8".
Colin Cross21122f92018-09-14 21:51:11 -0700519DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
Doug Zongker8678df42009-06-15 14:30:14 -0700520
521
Jeff Browne33ba4c2011-07-11 22:11:46 -0700522# Rules that need to be present for the all targets, even
The Android Open Source Project88b60792009-03-03 19:28:42 -0800523# if they don't do anything.
524.PHONY: systemimage
525systemimage:
526
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800527# -----------------------------------------------------------------
528
529.PHONY: event-log-tags
530
Joe Onoratob7510532010-07-14 10:22:54 -0700531# Produce an event logs tag file for everything we know about, in order
532# to properly allocate numbers. Then produce a file that's filtered
533# for what's going to be installed.
534
535all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
536
Colin Crossdc8f8e42012-04-12 13:25:54 -0700537event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
538
Joe Onoratob7510532010-07-14 10:22:54 -0700539# Include tags from all packages that we know about
540all_event_log_tags_src := \
541 $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
542
Colin Crossdc8f8e42012-04-12 13:25:54 -0700543# PDK builds will already have a full list of tags that needs to get merged
544# in with the ones from source
545pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
546
547$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800548$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Joe Onoratob7510532010-07-14 10:22:54 -0700549 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900550 $(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
Joe Onoratob7510532010-07-14 10:22:54 -0700551
Doug Zongkera34fa952011-02-23 12:17:29 -0800552# Include tags from all packages included in this product, plus all
553# tags that are part of the system (ie, not in a vendor/ or device/
554# directory).
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800555event_log_tags_src := \
556 $(sort $(foreach m,\
Yo Chiang5e85bfe2020-05-13 20:19:05 +0800557 $(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800558 $(call module-names-for-tag-list,user), \
Doug Zongkera34fa952011-02-23 12:17:29 -0800559 $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
560 $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800561
Colin Crossdc8f8e42012-04-12 13:25:54 -0700562$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
Joe Onoratob7510532010-07-14 10:22:54 -0700563$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
Colin Crossfdea8932017-12-06 14:38:40 -0800564$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/make/tools/event_log_tags.py
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800565 $(hide) mkdir -p $(dir $@)
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900566 $(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
Doug Zongker7e2f13b2010-02-16 16:01:43 -0800567
568event-log-tags: $(event_log_tags_file)
569
570ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
571
Joe Onoratob7510532010-07-14 10:22:54 -0700572
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573# #################################################################
574# Targets for boot/OS images
575# #################################################################
Ying Wangc6349742014-01-13 16:14:20 -0800576ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
577 INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
578 ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
579 INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
580 else
581 INSTALLED_2NDBOOTLOADER_TARGET :=
582 endif
583else
584 INSTALLED_BOOTLOADER_MODULE :=
585 INSTALLED_2NDBOOTLOADER_TARGET :=
586endif # TARGET_NO_BOOTLOADER
587ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -0700588 ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
589 INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
590 $(PRODUCT_OUT)/$(k))
591 else
592 INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
593 endif
Ying Wangc6349742014-01-13 16:14:20 -0800594else
595 INSTALLED_KERNEL_TARGET :=
596endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800597
598# -----------------------------------------------------------------
Tom Cherryd14b8952018-08-09 14:26:00 -0700599# the root dir
600INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800601 $(ALL_GENERATED_SOURCES) \
602 $(ALL_DEFAULT_INSTALLED_MODULES))
603
Luis Hector Chavezff489932018-07-03 15:41:40 -0700604INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
605INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
606$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700607$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Luis Hector Chavezff489932018-07-03 15:41:40 -0700608 @echo Installed file list: $@
609 @mkdir -p $(dir $@)
610 @rm -f $@
611 $(hide) $(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700612 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Luis Hector Chavezff489932018-07-03 15:41:40 -0700613
614$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_ROOT))
615
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800616#------------------------------------------------------------------
617# dtb
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700618ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800619INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700620ifdef BOARD_PREBUILT_DTBIMAGE_DIR
Hridya Valsarajuc63a7442019-02-07 11:38:18 -0800621$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800622 cat $^ > $@
623endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -0700624endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -0800625
Tom Cherryd14b8952018-08-09 14:26:00 -0700626# -----------------------------------------------------------------
627# the ramdisk
Dan Willemsen67495202019-01-16 12:42:05 -0800628ifdef BUILDING_RAMDISK_IMAGE
Tom Cherryd14b8952018-08-09 14:26:00 -0700629INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
630 $(ALL_GENERATED_SOURCES) \
631 $(ALL_DEFAULT_INSTALLED_MODULES))
632
633INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
634INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
635$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700636$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tom Cherryd14b8952018-08-09 14:26:00 -0700637 @echo Installed file list: $@
SzuWei Lin29770fa2019-03-28 11:46:48 +0800638 @mkdir -p $(TARGET_RAMDISK_OUT)
Tom Cherryd14b8952018-08-09 14:26:00 -0700639 @mkdir -p $(dir $@)
640 @rm -f $@
641 $(hide) $(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -0700642 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tom Cherryd14b8952018-08-09 14:26:00 -0700643
644$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE_RAMDISK))
Joe Onorato64d85d02009-04-09 19:31:12 -0700645BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
646
J. Avila3f6560e2020-05-11 20:20:03 +0000647ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
648# -l enables the legacy format used by the Linux kernel
649COMPRESSION_COMMAND_DEPS := $(LZ4)
650COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
651RAMDISK_EXT := .lz4
652else
653COMPRESSION_COMMAND_DEPS := $(MINIGZIP)
654COMPRESSION_COMMAND := $(MINIGZIP)
655RAMDISK_EXT := .gz
656endif
657
Joe Onorato64d85d02009-04-09 19:31:12 -0700658# We just build this directly to the install location.
659INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +0000660$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800661 $(call pretty,"Target ram disk: $@")
J. Avila3f6560e2020-05-11 20:20:03 +0000662 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -0800663
Ying Wangad7fd292013-08-08 16:34:29 -0700664.PHONY: ramdisk-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +0000665ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Ying Wangad7fd292013-08-08 16:34:29 -0700666 @echo "make $@: ignoring dependencies"
J. Avila3f6560e2020-05-11 20:20:03 +0000667 $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800668
Dan Willemsen67495202019-01-16 12:42:05 -0800669endif # BUILDING_RAMDISK_IMAGE
670
The Android Open Source Project88b60792009-03-03 19:28:42 -0800671# -----------------------------------------------------------------
672# the boot image, which is a collection of other images.
Chris Grossa784ef12019-04-22 11:09:57 -0700673
674# This is defined here since we may be building recovery as boot
675# below and only want to define this once
Steve Muckleb3dda772020-03-11 16:03:07 -0700676ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
677 BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
678else
679 BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
680endif
681
Steve Muckle903a1ca2020-05-07 17:32:10 -0700682ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
683 BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
684endif
685
686# $1: boot image file name
687# $2: boot image variant (boot, boot-debug)
688define get-bootimage-partition-size
689 $(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
690endef
Chris Grossa784ef12019-04-22 11:09:57 -0700691
692ifneq ($(strip $(TARGET_NO_KERNEL)),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800693INTERNAL_BOOTIMAGE_ARGS := \
694 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Rom Lemarchandf9c92662015-04-08 15:11:47 -0700695 --kernel $(INSTALLED_KERNEL_TARGET)
696
697ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
698INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
699endif
700
Steve Mucklee1b10862019-07-10 10:49:37 -0700701ifndef BUILDING_VENDOR_BOOT_IMAGE
702ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
703 INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
704endif
705endif
706
The Android Open Source Project88b60792009-03-03 19:28:42 -0800707INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
708
Anton Hansson8dab0a62019-03-28 15:45:40 +0000709ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700710ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000711VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700712 | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'`
713endif
714endif
715
Anton Hansson72e36f02019-02-26 17:36:30 +0000716INTERNAL_KERNEL_CMDLINE := $(strip $(INTERNAL_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
Steve Mucklee1b10862019-07-10 10:49:37 -0700717
718ifndef BUILDING_VENDOR_BOOT_IMAGE
719ifdef BOARD_KERNEL_BASE
720 INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
721endif
722ifdef BOARD_KERNEL_PAGESIZE
723 INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
724endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -0700725ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -0700726 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
727endif
728else
729# building vendor boot image, dtb/base/pagesize go there
730ifdef GENERIC_KERNEL_CMDLINE
731 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
732endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700733endif
Badhri Jagan Sridharanf380da32016-05-27 09:49:49 -0700734
Sami Tolvanen3303d902016-03-15 16:49:30 +0000735INTERNAL_MKBOOTIMG_VERSION_ARGS := \
736 --os_version $(PLATFORM_VERSION) \
737 --os_patch_level $(PLATFORM_SECURITY_PATCH)
738
Chris Grossa784ef12019-04-22 11:09:57 -0700739# Define these only if we are building boot
740ifdef BUILDING_BOOT_IMAGE
741INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
742
The Android Open Source Project88b60792009-03-03 19:28:42 -0800743ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
JP Abgrall7bb75e42015-02-11 15:04:59 -0800744$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
David Zeuthen0eb10972016-09-28 17:55:27 -0400745
746else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
747
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800748$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400749 $(call pretty,"Target boot image: $@")
750 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800751 $(hide) $(call assert-max-image-size,$@,$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400752 $(hide) $(AVBTOOL) add_hash_footer \
753 --image $@ \
754 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800755 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400756 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
757
758.PHONY: bootimage-nodeps
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800759bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
David Zeuthen0eb10972016-09-28 17:55:27 -0400760 @echo "make $@: ignoring dependencies"
761 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800762 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(call get-hash-image-max-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE)))
David Zeuthen0eb10972016-09-28 17:55:27 -0400763 $(hide) $(AVBTOOL) add_hash_footer \
Bowgo Tsai03b9c8e2017-11-17 15:22:37 +0800764 --image $(INSTALLED_BOOTIMAGE_TARGET) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400765 --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
Bowgo Tsai3e599ea2017-05-26 18:30:04 +0800766 --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
David Zeuthen0eb10972016-09-28 17:55:27 -0400767 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
768
Anton Hansson8dab0a62019-03-28 15:45:40 +0000769else ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
Geremy Condra740b6632014-07-08 20:07:41 -0700770
771$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
772 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000773 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
Anton Hansson8dab0a62019-03-28 15:45:40 +0000774 $(BOOT_SIGNER) /boot $@ $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
Geremy Condra740b6632014-07-08 20:07:41 -0700775 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
776
777.PHONY: bootimage-nodeps
778bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER)
779 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000780 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
Anton Hansson8dab0a62019-03-28 15:45:40 +0000781 $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(INSTALLED_BOOTIMAGE_TARGET)
Geremy Condra740b6632014-07-08 20:07:41 -0700782 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
783
Anton Hansson8dab0a62019-03-28 15:45:40 +0000784else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true
David Riley17be3d32015-03-03 08:54:11 -0800785
Tao Bao4b577412017-02-22 22:54:39 -0800786$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800787 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000788 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +0000789 $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $@.keyblock $@
David Riley17be3d32015-03-03 08:54:11 -0800790 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
791
792.PHONY: bootimage-nodeps
Tao Bao4b577412017-02-22 22:54:39 -0800793bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
David Riley17be3d32015-03-03 08:54:11 -0800794 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000795 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned
Anton Hansson8dab0a62019-03-28 15:45:40 +0000796 $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET)
David Riley17be3d32015-03-03 08:54:11 -0800797 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
798
799else # PRODUCT_SUPPORTS_VBOOT != true
The Android Open Source Project88b60792009-03-03 19:28:42 -0800800
801$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
802 $(call pretty,"Target boot image: $@")
Sami Tolvanen3303d902016-03-15 16:49:30 +0000803 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700804 $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700805
806.PHONY: bootimage-nodeps
807bootimage-nodeps: $(MKBOOTIMG)
808 @echo "make $@: ignoring dependencies"
Sami Tolvanen3303d902016-03-15 16:49:30 +0000809 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
JP Abgrall0ed7cec2014-06-16 14:19:36 -0700810 $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
Ying Wangad7fd292013-08-08 16:34:29 -0700811
The Android Open Source Project88b60792009-03-03 19:28:42 -0800812endif # TARGET_BOOTIMAGE_USE_EXT2
Chris Grossa784ef12019-04-22 11:09:57 -0700813endif # BUILDING_BOOT_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -0800814
Tao Baob1a2e352018-08-14 16:17:12 -0700815else # TARGET_NO_KERNEL == "true"
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700816ifdef BOARD_PREBUILT_BOOTIMAGE
817ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
818# Remove when b/63676296 is resolved.
819$(error Prebuilt bootimage is only supported for AB targets)
820endif
Kiyoung Kim62e22312019-06-20 14:27:45 +0900821INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
Michael Schwartz0dc6f212017-07-18 10:05:13 -0700822$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTIMAGE),$(INSTALLED_BOOTIMAGE_TARGET)))
Tao Baob1a2e352018-08-14 16:17:12 -0700823else # BOARD_PREBUILT_BOOTIMAGE not defined
Tao Baob1a2e352018-08-14 16:17:12 -0700824INSTALLED_BOOTIMAGE_TARGET :=
825endif # BOARD_PREBUILT_BOOTIMAGE
826endif # TARGET_NO_KERNEL
The Android Open Source Project88b60792009-03-03 19:28:42 -0800827
828# -----------------------------------------------------------------
Steve Mucklee1b10862019-07-10 10:49:37 -0700829# vendor boot image
830ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
831
832ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
833 $(error vboot 1.0 does not support vendor_boot partition)
834endif
835
836INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
837 $(ALL_GENERATED_SOURCES) \
838 $(ALL_DEFAULT_INSTALLED_MODULES))
839
Steve Muckle414dbe12020-06-18 21:38:35 -0700840INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor-boot)/vendor-ramdisk.cpio$(RAMDISK_EXT)
J. Avila3f6560e2020-05-11 20:20:03 +0000841$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
842 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700843
844ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
845 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
846endif
847ifdef BOARD_KERNEL_BASE
848 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
849endif
850ifdef BOARD_KERNEL_PAGESIZE
851 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
852endif
853ifdef INTERNAL_KERNEL_CMDLINE
854 INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
855endif
856
857INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
858$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
859ifeq ($(BOARD_AVB_ENABLE),true)
860$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
861 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800862 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700863 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
864 $(AVBTOOL) add_hash_footer \
865 --image $@ \
866 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
867 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
868 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
869else
870$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
871 $(call pretty,"Target vendor_boot image: $@")
cfig125efba2020-05-11 15:00:35 +0800872 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) --vendor_boot $@
Steve Mucklee1b10862019-07-10 10:49:37 -0700873 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
874endif
875endif # BUILDING_VENDOR_BOOT_IMAGE
876
877# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -0800878# NOTICE files
879#
Steve Blockd14d3b42012-03-01 11:34:41 +0000880# We are required to publish the licenses for all code under BSD, GPL and
881# Apache licenses (and possibly other more exotic ones as well). We err on the
882# side of caution, so the licenses for other third-party code are included here
883# too.
884#
The Android Open Source Project88b60792009-03-03 19:28:42 -0800885# This needs to be before the systemimage rules, because it adds to
886# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
887# go into the systemimage.
888
Steve Block495e5852012-02-29 19:18:08 +0000889.PHONY: notice_files
890
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900891# Create the rule to combine the files into text and html/xml forms
Yifan Hong3d3f0302020-05-11 18:35:11 -0700892# $(1) - xml_excluded_system_product_odm_vendor_dlkm|
893# xml_excluded_vendor_product_odm_vendor_dlkm|
894# xml_product|xml_odm|xml_system_ext|xml_system|xml_vendor_dlkm|html
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900895# $(2) - Plain text output file
896# $(3) - HTML/XML output file
897# $(4) - File title
Jaewoong Junge6f57e02019-06-16 21:48:42 -0700898# $(5) - Directory to use. Notice files are all $(5)/src. Other
The Android Open Source Project88b60792009-03-03 19:28:42 -0800899# directories in there will be used for scratch
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900900# $(6) - Dependencies for the output files
Bob Badour4b25c902020-01-28 13:23:39 -0800901# $(7) - Directories to exclude
The Android Open Source Project88b60792009-03-03 19:28:42 -0800902#
903# The algorithm here is that we go collect a hash for each of the notice
904# files and write the names of the files that match that hash. Then
905# to generate the real files, we go print out all of the files and their
906# hashes.
907#
908# These rules are fairly complex, so they depend on this makefile so if
909# it changes, they'll run again.
910#
911# TODO: We could clean this up so that we just record the locations of the
912# original notice files instead of making rules to copy them somwehere.
913# Then we could traverse that without quite as much bash drama.
914define combine-notice-files
Dan Willemsenf4cbafa2020-04-28 15:57:32 -0700915$(2): PRIVATE_MESSAGE := $(4)
916$(2): PRIVATE_DIR := $(5)
917$(2): .KATI_IMPLICIT_OUTPUTS := $(3)
918$(2): $(6) $(BUILD_SYSTEM)/Makefile build/make/tools/generate-notice-files.py
Bob Badour4b25c902020-01-28 13:23:39 -0800919 build/make/tools/generate-notice-files.py --text-output $(2) $(foreach xdir, $(7), -e $(xdir) )\
Yifan Hong3d3f0302020-05-11 18:35:11 -0700920 $(if $(filter $(1),xml_excluded_vendor_product_odm_vendor_dlkm),-e vendor -e product -e system_ext -e odm -e vendor_dlkm --xml-output, \
921 $(if $(filter $(1),xml_excluded_system_product_odm_vendor_dlkm),-e system -e product -e system_ext -e odm -e vendor_dlkm --xml-output, \
Anton Hansson6d814982018-11-26 18:12:05 +0000922 $(if $(filter $(1),xml_product),-i product --xml-output, \
Justin Yun6151e3f2019-06-25 15:58:13 +0900923 $(if $(filter $(1),xml_system_ext),-i system_ext --xml-output, \
Chris Grossaad39b32019-06-13 09:43:26 -0700924 $(if $(filter $(1),xml_system),-i system --xml-output, \
925 $(if $(filter $(1),xml_odm),-i odm --xml-output, \
Yifan Hong3d3f0302020-05-11 18:35:11 -0700926 $(if $(filter $(1),xml_vendor_dlkm),-i vendor_dlkm --xml-output, \
927 --html-output))))))) $(3) \
Anton Hansson6d814982018-11-26 18:12:05 +0000928 -t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900929notice_files: $(2) $(3)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800930endef
931
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000932# Notice file logic isn't relevant for TARGET_BUILD_APPS
933ifndef TARGET_BUILD_APPS
934
The Android Open Source Project88b60792009-03-03 19:28:42 -0800935# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
936# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
937# the src subdirectory.
Steve Block495e5852012-02-29 19:18:08 +0000938target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
Steve Block495e5852012-02-29 19:18:08 +0000939tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -0800940tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000941kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
942winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
943pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800944
Bob Badour4b25c902020-01-28 13:23:39 -0800945# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
946# reasons--not to be flashed onto any device. Targets under these directories
947# need no associated notice file on the device UI.
948exclude_target_dirs := apex
949
Steven Morelandae69e572017-12-15 14:49:55 -0800950# TODO(b/69865032): Make PRODUCT_NOTICE_SPLIT the default behavior.
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000951ifneq ($(PRODUCT_NOTICE_SPLIT),true)
952target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
953target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
954installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
955$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +0000956 $(target_notice_file_txt), \
957 $(target_notice_file_html), \
958 "Notices for files contained in the filesystem images in this directory:", \
959 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -0800960 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files), \
961 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +0000962$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
963 $(hide) $(MINIGZIP) -9 < $< > $@
964$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
965 $(copy-file-to-target)
966else
967target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
968target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900969installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
970
971target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
972target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
973target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
974installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
Dario Freniadc972d2018-07-09 18:38:38 +0100975
976target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
977target_product_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml
978target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
979installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
Dario Frenicbca1132018-08-28 18:04:03 +0100980
Justin Yun6151e3f2019-06-25 15:58:13 +0900981target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
982target_system_ext_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml
983target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
984installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
Jaekyun Seok3b7560b2017-04-19 15:26:47 +0900985
Chris Gross15d96552019-07-16 14:38:43 -0700986target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
987target_odm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml
988target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
989installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
990
Yifan Hong3d3f0302020-05-11 18:35:11 -0700991target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
992target_vendor_dlkm_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml
993target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
994installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
995
Anton Hansson6ad6f6c2018-11-12 23:33:47 +0000996# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
997# being built. A notice xml file must depend on all modules that could potentially
998# install a license file relevant to it.
999license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)
Bob Badour4b25c902020-01-28 13:23:39 -08001000# Only files copied to a system image need system image notices.
1001license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001002# Phonys/fakes don't have notice files (though their deps might)
1003license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
Jooyung Han4416b002019-05-29 18:28:22 +09001004# testcases are not relevant to the system image.
1005license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001006# filesystem images: system, vendor, product, system_ext, odm, and vendor_dlkm
Chris Grossaad39b32019-06-13 09:43:26 -07001007license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
Anton Hansson6ad6f6c2018-11-12 23:33:47 +00001008license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
1009license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
Justin Yun6151e3f2019-06-25 15:58:13 +09001010license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
Chris Gross15d96552019-07-16 14:38:43 -07001011license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001012license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
Chris Grossaad39b32019-06-13 09:43:26 -07001013license_modules_agg := $(license_modules_system) \
1014 $(license_modules_vendor) \
Chris Gross15d96552019-07-16 14:38:43 -07001015 $(license_modules_product) \
1016 $(license_modules_system_ext) \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001017 $(license_modules_odm) \
1018 $(license_modules_vendor_dlkm)
Bob Badour4b25c902020-01-28 13:23:39 -08001019# targets used for debug symbols only and do not get copied to the device
1020license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
1021
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001022license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
Bob Badour4b25c902020-01-28 13:23:39 -08001023license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
1024
1025# Identify the other targets we expect to have notices for:
1026# targets copied to the device but are not readable by the UI (e.g. must boot
1027# into a different partition to read or don't have an associated /etc
1028# directory) must have their notices built somewhere readable.
1029license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
1030license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
1031license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
1032license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
1033license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
1034license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
1035license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor-ramdisk/%,$(license_modules_rest))
1036license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
1037license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
1038license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
1039license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
1040license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
1041license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
1042
1043# after removing targets in system images, targets reported in system images, and
1044# targets used for debug symbols that do not need notices, nothing must remain.
1045license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
1046$(call maybe-print-list-and-error, $(license_modules_rest), \
1047 "Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
The Android Open Source Project88b60792009-03-03 19:28:42 -08001048
Chris Grossaad39b32019-06-13 09:43:26 -07001049# If we are building in a configuration that includes a prebuilt vendor.img, we can't
1050# update its notice file, so include those notices in the system partition instead
1051ifdef BOARD_PREBUILT_VENDORIMAGE
Bob Badour4b25c902020-01-28 13:23:39 -08001052license_modules_system += $(license_modules_rehomed)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001053system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm
1054system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm in this directory:"
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001055else
Bob Badour4b25c902020-01-28 13:23:39 -08001056license_modules_vendor += $(license_modules_rehomed)
Chris Grosse5d4a9e2019-07-30 15:46:35 -07001057system_xml_directories := xml_system
1058system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
Chris Grossaad39b32019-06-13 09:43:26 -07001059endif
1060
1061$(eval $(call combine-notice-files, $(system_xml_directories), \
Anton Hansson6d814982018-11-26 18:12:05 +00001062 $(target_notice_file_txt), \
1063 $(target_notice_file_xml), \
Chris Grossaad39b32019-06-13 09:43:26 -07001064 $(system_notice_file_message), \
Anton Hansson6d814982018-11-26 18:12:05 +00001065 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001066 $(license_modules_system), \
1067 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001068$(eval $(call combine-notice-files, xml_excluded_system_product_odm_vendor_dlkm, \
Anton Hansson6d814982018-11-26 18:12:05 +00001069 $(target_vendor_notice_file_txt), \
1070 $(target_vendor_notice_file_xml), \
Yifan Hong3d3f0302020-05-11 18:35:11 -07001071 "Notices for files contained in all filesystem images except system/system_ext/product/odm/vendor_dlkm in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001072 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001073 $(license_modules_vendor), \
1074 $(exclude_target_dirs)))
Dario Freniadc972d2018-07-09 18:38:38 +01001075$(eval $(call combine-notice-files, xml_product, \
Anton Hansson6d814982018-11-26 18:12:05 +00001076 $(target_product_notice_file_txt), \
1077 $(target_product_notice_file_xml), \
1078 "Notices for files contained in the product filesystem image in this directory:", \
1079 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001080 $(license_modules_product), \
1081 $(exclude_target_dirs)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001082$(eval $(call combine-notice-files, xml_system_ext, \
1083 $(target_system_ext_notice_file_txt), \
1084 $(target_system_ext_notice_file_xml), \
1085 "Notices for files contained in the system_ext filesystem image in this directory:", \
Anton Hansson6d814982018-11-26 18:12:05 +00001086 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001087 $(license_modules_system_ext), \
1088 $(exclude_target_dirs)))
Chris Gross15d96552019-07-16 14:38:43 -07001089$(eval $(call combine-notice-files, xml_odm, \
1090 $(target_odm_notice_file_txt), \
1091 $(target_odm_notice_file_xml), \
1092 "Notices for files contained in the odm filesystem image in this directory:", \
1093 $(TARGET_OUT_NOTICE_FILES), \
Bob Badour4b25c902020-01-28 13:23:39 -08001094 $(license_modules_odm), \
1095 $(exclude_target_dirs)))
Yifan Hong3d3f0302020-05-11 18:35:11 -07001096$(eval $(call combine-notice-files, xml_vendor_dlkm, \
1097 $(target_vendor_dlkm_notice_file_txt), \
1098 $(target_vendor_dlkm_notice_file_xml), \
1099 "Notices for files contained in the vendor_dlkm filesystem image in this directory:", \
1100 $(TARGET_OUT_NOTICE_FILES), \
1101 $(license_modules_vendor_dlkm), \
1102 $(exclude_target_dirs)))
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001103
1104$(target_notice_file_xml_gz): $(target_notice_file_xml) | $(MINIGZIP)
1105 $(hide) $(MINIGZIP) -9 < $< > $@
1106$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
1107 $(hide) $(MINIGZIP) -9 < $< > $@
1108$(target_product_notice_file_xml_gz): $(target_product_notice_file_xml) | $(MINIGZIP)
1109 $(hide) $(MINIGZIP) -9 < $< > $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001110$(target_system_ext_notice_file_xml_gz): $(target_system_ext_notice_file_xml) | $(MINIGZIP)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001111 $(hide) $(MINIGZIP) -9 < $< > $@
Chris Gross15d96552019-07-16 14:38:43 -07001112$(target_odm_notice_file_xml_gz): $(target_odm_notice_file_xml) | $(MINIGZIP)
1113 $(hide) $(MINIGZIP) -9 < $< > $@
Yifan Hong3d3f0302020-05-11 18:35:11 -07001114$(target_vendor_dlkm_notice_file_xml_gz): $(target_vendor_dlkm_notice_file_xml) | $(MINIGZIP)
1115 $(hide) $(MINIGZIP) -9 < $< > $@
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001116$(installed_notice_html_or_xml_gz): $(target_notice_file_xml_gz)
1117 $(copy-file-to-target)
1118$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
1119 $(copy-file-to-target)
1120$(installed_product_notice_xml_gz): $(target_product_notice_file_xml_gz)
1121 $(copy-file-to-target)
Justin Yun6151e3f2019-06-25 15:58:13 +09001122$(installed_system_ext_notice_xml_gz): $(target_system_ext_notice_file_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001123 $(copy-file-to-target)
Chris Gross15d96552019-07-16 14:38:43 -07001124$(installed_odm_notice_xml_gz): $(target_odm_notice_file_xml_gz)
1125 $(copy-file-to-target)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001126$(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
1127 $(copy-file-to-target)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001128
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001129ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
1130ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
1131ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
1132ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
1133ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
Yifan Hong3d3f0302020-05-11 18:35:11 -07001134ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
Anton Hanssonbfbaa982018-11-12 23:29:13 +00001135endif # PRODUCT_NOTICE_SPLIT
1136
Dan Willemsen5c3fc2a2019-07-29 23:45:19 -07001137ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001138
Jaekyun Seok3b7560b2017-04-19 15:26:47 +09001139$(eval $(call combine-notice-files, html, \
Anton Hansson6d814982018-11-26 18:12:05 +00001140 $(tools_notice_file_txt), \
1141 $(tools_notice_file_html), \
1142 "Notices for files contained in the tools directory:", \
1143 $(HOST_OUT_NOTICE_FILES), \
1144 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bob Badour4b25c902020-01-28 13:23:39 -08001145 $(winpthreads_notice_file), \
1146 $(exclude_target_dirs)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001147
Ying Wang62c81f82013-08-22 20:02:03 -07001148endif # TARGET_BUILD_APPS
The Android Open Source Project88b60792009-03-03 19:28:42 -08001149
1150# The kernel isn't really a module, so to get its module file in there, we
1151# make the target NOTICE files depend on this particular file too, which will
1152# then be in the right directory for the find in combine-notice-files to work.
Dan Willemsen288bedf2019-05-28 15:36:47 -07001153$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001154
Dan Willemsen288bedf2019-05-28 15:36:47 -07001155$(eval $(call copy-one-file,$(BUILD_SYSTEM)/WINPTHREADS_COPYING,$(winpthreads_notice_file)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001156
Doug Zongker8678df42009-06-15 14:30:14 -07001157
The Android Open Source Project88b60792009-03-03 19:28:42 -08001158# #################################################################
1159# Targets for user images
1160# #################################################################
1161
Ying Wang933abf12010-06-16 14:31:34 -07001162INTERNAL_USERIMAGES_EXT_VARIANT :=
The Android Open Source Project88b60792009-03-03 19:28:42 -08001163ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001164INTERNAL_USERIMAGES_EXT_VARIANT := ext2
1165else
1166ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001167INTERNAL_USERIMAGES_EXT_VARIANT := ext3
1168else
1169ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
Colin Cross0a7b2c52010-05-07 02:23:59 -07001170INTERNAL_USERIMAGES_EXT_VARIANT := ext4
1171endif
1172endif
1173endif
1174
JP Abgrall6ea5bd62014-10-22 20:01:22 -07001175# These options tell the recovery updater/installer how to mount the partitions writebale.
1176# <fstype>=<fstype_opts>[|<fstype_opts>]...
1177# fstype_opts := <opt>[,<opt>]...
1178# opt := <name>[=<value>]
JP Abgrall775b1ab2014-10-23 16:27:03 -07001179# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
1180DEFAULT_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 -07001181
Ying Wang542903a2010-11-17 15:40:38 -08001182ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
1183 INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
1184endif
Todd Poynorb2a555e2015-12-15 18:00:14 -08001185ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED))
1186 INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s
1187endif
Alistair Delva91238cc2019-10-16 10:53:41 -07001188ifneq (true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED))
1189 INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG := -S
1190endif
Tao Baodba635a2019-06-24 10:39:54 -07001191
1192INTERNAL_USERIMAGES_DEPS := \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001193 $(BUILD_IMAGE) \
Tao Baodba635a2019-06-24 10:39:54 -07001194 $(MKE2FS_CONF) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07001195 $(MKEXTUSERIMG)
Tao Baodba635a2019-06-24 10:39:54 -07001196
1197ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
1198INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
Mohamad Ayyash68946952015-03-03 12:30:37 -08001199endif
1200
Yifan Hongcfb917a2020-05-07 14:58:20 -07001201ifneq ($(filter \
1202 $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
1203 $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
1204 $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
1205 $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
1206 $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
1207 $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
1208 ,squashfs),)
Tao Baodba635a2019-06-24 10:39:54 -07001209INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
1210endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08001211
Anton Hansson8dab0a62019-03-28 15:45:40 +00001212ifeq (true,$(PRODUCT_SUPPORTS_VERITY))
Tao Baob4ec6d72018-03-15 23:21:28 -07001213INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001214ifeq (true,$(PRODUCT_SUPPORTS_VERITY_FEC))
Sami Tolvanenf99b5312015-05-20 07:30:57 +01001215INTERNAL_USERIMAGES_DEPS += $(FEC)
1216endif
Geremy Condrafd6f7512013-06-16 17:26:08 -07001217endif
1218
Tao Baodba635a2019-06-24 10:39:54 -07001219ifeq ($(BOARD_AVB_ENABLE),true)
1220INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
1221endif
1222
1223# Get a colon-separated list of search paths.
1224INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
1225
Alex Klyubin092c9022017-03-13 13:28:34 -07001226SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
Ying Wangfdbd9cb2012-11-21 10:47:00 -08001227INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
1228
Yifan Hongc5c01242018-11-09 10:27:23 -08001229ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001230
Anton Hansson8dab0a62019-03-28 15:45:40 +00001231ifeq ($(PRODUCT_SUPPORTS_VERITY),true)
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001232 $(error vboot 1.0 doesn't support logical partition)
1233endif
1234
Yifan Hongc5c01242018-11-09 10:27:23 -08001235endif # PRODUCT_USE_DYNAMIC_PARTITIONS
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001236
Ying Wangbd93d422011-10-28 17:02:30 -07001237# $(1): the path of the output dictionary file
Yifan Hongcfb917a2020-05-07 14:58:20 -07001238# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm"
Yifan Hong760d3c02018-05-30 11:16:46 -07001239# $(3): additional "key=value" pairs to append to the dictionary file.
1240define generate-image-prop-dictionary
Yifan Hong760d3c02018-05-30 11:16:46 -07001241$(if $(filter $(2),system),\
1242 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
Bowgo Tsai867ab662019-01-29 13:30:18 +08001243 $(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001244 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1245 $(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1246 $(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1247 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
1248 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1249 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1250 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1251 $(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 +00001252 $(if $(PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
1253 $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001254 $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001255 $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001256 $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1)
1257)
1258$(if $(filter $(2),system_other),\
1259 $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001260)
Yifan Hong760d3c02018-05-30 11:16:46 -07001261$(if $(filter $(2),userdata),\
1262 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1263 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Rosenberg6cc2c812019-12-17 17:36:31 -08001264 $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
1265 $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001266 $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001267 $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001268)
Yifan Hong760d3c02018-05-30 11:16:46 -07001269$(if $(filter $(2),cache),\
1270 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1271 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001272 $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001273 $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001274)
1275$(if $(filter $(2),vendor),\
1276 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1277 $(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1278 $(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
1279 $(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
1280 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
1281 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1282 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1283 $(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1284 $(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 +00001285 $(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 -07001286 $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001287 $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001288 $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001289)
1290$(if $(filter $(2),product),\
1291 $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1292 $(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1293 $(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1294 $(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
1295 $(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
1296 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1297 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "product_squashfs_compressor_opt=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1298 $(if $(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "product_squashfs_block_size=$(BOARD_PRODUCTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1299 $(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 +00001300 $(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 -07001301 $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001302 $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001303 $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001304)
Justin Yun6151e3f2019-06-25 15:58:13 +09001305$(if $(filter $(2),system_ext),\
1306 $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1307 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_ext_extfs_inode_count=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1308 $(if $(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_ext_extfs_rsv_pct=$(BOARD_SYSTEM_EXTIMAGE_EXTFS_RSV_PCT)" >> $(1))
1309 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),$(hide) echo "system_ext_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE)" >> $(1))
1310 $(if $(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE),$(hide) echo "system_ext_journal_size=$(BOARD_SYSTEM_EXTIMAGE_JOURNAL_SIZE)" >> $(1))
1311 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_ext_squashfs_compressor=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1312 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_ext_squashfs_compressor_opt=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1313 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_ext_squashfs_block_size=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1314 $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1315 $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1316 $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001317 $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1)
Dario Freni5f681e12018-05-29 13:09:01 +01001318)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001319$(if $(filter $(2),odm),\
1320 $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1321 $(if $(BOARD_ODMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "odm_extfs_inode_count=$(BOARD_ODMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1322 $(if $(BOARD_ODMIMAGE_EXTFS_RSV_PCT),$(hide) echo "odm_extfs_rsv_pct=$(BOARD_ODMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1323 $(if $(BOARD_ODMIMAGE_PARTITION_SIZE),$(hide) echo "odm_size=$(BOARD_ODMIMAGE_PARTITION_SIZE)" >> $(1))
1324 $(if $(BOARD_ODMIMAGE_JOURNAL_SIZE),$(hide) echo "odm_journal_size=$(BOARD_ODMIMAGE_JOURNAL_SIZE)" >> $(1))
1325 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "odm_squashfs_compressor=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1326 $(if $(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "odm_squashfs_compressor_opt=$(BOARD_ODMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1327 $(if $(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "odm_squashfs_block_size=$(BOARD_ODMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1328 $(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 +00001329 $(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 +08001330 $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
Daniel Norman72c626f2019-05-13 15:58:14 -07001331 $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1)
Chris Gross203191b2020-05-30 02:39:12 +00001332 $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001333)
Yifan Hongcfb917a2020-05-07 14:58:20 -07001334$(if $(filter $(2),vendor_dlkm),\
1335 $(if $(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_dlkm_fs_type=$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
1336 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_dlkm_extfs_inode_count=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1337 $(if $(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_dlkm_extfs_rsv_pct=$(BOARD_VENDOR_DLKMIMAGE_EXTFS_RSV_PCT)" >> $(1))
1338 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),$(hide) echo "vendor_dlkm_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE)" >> $(1))
1339 $(if $(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_dlkm_journal_size=$(BOARD_VENDOR_DLKMIMAGE_JOURNAL_SIZE)" >> $(1))
1340 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_dlkm_squashfs_compressor=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
1341 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_dlkm_squashfs_compressor_opt=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
1342 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_dlkm_squashfs_block_size=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
1343 $(if $(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_dlkm_squashfs_disable_4k_align=$(BOARD_VENDOR_DLKMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
1344 $(if $(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_dlkm_reserved_size=$(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1))
1345 $(hide) echo "vendor_dlkm_selinux_fc=$(SELINUX_FC)" >> $(1)
1346 $(hide) echo "building_vendor_dlkm_image=$(BUILDING_VENDOR_DLKM_IMAGE)" >> $(1)
1347)
Yifan Hong760d3c02018-05-30 11:16:46 -07001348$(if $(filter $(2),oem),\
1349 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
1350 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
1351 $(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
1352 $(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 -07001353 $(hide) echo "oem_selinux_fc=$(SELINUX_FC)" >> $(1)
Yifan Hong760d3c02018-05-30 11:16:46 -07001354)
Tao Bao3602eca2018-07-10 10:53:55 -07001355$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001356
Tao Bao3602eca2018-07-10 10:53:55 -07001357$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
Ying Wangbd93d422011-10-28 17:02:30 -07001358$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
Todd Poynorb2a555e2015-12-15 18:00:14 -08001359$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07001360$(if $(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG),$(hide) echo "f2fs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_F2FS_FLAG)" >> $(1))
Tao Bao3602eca2018-07-10 10:53:55 -07001361$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
1362$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
1363$(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 +00001364$(if $(PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1))
1365$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCT_SUPPORTS_VERITY)" >> $(1))
1366$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
1367$(if $(PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1))
1368$(if $(PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1))
Bowgo Tsai6ceeb1a2017-10-11 16:21:48 +08001369$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001370$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
1371$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
1372$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
Justin Yun6151e3f2019-06-25 15:58:13 +09001373$(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 -07001374$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001375$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
1376$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
1377$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
1378$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
1379$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
Tao Bao3cba3742017-05-16 16:27:25 -07001380$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001381$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1382$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1383$(if $(BOARD_AVB_ENABLE),\
1384 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
1385 $(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)
1386 $(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)
1387 $(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08001388$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1389$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1390$(if $(BOARD_AVB_ENABLE),\
1391 $(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
1392 $(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)
Bowgo Tsaie4544b12019-02-27 10:15:51 +08001393 $(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08001394$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1395$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1396$(if $(BOARD_AVB_ENABLE),\
1397 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
1398 $(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)
1399 $(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)
1400 $(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09001401$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1402$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1403$(if $(BOARD_AVB_ENABLE),\
1404 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
1405 $(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)
1406 $(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)
1407 $(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Justin Yun6151e3f2019-06-25 15:58:13 +09001408$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
Tao Bao1ebda8d2018-08-01 17:21:14 -07001409$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001410 $(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 +01001411$(if $(BOARD_AVB_ENABLE),\
Justin Yun6151e3f2019-06-25 15:58:13 +09001412 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
1413 $(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)
1414 $(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)
1415 $(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001416$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1417$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1418$(if $(BOARD_AVB_ENABLE),\
1419 $(if $(BOARD_AVB_ODM_KEY_PATH),\
1420 $(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)
1421 $(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)
1422 $(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Yifan Hongcfb917a2020-05-07 14:58:20 -07001423$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1))
1424$(if $(BOARD_AVB_ENABLE),\
1425 $(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
1426$(if $(BOARD_AVB_ENABLE),\
1427 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
1428 $(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)
1429 $(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)
1430 $(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)))
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001431$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
1432 $(hide) echo "recovery_as_boot=true" >> $(1))
Ying Wang0eabd4f2015-03-24 19:07:40 -07001433$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
Tom Cherryd14b8952018-08-09 14:26:00 -07001434 $(hide) echo "system_root_image=true" >> $(1))
1435$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
Tamas Petz89418f02020-02-03 15:40:15 +01001436$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
1437 $(hide) echo "use_dynamic_partition_size=true" >> $(1))
Yifan Hong760d3c02018-05-30 11:16:46 -07001438$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
1439endef
1440
1441# $(1): the path of the output dictionary file
1442# $(2): additional "key=value" pairs to append to the dictionary file.
Daniel Norman72c626f2019-05-13 15:58:14 -07001443PROP_DICTIONARY_IMAGES := oem
1444ifdef BUILDING_CACHE_IMAGE
1445 PROP_DICTIONARY_IMAGES += cache
1446endif
1447ifdef BUILDING_SYSTEM_IMAGE
1448 PROP_DICTIONARY_IMAGES += system
1449endif
Chris Gross203191b2020-05-30 02:39:12 +00001450ifdef BUILDING_SYSTEM_OTHER_IMAGE
1451 PROP_DICTIONARY_IMAGES += system_other
1452endif
Daniel Norman72c626f2019-05-13 15:58:14 -07001453ifdef BUILDING_USERDATA_IMAGE
1454 PROP_DICTIONARY_IMAGES += userdata
1455endif
1456ifdef BUILDING_VENDOR_IMAGE
1457 PROP_DICTIONARY_IMAGES += vendor
1458endif
1459ifdef BUILDING_PRODUCT_IMAGE
1460 PROP_DICTIONARY_IMAGES += product
1461endif
Justin Yun6151e3f2019-06-25 15:58:13 +09001462ifdef BUILDING_SYSTEM_EXT_IMAGE
1463 PROP_DICTIONARY_IMAGES += system_ext
Daniel Norman72c626f2019-05-13 15:58:14 -07001464endif
1465ifdef BUILDING_ODM_IMAGE
1466 PROP_DICTIONARY_IMAGES += odm
1467endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07001468ifdef BUILDING_VENDOR_DLKM_IMAGE
1469 PROP_DICTIONARY_IMAGES += vendor_dlkm
1470endif
Yifan Hong760d3c02018-05-30 11:16:46 -07001471define generate-userimage-prop-dictionary
Daniel Norman72c626f2019-05-13 15:58:14 -07001472 $(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
Ying Wangbd93d422011-10-28 17:02:30 -07001473endef
1474
Yifan Hongbbcba1e2018-06-18 16:32:35 -07001475# $(1): the path of the input dictionary file, where each line has the format key=value
1476# $(2): the key to look up
1477define read-image-prop-dictionary
1478$$(grep '$(2)=' $(1) | cut -f2- -d'=')
1479endef
1480
The Android Open Source Project88b60792009-03-03 19:28:42 -08001481# -----------------------------------------------------------------
Doug Zongker4647f122009-07-02 09:00:54 -07001482# Recovery image
Doug Zongker8cebf1f2009-07-07 17:14:25 -07001483
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001484# Recovery image exists if we are building recovery, or building recovery as boot.
Chris Grossa784ef12019-04-22 11:09:57 -07001485ifdef BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001486
Ying Wang37526142015-03-10 12:02:57 -07001487INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
1488 $(ALL_DEFAULT_INSTALLED_MODULES))
1489
Tao Bao10fc9492018-08-14 12:17:48 -07001490INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
1491INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
1492
1493# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
1494# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
1495# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
1496# the call to FILELIST.
1497ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Chris Grossa784ef12019-04-22 11:09:57 -07001498INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
Tao Bao10fc9492018-08-14 12:17:48 -07001499$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_BOOTIMAGE_TARGET)
1500else
1501$(INSTALLED_FILES_FILE_RECOVERY): $(INSTALLED_RECOVERYIMAGE_TARGET)
1502endif
1503
1504$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001505$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Tao Bao10fc9492018-08-14 12:17:48 -07001506 @echo Installed file list: $@
1507 @mkdir -p $(dir $@)
1508 @rm -f $@
1509 $(hide) $(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001510 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Tao Bao10fc9492018-08-14 12:17:48 -07001511
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001512recovery_sepolicy := \
1513 $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
Jeff Vander Stoep4ff042c2017-06-13 08:30:46 -07001514 $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001515 $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
Bowgo Tsai07365df2019-09-28 09:04:51 +08001516 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
1517 $(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
1518 $(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001519 $(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
Bowgo Tsai99671252017-11-30 22:15:17 +08001520 $(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
Tri Vo62d51b62019-02-19 11:23:12 -08001521 $(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
1522 $(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
1523 $(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
Bowgo Tsai99671252017-11-30 22:15:17 +08001524
Alex Klyubin2a7171a2017-03-10 12:53:02 -08001525# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
1526# SELinux files
1527IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
1528
Doug Zongker4647f122009-07-02 09:00:54 -07001529recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
1530recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
Dan Willemsen97672232020-05-27 00:09:16 -07001531recovery_resources_common := bootable/recovery/res
Doug Zongkere1297322013-03-06 15:04:31 -08001532
Anton Hansson45a40da2019-01-18 14:06:34 +00001533# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
1534# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
1535# which get remapped to a bucket.
1536recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
Tao Baoe1e829e2018-08-29 20:36:00 -07001537ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
1538recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
Anton Hansson45a40da2019-01-18 14:06:34 +00001539# We roughly use the medium point between the primary densities to split buckets.
Tao Baoe1e829e2018-08-29 20:36:00 -07001540# ------160------240------320----------480------------640------
1541# mdpi hdpi xhdpi xxhdpi xxxhdpi
1542recovery_density := $(strip \
1543 $(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
1544 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
1545 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
1546 $(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
Doug Zongker8eaeea92014-05-12 15:32:20 -07001547endif
1548
1549ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
1550recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
1551else
Doug Zongker25d55f82014-04-04 13:51:15 -07001552recovery_resources_common := $(recovery_resources_common)-xhdpi
1553endif
1554
Tao Baoe1e829e2018-08-29 20:36:00 -07001555# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
1556# Note that the font selected here can be overridden for a particular device by putting a font.png
1557# in its private recovery resources.
1558ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
Dan Willemsen97672232020-05-27 00:09:16 -07001559recovery_font := bootable/recovery/fonts/18x32.png
Doug Zongkere1297322013-03-06 15:04:31 -08001560else
Dan Willemsen97672232020-05-27 00:09:16 -07001561recovery_font := bootable/recovery/fonts/12x22.png
Doug Zongkere1297322013-03-06 15:04:31 -08001562endif
1563
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001564
1565# We will only generate the recovery background text images if the variable
1566# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
1567# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
1568# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
1569# BoardConfig in order to use this feature.
1570ifeq ($(recovery_density),xxxhdpi)
1571TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
1572else ifeq ($(recovery_density),xxhdpi)
1573TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
1574endif
1575
1576ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
1577# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
1578ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
1579 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
1580else
1581 recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
1582endif
1583
1584
Dan Willemsen97672232020-05-27 00:09:16 -07001585RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001586RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
1587RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
1588RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
1589RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
1590
xunchangcc57d312018-12-07 12:12:17 -08001591RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
1592RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
1593RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
1594RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
1595RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
1596
1597generated_recovery_text_files := \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001598 $(RECOVERY_INSTALLING_TEXT_FILE) \
1599 $(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
1600 $(RECOVERY_ERASING_TEXT_FILE) \
1601 $(RECOVERY_ERROR_TEXT_FILE) \
xunchangcc57d312018-12-07 12:12:17 -08001602 $(RECOVERY_NO_COMMAND_TEXT_FILE) \
1603 $(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
1604 $(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
1605 $(RECOVERY_TRY_AGAIN_TEXT_FILE) \
1606 $(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
1607 $(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001608
Dan Willemsen97672232020-05-27 00:09:16 -07001609resource_dir := bootable/recovery/tools/recovery_l10n/res/
1610resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001611image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
xunchangcc57d312018-12-07 12:12:17 -08001612zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001613$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
Dan Willemsen97672232020-05-27 00:09:16 -07001614$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001615$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
1616$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
xunchangcc57d312018-12-07 12:12:17 -08001617$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001618$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
xunchangdbe55e12018-12-19 17:15:14 -08001619$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001620 recovery_installing \
1621 recovery_installing_security \
1622 recovery_erasing \
1623 recovery_error \
xunchangdbe55e12018-12-19 17:15:14 -08001624 recovery_no_command
1625$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
xunchangcc57d312018-12-07 12:12:17 -08001626 recovery_cancel_wipe_data \
1627 recovery_factory_data_reset \
1628 recovery_try_again \
1629 recovery_wipe_data_menu_header \
1630 recovery_wipe_data_confirmation
1631$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
Dan Willemsen97672232020-05-27 00:09:16 -07001632$(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 -08001633 # Prepares the font directory.
1634 @rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
1635 @mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
xunchangcc57d312018-12-07 12:12:17 -08001636 $(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001637 @rm -rf $(dir $@)
1638 @mkdir -p $(dir $@)
xunchangdbe55e12018-12-19 17:15:14 -08001639 $(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
xunchangcc57d312018-12-07 12:12:17 -08001640 $(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
xunchangdbe55e12018-12-19 17:15:14 -08001641 $(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001642 java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
1643 --image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
1644 --text_name $(text_name) \
1645 --font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
1646 --resource_dir $(PRIVATE_RESOURCE_DIR) \
xunchangdbe55e12018-12-19 17:15:14 -08001647 --output_file $(output_file) $(center_alignment) && \
xunchangcc57d312018-12-07 12:12:17 -08001648 $(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001649else
1650RECOVERY_INSTALLING_TEXT_FILE :=
1651RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
1652RECOVERY_ERASING_TEXT_FILE :=
1653RECOVERY_ERROR_TEXT_FILE :=
1654RECOVERY_NO_COMMAND_TEXT_FILE :=
xunchangcc57d312018-12-07 12:12:17 -08001655RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
1656RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
1657RECOVERY_TRY_AGAIN_TEXT_FILE :=
1658RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
1659RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001660endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
1661
Ying Wang9a175682015-08-06 11:47:47 -07001662ifndef TARGET_PRIVATE_RES_DIRS
1663TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
1664endif
Doug Zongker4647f122009-07-02 09:00:54 -07001665recovery_resource_deps := $(shell find $(recovery_resources_common) \
Ying Wang9a175682015-08-06 11:47:47 -07001666 $(TARGET_PRIVATE_RES_DIRS) -type f)
xunchangcc57d312018-12-07 12:12:17 -08001667recovery_resource_deps += $(generated_recovery_text_files)
Tianjie Xu81c88ad2018-11-07 11:36:19 -08001668
1669
Andrew Boiefa61ff02012-09-28 09:33:45 -07001670ifdef TARGET_RECOVERY_FSTAB
1671recovery_fstab := $(TARGET_RECOVERY_FSTAB)
1672else
Doug Zongker9ce0fb62010-09-20 18:04:41 -07001673recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
Andrew Boiefa61ff02012-09-28 09:33:45 -07001674endif
Tao Baoc3c17532016-06-10 10:11:54 -07001675ifdef TARGET_RECOVERY_WIPE
1676recovery_wipe := $(TARGET_RECOVERY_WIPE)
Tao Bao3051f4f2016-05-31 23:56:23 -07001677else
Tao Baoc3c17532016-06-10 10:11:54 -07001678recovery_wipe :=
Tao Bao3051f4f2016-05-31 23:56:23 -07001679endif
Tao Bao8beab692015-07-22 12:33:18 -07001680
Tao Bao6d5d6232018-03-09 17:04:42 -08001681# Traditionally with non-A/B OTA we have:
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001682# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
Tao Bao6d5d6232018-03-09 17:04:42 -08001683# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
1684# and invoke install-recovery.sh on the first boot post an OTA update.
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001685#
1686# We no longer need that if one of the following conditions holds:
Tao Bao6d5d6232018-03-09 17:04:42 -08001687# a) We carry a full copy of the recovery image - no patching needed
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001688# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
Tao Bao6d5d6232018-03-09 17:04:42 -08001689# b) We build a single image that contains boot and recovery both - no recovery image to install
1690# (BOARD_USES_RECOVERY_AS_BOOT = true);
Tom Cherry2929cad2018-09-20 11:04:37 -07001691# c) We mount the system image as / and therefore do not have a ramdisk in boot.img
Tao Bao6d5d6232018-03-09 17:04:42 -08001692# (BOARD_BUILD_SYSTEM_ROOT_IMAGE = true).
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001693# d) We include the recovery DTBO image within recovery - not needing the resource file as we
1694# do bsdiff because boot and recovery will contain different number of entries
1695# (BOARD_INCLUDE_RECOVERY_DTBO = true).
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001696# e) We include the recovery ACPIO image within recovery - not needing the resource file as we
1697# do bsdiff because boot and recovery will contain different number of entries
1698# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08001699
Tom Cherry2929cad2018-09-20 11:04:37 -07001700ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001701 $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Doug Zongker56588872012-08-20 15:38:58 -07001702# Named '.dat' so we don't attempt to use imgdiff for patching it.
Bill Peckhame868aec2019-09-17 17:06:47 -07001703RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
1704ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
Tao Bao8beab692015-07-22 12:33:18 -07001705else
Tao Bao8beab692015-07-22 12:33:18 -07001706RECOVERY_RESOURCE_ZIP :=
1707endif
Doug Zongker4647f122009-07-02 09:00:54 -07001708
Tao Bao139c7272018-07-31 13:26:54 -07001709INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
1710
1711$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
Tao Bao139c7272018-07-31 13:26:54 -07001712 TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
1713 TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
1714 TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
1715 TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
1716 TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
1717 TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
1718 TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
1719 TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset
1720
1721# Parses the given list of build variables and writes their values as build properties if defined.
1722# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
1723# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
1724# $(1): Map from the build variable names to property names
1725# $(2): Output file
1726define append-recovery-ui-properties
1727echo "#" >> $(2)
1728echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
1729echo "#" >> $(2)
1730$(foreach prop,$(1), \
1731 $(eval _varname := $(call word-colon,1,$(prop))) \
1732 $(eval _propname := $(call word-colon,2,$(prop))) \
1733 $(eval _value := $($(_varname))) \
1734 $(if $(_value), \
1735 echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
1736endef
1737
1738$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001739 $(INSTALLED_BUILD_PROP_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00001740 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
1741 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
1742 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09001743 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
Tao Bao1edaca12018-09-18 10:22:54 -07001744 @echo "Target recovery buildinfo: $@"
Tao Bao139c7272018-07-31 13:26:54 -07001745 $(hide) mkdir -p $(dir $@)
1746 $(hide) rm -f $@
Jiyong Parkbb26c6f2020-05-26 03:18:36 +09001747 $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001748 $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08001749 $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001750 $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
Justin Yun6151e3f2019-06-25 15:58:13 +09001751 $(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
Tao Bao139c7272018-07-31 13:26:54 -07001752 $(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
1753
Steve Mucklef84668e2020-03-16 19:13:46 -07001754ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Muckle10346272020-04-07 16:39:10 -07001755 INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
Steve Mucklee1b10862019-07-10 10:49:37 -07001756ifdef GENERIC_KERNEL_CMDLINE
1757 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
1758endif
Steve Mucklef84668e2020-03-16 19:13:46 -07001759else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
Steve Mucklee1b10862019-07-10 10:49:37 -07001760 INTERNAL_RECOVERYIMAGE_ARGS := \
1761 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001762 --ramdisk $(recovery_ramdisk)
Doug Zongker4647f122009-07-02 09:00:54 -07001763# Assumes this has already been stripped
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07001764ifdef INTERNAL_KERNEL_CMDLINE
1765 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
Doug Zongker4647f122009-07-02 09:00:54 -07001766endif
1767ifdef BOARD_KERNEL_BASE
1768 INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
1769endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07001770ifdef BOARD_KERNEL_PAGESIZE
1771 INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
1772endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001773ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08001774ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1775 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1776else
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07001777 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
1778endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001779endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001780ifdef BOARD_INCLUDE_RECOVERY_ACPIO
1781 INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
1782endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001783ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
1784 INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
1785endif
Steve Mucklee1b10862019-07-10 10:49:37 -07001786endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Steve Mucklef84668e2020-03-16 19:13:46 -07001787ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
1788 BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
1789endif
Doug Zongker4647f122009-07-02 09:00:54 -07001790
J. Avila3f6560e2020-05-11 20:20:03 +00001791$(recovery_ramdisk): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001792 $(INTERNAL_ROOT_FILES) \
1793 $(INSTALLED_RAMDISK_TARGET) \
1794 $(INTERNAL_RECOVERYIMAGE_FILES) \
1795 $(recovery_sepolicy) \
1796 $(INSTALLED_2NDBOOTLOADER_TARGET) \
1797 $(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
1798 $(recovery_resource_deps) \
1799 $(recovery_fstab)
1800 # Making recovery image
1801 mkdir -p $(TARGET_RECOVERY_OUT)
1802 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
1803 # Copying baseline ramdisk...
1804 # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
1805 rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
1806 # Modifying ramdisk contents...
1807 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),, \
1808 ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init)
1809 # Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
1810 find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
1811 cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
1812 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1813 rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1814 cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1815 $(foreach recovery_text_file,$(generated_recovery_text_files), \
1816 cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
1817 cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1818 $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1819 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1820 $(foreach item,$(recovery_fstab), \
1821 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
1822 $(if $(strip $(recovery_wipe)), \
1823 cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
1824 ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
1825 $(BOARD_RECOVERY_IMAGE_PREPARE)
J. Avila3f6560e2020-05-11 20:20:03 +00001826 $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
Steve Muckleb3dda772020-03-11 16:03:07 -07001827
Ying Wang747b9f12015-01-30 14:05:22 -08001828# $(1): output file
Steve Muckleb3dda772020-03-11 16:03:07 -07001829# $(2): kernel file
Ying Wang747b9f12015-01-30 14:05:22 -08001830define build-recoveryimage-target
Anton Hansson8dab0a62019-03-28 15:45:40 +00001831 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
Steve Muckle10346272020-04-07 16:39:10 -07001832 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001833 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001834 --output $(1).unsigned, \
Steve Muckle10346272020-04-07 16:39:10 -07001835 $(MKBOOTIMG) --kernel $(2) $(INTERNAL_RECOVERYIMAGE_ARGS) \
Steve Mucklef84668e2020-03-16 19:13:46 -07001836 $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
Steve Muckleb3dda772020-03-11 16:03:07 -07001837 --output $(1))
Anton Hansson8dab0a62019-03-28 15:45:40 +00001838 $(if $(filter true,$(PRODUCT_SUPPORTS_BOOT_SIGNER)),\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001839 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
Anton Hansson8dab0a62019-03-28 15:45:40 +00001840 $(BOOT_SIGNER) /boot $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\
1841 $(BOOT_SIGNER) /recovery $(1) $(PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\
Nick Desaulniersd491fcf2016-08-08 10:51:10 -07001842 )\
1843 )
Anton Hansson8dab0a62019-03-28 15:45:40 +00001844 $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
1845 $(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 +08001846 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001847 $(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 -07001848 $(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
David Zeuthen8fecb282017-12-01 16:24:01 -05001849 $(if $(filter true,$(BOARD_AVB_ENABLE)), \
1850 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
Steve Muckle903a1ca2020-05-07 17:32:10 -07001851 $(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 -07001852 $(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 -08001853endef
1854
Dan Willemsend120ac62020-06-12 02:39:34 +00001855recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
Anton Hansson8dab0a62019-03-28 15:45:40 +00001856ifeq (true,$(PRODUCT_SUPPORTS_BOOT_SIGNER))
Dan Willemsend120ac62020-06-12 02:39:34 +00001857 recoveryimage-deps += $(BOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001858endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00001859ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Dan Willemsend120ac62020-06-12 02:39:34 +00001860 recoveryimage-deps += $(VBOOT_SIGNER)
Ying Wangbd07ad02016-03-10 12:57:33 -08001861endif
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001862ifeq (true,$(BOARD_AVB_ENABLE))
Dan Willemsend120ac62020-06-12 02:39:34 +00001863 recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
Thierry Strudeld7bd1f22017-05-04 13:58:04 -07001864endif
Tao Baof4866c72018-08-22 14:35:09 -07001865ifdef BOARD_INCLUDE_RECOVERY_DTBO
Dan Willemsend120ac62020-06-12 02:39:34 +00001866 ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
1867 recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
1868 else
1869 recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
1870 endif
Hridya Valsarajua9418992019-02-04 10:35:25 -08001871endif
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001872ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Dan Willemsend120ac62020-06-12 02:39:34 +00001873 recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08001874endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001875ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
Dan Willemsend120ac62020-06-12 02:39:34 +00001876 recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08001877endif
Tao Baof4866c72018-08-22 14:35:09 -07001878
Dan Willemsend120ac62020-06-12 02:39:34 +00001879ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1880$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
Tao Baof4866c72018-08-22 14:35:09 -07001881 $(call pretty,"Target boot image from recovery: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07001882 $(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
Tao Baof4866c72018-08-22 14:35:09 -07001883endif # BOARD_USES_RECOVERY_AS_BOOT
1884
Dan Willemsend120ac62020-06-12 02:39:34 +00001885$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
Steve Muckleb3dda772020-03-11 16:03:07 -07001886 $(call build-recoveryimage-target, $@, $(recovery_kernel))
Doug Zongker4647f122009-07-02 09:00:54 -07001887
Tao Bao4594d0e2015-12-22 09:47:46 -08001888ifdef RECOVERY_RESOURCE_ZIP
Dan Willemsen48a621c2015-10-29 16:33:05 -07001889$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Doug Zongker1a097262012-09-04 14:45:11 -07001890 $(hide) mkdir -p $(dir $@)
Dan Willemsen48a621c2015-10-29 16:33:05 -07001891 $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
1892 $(remove-timestamps-from-package)
Tao Bao8beab692015-07-22 12:33:18 -07001893endif
Doug Zongker56588872012-08-20 15:38:58 -07001894
Ying Wang747b9f12015-01-30 14:05:22 -08001895.PHONY: recoveryimage-nodeps
1896recoveryimage-nodeps:
1897 @echo "make $@: ignoring dependencies"
1898 $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
1899
Chris Grossa784ef12019-04-22 11:09:57 -07001900else # BUILDING_RECOVERY_IMAGE
Doug Zongker56588872012-08-20 15:38:58 -07001901RECOVERY_RESOURCE_ZIP :=
Chris Grossa784ef12019-04-22 11:09:57 -07001902endif # BUILDING_RECOVERY_IMAGE
Doug Zongker4647f122009-07-02 09:00:54 -07001903
1904.PHONY: recoveryimage
Doug Zongker56588872012-08-20 15:38:58 -07001905recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
Doug Zongker4647f122009-07-02 09:00:54 -07001906
Jiyong Park03eb0612017-10-04 21:22:41 +09001907ifneq ($(BOARD_NAND_PAGE_SIZE),)
1908$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
Dima Zavin11818982010-02-05 13:34:34 -08001909endif
1910
Jiyong Park03eb0612017-10-04 21:22:41 +09001911ifneq ($(BOARD_NAND_SPARE_SIZE),)
1912$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
Naseer Ahmed53871882010-08-06 12:19:29 -07001913endif
1914
Bowgo Tsai5c40c712019-10-08 10:22:19 +08001915ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
Doug Zongker4647f122009-07-02 09:00:54 -07001916# -----------------------------------------------------------------
Bowgo Tsai0013f552019-03-20 17:59:52 +08001917# the debug ramdisk, which is the original ramdisk plus additional
1918# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
1919# When /force_debuggable is present, /init will load userdebug sepolicy
1920# and property files to allow adb root, if the device is unlocked.
1921
1922ifdef BUILDING_RAMDISK_IMAGE
1923BUILT_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
1924INSTALLED_DEBUG_RAMDISK_TARGET := $(BUILT_DEBUG_RAMDISK_TARGET)
1925
1926INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
1927 $(ALL_GENERATED_SOURCES) \
1928 $(ALL_DEFAULT_INSTALLED_MODULES))
1929
1930# Note: TARGET_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/debug_ramdisk/first_stage_ramdisk,
1931# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/debug_ramdisk.
1932# But the root dir of the ramdisk to build is always $(PRODUCT_OUT)/debug_ramdisk.
1933my_debug_ramdisk_root_dir := $(PRODUCT_OUT)/debug_ramdisk
1934
1935INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
1936INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
1937$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
1938$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
1939
1940# Cannot just depend on INTERNAL_DEBUG_RAMDISK_FILES like other INSTALLED_FILES_FILE_* rules.
1941# Because ramdisk-debug.img will rsync from either ramdisk.img or ramdisk-recovery.img.
1942# Need to depend on the built ramdisk-debug.img, to get a complete list of the installed files.
1943$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INSTALLED_DEBUG_RAMDISK_TARGET)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001944$(INSTALLED_FILES_FILE_DEBUG_RAMDISK) : $(INTERNAL_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001945 echo Installed file list: $@
1946 mkdir -p $(dir $@)
1947 rm -f $@
1948 $(FILESLIST) $(DEBUG_RAMDISK_ROOT_DIR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07001949 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08001950
1951# ramdisk-debug.img will rsync the content from either ramdisk.img or ramdisk-recovery.img,
1952# depending on whether BOARD_USES_RECOVERY_AS_BOOT is set or not.
1953ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1954my_debug_ramdisk_sync_dir := $(TARGET_RECOVERY_ROOT_OUT)
1955else
1956my_debug_ramdisk_sync_dir := $(TARGET_RAMDISK_OUT)
1957endif # BOARD_USES_RECOVERY_AS_BOOT
1958
1959$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
1960$(INSTALLED_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08001961
1962ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1963# 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 +08001964$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_BOOTIMAGE_TARGET)
Bowgo Tsaic3e8cc92019-04-24 12:35:50 +08001965else
1966# Depends on ramdisk.img, note that some target has ramdisk.img but no boot.img, e.g., emulator.
1967$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_RAMDISK_TARGET)
1968endif # BOARD_USES_RECOVERY_AS_BOOT
J. Avila3f6560e2020-05-11 20:20:03 +00001969$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001970 $(call pretty,"Target debug ram disk: $@")
1971 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
1972 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08001973 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00001974 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai0013f552019-03-20 17:59:52 +08001975
1976.PHONY: ramdisk_debug-nodeps
1977ramdisk_debug-nodeps: DEBUG_RAMDISK_SYNC_DIR := $(my_debug_ramdisk_sync_dir)
1978ramdisk_debug-nodeps: DEBUG_RAMDISK_ROOT_DIR := $(my_debug_ramdisk_root_dir)
J. Avila3f6560e2020-05-11 20:20:03 +00001979ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001980 echo "make $@: ignoring dependencies"
1981 mkdir -p $(TARGET_DEBUG_RAMDISK_OUT)
1982 touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
Bowgo Tsai1578e232019-04-24 15:33:03 +08001983 rsync -a $(DEBUG_RAMDISK_SYNC_DIR)/ $(DEBUG_RAMDISK_ROOT_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00001984 $(MKBOOTFS) -d $(TARGET_OUT) $(DEBUG_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
Bowgo Tsai0013f552019-03-20 17:59:52 +08001985
1986my_debug_ramdisk_sync_dir :=
1987my_debug_ramdisk_root_dir :=
1988
1989endif # BUILDING_RAMDISK_IMAGE
1990
1991# -----------------------------------------------------------------
1992# the boot-debug.img, which is the kernel plus ramdisk-debug.img
1993#
1994# Note: it's intentional to skip signing for boot-debug.img, because it
1995# can only be used if the device is unlocked with verification error.
1996ifneq ($(strip $(TARGET_NO_KERNEL)),true)
Steve Muckleb3dda772020-03-11 16:03:07 -07001997ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
1998 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
1999 $(PRODUCT_OUT)/$(k).img)
2000else
2001 INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
2002endif
Bowgo Tsai0013f552019-03-20 17:59:52 +08002003
2004# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
2005ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
2006INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(recovery_ramdisk),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_RECOVERYIMAGE_ARGS))
2007else
2008INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INSTALLED_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET), $(INTERNAL_BOOTIMAGE_ARGS))
2009endif
2010
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002011# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
2012# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2013# Using a test key to sign boot-debug.img to continue booting with the mismatched
2014# public key, if the device is unlocked.
2015ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002016$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
Bowgo Tsai26b0a262019-05-03 16:38:34 +08002017endif
2018
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002019BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2020INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2021# $(1): the bootimage to sign
2022define test-key-sign-bootimage
Steve Muckle903a1ca2020-05-07 17:32:10 -07002023$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot-debug)))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002024$(AVBTOOL) add_hash_footer \
2025 --image $(1) \
Steve Muckle903a1ca2020-05-07 17:32:10 -07002026 --partition_size $(call get-bootimage-partition-size,$(1),boot-debug)\
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002027 --partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
2028 $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
Steve Muckle903a1ca2020-05-07 17:32:10 -07002029$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot-debug))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002030endef
2031
Steve Muckleb3dda772020-03-11 16:03:07 -07002032# $(1): output file
2033define build-debug-bootimage-target
2034 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
2035 $(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $1
2036 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1))
2037endef
2038
Bowgo Tsai0013f552019-03-20 17:59:52 +08002039# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
2040$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
2041 $(call pretty,"Target boot debug image: $@")
Steve Muckleb3dda772020-03-11 16:03:07 -07002042 $(call build-debug-bootimage-target, $@)
Bowgo Tsai0013f552019-03-20 17:59:52 +08002043
2044.PHONY: bootimage_debug-nodeps
2045bootimage_debug-nodeps: $(MKBOOTIMG)
2046 echo "make $@: ignoring dependencies"
Steve Muckleb3dda772020-03-11 16:03:07 -07002047 $(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
Bowgo Tsai0013f552019-03-20 17:59:52 +08002048
2049endif # TARGET_NO_KERNEL
2050
Bowgo Tsai6a683672020-02-14 19:00:15 +08002051ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
2052ifeq ($(BUILDING_RAMDISK_IMAGE),true)
2053# -----------------------------------------------------------------
2054# vendor debug ramdisk
2055# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
J. Avila3f6560e2020-05-11 20:20:03 +00002056INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor-ramdisk-debug.cpio$(RAMDISK_EXT)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002057$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): DEBUG_RAMDISK_FILES := $(INTERNAL_DEBUG_RAMDISK_FILES)
2058$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_RAMDISK_DIR := $(TARGET_VENDOR_RAMDISK_OUT)
2059
2060INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
2061 $(ALL_GENERATED_SOURCES) \
2062 $(ALL_DEFAULT_INSTALLED_MODULES))
2063
2064# Note: TARGET_VENDOR_DEBUG_RAMDISK_OUT will be $(PRODUCT_OUT)/vendor_debug_ramdisk/first_stage_ramdisk,
2065# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/vendor_debug_ramdisk.
2066# But the path of $(VENDOR_DEBUG_RAMDISK_DIR) to build the vendor debug ramdisk, is always
2067# $(PRODUCT_OUT)/vendor_debug_ramdisk.
2068$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2069$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002070$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai6a683672020-02-14 19:00:15 +08002071 $(call pretty,"Target vendor debug ram disk: $@")
2072 mkdir -p $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
2073 touch $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/force_debuggable
2074 $(foreach debug_file,$(DEBUG_RAMDISK_FILES), \
2075 cp -f $(debug_file) $(subst $(PRODUCT_OUT)/debug_ramdisk,$(PRODUCT_OUT)/vendor_debug_ramdisk,$(debug_file)) &&) true
2076 rsync -a $(VENDOR_RAMDISK_DIR)/ $(VENDOR_DEBUG_RAMDISK_DIR)
J. Avila3f6560e2020-05-11 20:20:03 +00002077 $(MKBOOTFS) -d $(TARGET_OUT) $(VENDOR_DEBUG_RAMDISK_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002078
2079INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
2080INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
2081$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
2082$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): VENDOR_DEBUG_RAMDISK_DIR := $(PRODUCT_OUT)/vendor_debug_ramdisk
2083
2084# The vendor debug ramdisk will rsync from $(TARGET_VENDOR_RAMDISK_OUT) and $(INTERNAL_DEBUG_RAMDISK_FILES),
2085# so we have to wait for the vendor debug ramdisk to be built before generating the installed file list.
2086$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2087$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2088 echo Installed file list: $@
2089 mkdir -p $(dir $@)
2090 rm -f $@
2091 $(FILESLIST) $(VENDOR_DEBUG_RAMDISK_DIR) > $(@:.txt=.json)
2092 $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2093
2094# -----------------------------------------------------------------
2095# vendor_boot-debug.img.
2096INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
2097
2098# The util to sign vendor_boot-debug.img with a test key.
2099BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
2100INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2101# $(1): the vendor bootimage to sign
2102define test-key-sign-vendor-bootimage
2103$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
2104$(AVBTOOL) add_hash_footer \
2105 --image $(1) \
2106 --partition_size $(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE) \
2107 --partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
2108 $(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
2109$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2110endef
2111
2112ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
2113$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
2114endif
2115
2116# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
2117$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
2118 $(call pretty,"Target vendor_boot debug image: $@")
cfig125efba2020-05-11 15:00:35 +08002119 $(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) --vendor_boot $@
Bowgo Tsai6a683672020-02-14 19:00:15 +08002120 $(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
2121 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
2122
2123endif # BUILDING_RAMDISK_IMAGE
2124endif # BUILDING_VENDOR_BOOT_IMAGE
2125
Bowgo Tsai0013f552019-03-20 17:59:52 +08002126# -----------------------------------------------------------------
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002127# The test harness ramdisk, which is based off debug_ramdisk, plus a
2128# few additional test-harness-specific properties in adb_debug.prop.
2129
2130ifdef BUILDING_RAMDISK_IMAGE
2131BUILT_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
2132INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(BUILT_TEST_HARNESS_RAMDISK_TARGET)
2133
2134# rsync the content from ramdisk-debug.img to ramdisk-test-harness.img, then
2135# appends a few test harness specific properties into the adb_debug.prop.
2136TEST_HARNESS_RAMDISK_SYNC_DIR := $(PRODUCT_OUT)/debug_ramdisk
2137TEST_HARNESS_RAMDISK_ROOT_DIR := $(PRODUCT_OUT)/test_harness_ramdisk
2138
2139# The following TARGET_TEST_HARNESS_RAMDISK_OUT will be $(PRODUCT_OUT)/test_harness_ramdisk/first_stage_ramdisk,
2140# if BOARD_USES_RECOVERY_AS_BOOT is true. Otherwise, it will be $(PRODUCT_OUT)/test_harness_ramdisk.
2141TEST_HARNESS_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
2142ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
2143ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
2144
2145# $(1): a list of key=value pairs for additional property assignments
2146# $(2): the target .prop file to append the properties from $(1)
2147define append-test-harness-props
2148 echo "#" >> $(2); \
2149 echo "# ADDITIONAL TEST HARNESS_PROPERTIES" >> $(2); \
2150 echo "#" >> $(2);
2151 $(foreach line,$(1), echo "$(line)" >> $(2);)
2152endef
2153
2154$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
J. Avila3f6560e2020-05-11 20:20:03 +00002155$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002156 $(call pretty,"Target test harness ram disk: $@")
2157 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2158 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002159 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $@
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002160
2161.PHONY: ramdisk_test_harness-nodeps
J. Avila3f6560e2020-05-11 20:20:03 +00002162ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002163 echo "make $@: ignoring dependencies"
2164 rsync -a $(TEST_HARNESS_RAMDISK_SYNC_DIR)/ $(TEST_HARNESS_RAMDISK_ROOT_DIR)
2165 $(call append-test-harness-props,$(ADDITIONAL_TEST_HARNESS_PROPERTIES),$(TEST_HARNESS_PROP_TARGET))
J. Avila3f6560e2020-05-11 20:20:03 +00002166 $(MKBOOTFS) -d $(TARGET_OUT) $(TEST_HARNESS_RAMDISK_ROOT_DIR) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002167
2168endif # BUILDING_RAMDISK_IMAGE
2169
2170# -----------------------------------------------------------------
2171# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
2172#
2173# Note: it's intentional to skip signing for boot-test-harness.img, because it
2174# can only be used if the device is unlocked with verification error.
2175ifneq ($(strip $(TARGET_NO_KERNEL)),true)
2176
Steve Muckle4866bd62020-04-02 11:31:08 -07002177ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
2178 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
2179 $(PRODUCT_OUT)/$(k).img)
2180else
2181 INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
2182endif
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002183
2184# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
2185INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
2186
2187# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
2188# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
2189# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
2190# public key, if the device is unlocked.
2191ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
2192$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
2193endif
2194
Steve Muckle4866bd62020-04-02 11:31:08 -07002195# $(1): output file
2196define build-boot-test-harness-target
2197 $(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
2198 $(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
2199 $(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@))
2200endef
2201
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002202# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
2203$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
2204 $(call pretty,"Target boot test harness image: $@")
Steve Muckle4866bd62020-04-02 11:31:08 -07002205 $(call build-boot-test-harness-target,$@)
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002206
2207.PHONY: bootimage_test_harness-nodeps
2208bootimage_test_harness-nodeps: $(MKBOOTIMG)
2209 echo "make $@: ignoring dependencies"
Steve Muckle4866bd62020-04-02 11:31:08 -07002210 $(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
Bowgo Tsai5c40c712019-10-08 10:22:19 +08002211
2212endif # TARGET_NO_KERNEL
2213endif # BOARD_BUILD_SYSTEM_ROOT_IMAGE is not true
2214
2215# -----------------------------------------------------------------
Ying Wang02352372010-09-27 10:37:25 -07002216# system image
The Android Open Source Project88b60792009-03-03 19:28:42 -08002217#
Ying Wang9c649a72012-08-08 15:27:00 -07002218# Remove overridden packages from $(ALL_PDK_FUSION_FILES)
2219PDK_FUSION_SYSIMG_FILES := \
2220 $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \
2221 $(ALL_PDK_FUSION_FILES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002222
Dan Willemsen37a19862018-10-31 16:31:46 -07002223INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
Ying Wang160b6702012-03-13 18:58:27 -07002224 $(ALL_GENERATED_SOURCES) \
Doug Zongker56588872012-08-20 15:38:58 -07002225 $(ALL_DEFAULT_INSTALLED_MODULES) \
Bill Peckhame868aec2019-09-17 17:06:47 -07002226 $(PDK_FUSION_SYSIMG_FILES)) \
Dan Willemsen37a19862018-10-31 16:31:46 -07002227 $(PDK_FUSION_SYMLINK_STAMP))
Ying Wang160b6702012-03-13 18:58:27 -07002228
Ying Wang82cceba2012-08-13 15:03:00 -07002229FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002230
2231# ASAN libraries in the system image - add dependency.
2232ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07002233ifneq (,$(filter address, $(SANITIZE_TARGET)))
Andreas Gampe039b5c72017-03-24 16:06:31 -07002234 ifeq (true,$(SANITIZE_TARGET_SYSTEM))
2235 FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
2236 endif
2237endif
2238
Tom Cherryd14b8952018-08-09 14:26:00 -07002239FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
Luis Hector Chavezff489932018-07-03 15:41:40 -07002240
Ying Wange5e8c5f2011-09-09 16:35:53 -07002241# -----------------------------------------------------------------
Dan Willemsen67495202019-01-16 12:42:05 -08002242ifdef BUILDING_SYSTEM_IMAGE
2243
Ying Wange5e8c5f2011-09-09 16:35:53 -07002244# installed file list
2245# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
2246# We put installed-files.txt ahead of image itself in the dependency graph
2247# so that we can get the size stat even if the build fails due to too large
2248# system image.
2249INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
Colin Cross23dded02018-06-13 14:04:22 -07002250INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
2251$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002252$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002253 @echo Installed file list: $@
2254 @mkdir -p $(dir $@)
2255 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002256 $(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002257 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wange5e8c5f2011-09-09 16:35:53 -07002258
2259.PHONY: installed-file-list
2260installed-file-list: $(INSTALLED_FILES_FILE)
Ying Wang534fcd72013-03-01 16:45:35 -08002261
2262$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE))
Ying Wange5e8c5f2011-09-09 16:35:53 -07002263
2264systemimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002265 $(call intermediates-dir-for,PACKAGING,systemimage)
Ying Wange5e8c5f2011-09-09 16:35:53 -07002266BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img
2267
Ying Wang23898df2014-06-18 20:26:24 -07002268# Create symlink /system/vendor to /vendor if necessary.
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002269ifdef BOARD_USES_VENDORIMAGE
Ying Wang23898df2014-06-18 20:26:24 -07002270define create-system-vendor-symlink
Ying Wang3e72ed12014-07-17 12:56:49 -07002271$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \
2272 echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \
2273 echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \
2274 exit 1; \
2275fi
Ying Wang23898df2014-06-18 20:26:24 -07002276$(hide) ln -sf /vendor $(TARGET_OUT)/vendor
2277endef
2278else
2279define create-system-vendor-symlink
2280endef
2281endif
2282
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002283# Create symlink /system/product to /product if necessary.
2284ifdef BOARD_USES_PRODUCTIMAGE
2285define create-system-product-symlink
2286$(hide) if [ -d $(TARGET_OUT)/product ] && [ ! -h $(TARGET_OUT)/product ]; then \
2287 echo 'Non-symlink $(TARGET_OUT)/product detected!' 1>&2; \
2288 echo 'You cannot install files to $(TARGET_OUT)/product while building a separate product.img!' 1>&2; \
2289 exit 1; \
2290fi
2291$(hide) ln -sf /product $(TARGET_OUT)/product
2292endef
2293else
2294define create-system-product-symlink
2295endef
2296endif
2297
Justin Yun6151e3f2019-06-25 15:58:13 +09002298# Create symlink /system/system_ext to /system_ext if necessary.
2299ifdef BOARD_USES_SYSTEM_EXTIMAGE
2300define create-system-system_ext-symlink
2301$(hide) if [ -d $(TARGET_OUT)/system_ext ] && [ ! -h $(TARGET_OUT)/system_ext ]; then \
2302 echo 'Non-symlink $(TARGET_OUT)/system_ext detected!' 1>&2; \
2303 echo 'You cannot install files to $(TARGET_OUT)/system_ext while building a separate system_ext.img!' 1>&2; \
Dario Freni5f681e12018-05-29 13:09:01 +01002304 exit 1; \
2305fi
Justin Yun6151e3f2019-06-25 15:58:13 +09002306$(hide) ln -sf /system_ext $(TARGET_OUT)/system_ext
Dario Freni5f681e12018-05-29 13:09:01 +01002307endef
2308else
Justin Yun6151e3f2019-06-25 15:58:13 +09002309define create-system-system_ext-symlink
Dario Freni5f681e12018-05-29 13:09:01 +01002310endef
2311endif
2312
The Android Open Source Project88b60792009-03-03 19:28:42 -08002313# $(1): output file
2314define build-systemimage-target
Ying Wangbd93d422011-10-28 17:02:30 -07002315 @echo "Target system fs image: $(1)"
Ying Wang23898df2014-06-18 20:26:24 -07002316 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002317 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09002318 $(call create-system-system_ext-symlink)
Ying Wangbd93d422011-10-28 17:02:30 -07002319 @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002320 $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
Geremy Condra5b5f4952014-05-05 22:19:37 -07002321 skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002322 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002323 $(BUILD_IMAGE) \
2324 $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
2325 || ( mkdir -p $${DIST_DIR}; \
2326 cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
2327 exit 1 )
The Android Open Source Project88b60792009-03-03 19:28:42 -08002328endef
2329
Dan Willemsen6b72c732019-06-12 21:33:38 +00002330ifeq ($(BOARD_AVB_ENABLE),true)
2331$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
2332endif
Tao Bao2bbb07c2019-05-07 13:12:21 -07002333$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002334 $(call build-systemimage-target,$@)
2335
Tao Baoe9d61b02018-08-20 21:09:07 -07002336INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
Ying Wang02352372010-09-27 10:37:25 -07002337SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002338
Tao Baoe9d61b02018-08-20 21:09:07 -07002339# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
2340# compatibility, in case device-specific Makefiles still refer to the old name.
2341INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
2342
Doug Zongker73ef8252009-07-23 15:12:53 -07002343# The system partition needs room for the recovery image as well. We
2344# now store the recovery image as a binary patch using the boot image
2345# as the source (since they are very similar). Generate the patch so
2346# we can see how big it's going to be, and include that in the system
2347# image size check calculation.
Tao Baob1a2e352018-08-14 16:17:12 -07002348ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
Sriram Raman1e96ac82009-07-24 13:52:32 -07002349ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Bao8beab692015-07-22 12:33:18 -07002350ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
Chen, ZhiminX752439b2018-09-23 22:10:47 +08002351ifneq (,$(filter true, $(BOARD_BUILD_SYSTEM_ROOT_IMAGE) $(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
Tao Bao6d5d6232018-03-09 17:04:42 -08002352diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
2353else
2354diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
2355endif
Doug Zongker73ef8252009-07-23 15:12:53 -07002356intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
2357RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
Tao Bao6d5d6232018-03-09 17:04:42 -08002358$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
2359$(RECOVERY_FROM_BOOT_PATCH): \
Anton Hansson6d814982018-11-26 18:12:05 +00002360 $(INSTALLED_RECOVERYIMAGE_TARGET) \
2361 $(INSTALLED_BOOTIMAGE_TARGET) \
2362 $(diff_tool)
Doug Zongker73ef8252009-07-23 15:12:53 -07002363 @echo "Construct recovery from boot"
2364 mkdir -p $(dir $@)
Tao Bao6d5d6232018-03-09 17:04:42 -08002365 $(PRIVATE_DIFF_TOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
Tao Bao8beab692015-07-22 12:33:18 -07002366else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
2367RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
Tao Baob1a2e352018-08-14 16:17:12 -07002368endif # BOARD_USES_FULL_RECOVERY_IMAGE
2369endif # INSTALLED_RECOVERYIMAGE_TARGET
2370endif # INSTALLED_BOOTIMAGE_TARGET
Doug Zongker73ef8252009-07-23 15:12:53 -07002371
Yifan Hong9a3cad92020-04-27 19:06:59 -07002372$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002373 @echo "Install system fs image: $@"
2374 $(copy-file-to-target)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002375 $(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002376
Tao Baoe9d61b02018-08-20 21:09:07 -07002377systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002378
2379.PHONY: systemimage-nodeps snod
2380systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
Colin Cross144b0282010-05-10 13:04:47 -07002381 | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002382 @echo "make $@: ignoring dependencies"
Tao Baoe9d61b02018-08-20 21:09:07 -07002383 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
Yifan Hong8c3dce02019-04-09 17:03:57 +00002384 $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Ying Wangacf01ec2012-02-24 11:05:48 -08002385ifeq (true,$(WITH_DEXPREOPT))
Dan Willemsen395358e2020-03-04 23:50:53 +00002386 $(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
Ying Wangacf01ec2012-02-24 11:05:48 -08002387endif
2388
Dan Willemsen67495202019-01-16 12:42:05 -08002389endif # BUILDING_SYSTEM_IMAGE
2390
Anton Hansson30e061b2018-11-12 13:36:46 +00002391.PHONY: sync syncsys
2392sync syncsys: $(INTERNAL_SYSTEMIMAGE_FILES)
Colin Cross91a52272017-06-20 16:57:52 -07002393
Ying Wang3a61eeb2016-03-11 10:32:01 -08002394# -----------------------------------------------------------------
Ying Wang4534d812012-04-09 17:04:12 -07002395## platform.zip: system, plus other files to be used in PDK fusion build,
2396## in a zip file
keunyoungc0178062013-07-22 14:54:58 -07002397##
2398## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip.
2399## The variable will be typically set from BoardConfig.mk.
2400## Files under out dir will be rejected to prevent possible conflicts with other rules.
Colin Cross53c8f972018-09-28 16:19:42 -07002401ifneq (,$(BUILD_PLATFORM_ZIP))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002402pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002403 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002404pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\
Colin Cross6db5b0e2018-11-16 21:26:33 -08002405 $(if $(filter $(DEXPREOPT.$(m).INSTALLED_STRIPPED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m))))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002406pdk_classes_dex := $(strip \
2407 $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002408 $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.apk))
Ying Wang3a61eeb2016-03-11 10:32:01 -08002409
2410pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk
2411$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs)
2412$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps)
2413$(pdk_odex_config_mk) :
2414 @echo "PDK odex config makefile: $@"
2415 $(hide) mkdir -p $(dir $@)
2416 $(hide) echo "# Auto-generated. Do not modify." > $@
2417 $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@
2418 $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@
2419 $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\
2420 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\
2421 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2422 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2423 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2424 )
2425 $(foreach m,$(PRIVATE_APPS),\
Nicolas Geoffray2ca0e492019-10-18 14:47:19 +01002426 $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.apk)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002427 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\
2428 $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
2429 $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
2430 $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
Dan Willemsen05a2b932017-03-20 18:31:17 -07002431 $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
Ying Wang3a61eeb2016-03-11 10:32:01 -08002432 $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
2433 $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
2434 )
2435
keunyoungc0178062013-07-22 14:54:58 -07002436PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))
Keun young Park816b9fd2012-05-16 10:32:41 -07002437INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip
Ying Wang3a61eeb2016-03-11 10:32:01 -08002438
2439$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex)
2440$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk)
Colin Cross7363cde2018-09-14 21:51:11 -07002441$(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP)
2442# dependencies for the other partitions are defined below after their file lists
2443# are known
Colin Crossd60401a2019-04-18 14:46:48 -07002444$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_classes_dex) $(pdk_odex_config_mk) $(API_FINGERPRINT)
Keun young Park816b9fd2012-05-16 10:32:41 -07002445 $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)")
Colin Cross7363cde2018-09-14 21:51:11 -07002446 rm -f $@ $@.lst
2447 echo "-C $(PRODUCT_OUT)" >> $@.lst
2448 echo "-D $(TARGET_OUT)" >> $@.lst
2449 echo "-D $(TARGET_OUT_NOTICE_FILES)" >> $@.lst
2450 echo "$(addprefix -f $(TARGET_OUT_UNSTRIPPED)/,$(PDK_SYMBOL_FILES_LIST))" >> $@.lst
Dan Willemsen67495202019-01-16 12:42:05 -08002451ifdef BUILDING_VENDOR_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002452 echo "-D $(TARGET_OUT_VENDOR)" >> $@.lst
Ying Wangcff38622014-07-16 17:46:35 -07002453endif
Dan Willemsen67495202019-01-16 12:42:05 -08002454ifdef BUILDING_PRODUCT_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002455 echo "-D $(TARGET_OUT_PRODUCT)" >> $@.lst
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002456endif
Justin Yun6151e3f2019-06-25 15:58:13 +09002457ifdef BUILDING_SYSTEM_EXT_IMAGE
2458 echo "-D $(TARGET_OUT_SYSTEM_EXT)" >> $@.lst
Dario Freni5f681e12018-05-29 13:09:01 +01002459endif
Dan Willemsen67495202019-01-16 12:42:05 -08002460ifdef BUILDING_ODM_IMAGE
Colin Cross7363cde2018-09-14 21:51:11 -07002461 echo "-D $(TARGET_OUT_ODM)" >> $@.lst
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002462endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07002463ifdef BUILDING_VENDOR_DLKM_IMAGE
2464 echo "-D $(TARGET_OUT_VENDOR_DLKM)" >> $@.lst
2465endif
Colin Crossc451a372013-12-18 19:36:44 -08002466ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),)
Colin Cross7363cde2018-09-14 21:51:11 -07002467 echo "-C $(OUT_DIR)" >> $@.lst
2468 for f in $(filter-out $(PRIVATE_DEX_FILES),$(addprefix -f $(OUT_DIR)/,$(PDK_PLATFORM_JAVA_ZIP_CONTENTS))); do \
2469 if [ -e $$f ]; then \
2470 echo "-f $$f"; \
2471 fi \
2472 done >> $@.lst
Keun young Park816b9fd2012-05-16 10:32:41 -07002473endif
keunyoungc0178062013-07-22 14:54:58 -07002474ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),)
Colin Cross7363cde2018-09-14 21:51:11 -07002475 echo "-C . $(addprefix -f ,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES))" >> $@.lst
keunyoungc0178062013-07-22 14:54:58 -07002476endif
Ying Wang3a61eeb2016-03-11 10:32:01 -08002477 @# Add dex-preopt files and config.
Colin Cross7363cde2018-09-14 21:51:11 -07002478 $(if $(PRIVATE_DEX_FILES),\
2479 echo "-C $(OUT_DIR) $(addprefix -f ,$(PRIVATE_DEX_FILES))") >> $@.lst
Colin Crossd60401a2019-04-18 14:46:48 -07002480 echo "-C $(dir $(API_FINGERPRINT)) -f $(API_FINGERPRINT)" >> $@.lst
Colin Cross7363cde2018-09-14 21:51:11 -07002481 touch $(PRODUCT_OUT)/pdk.mk
2482 echo "-C $(PRODUCT_OUT) -f $(PRIVATE_ODEX_CONFIG) -f $(PRODUCT_OUT)/pdk.mk" >> $@.lst
2483 $(SOONG_ZIP) --ignore_missing_files -o $@ @$@.lst
Ying Wang4c289e52012-03-30 13:52:54 -07002484
2485.PHONY: platform
Keun young Park816b9fd2012-05-16 10:32:41 -07002486platform: $(INSTALLED_PLATFORM_ZIP)
2487
2488.PHONY: platform-java
2489platform-java: platform
Ying Wang4c289e52012-03-30 13:52:54 -07002490
2491# Dist the platform.zip
Keun young Park3e93aea2012-05-29 17:55:46 -07002492ifneq (,$(filter platform platform-java, $(MAKECMDGOALS)))
2493$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP))
Ying Wang4c289e52012-03-30 13:52:54 -07002494endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08002495
Colin Cross53c8f972018-09-28 16:19:42 -07002496endif # BUILD_PLATFORM_ZIP
2497
Ying Wang3a61eeb2016-03-11 10:32:01 -08002498# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08002499# data partition image
2500INTERNAL_USERDATAIMAGE_FILES := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002501 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002502
Dan Willemsen67495202019-01-16 12:42:05 -08002503ifdef BUILDING_USERDATA_IMAGE
Ying Wangbd93d422011-10-28 17:02:30 -07002504userdataimage_intermediates := \
Ying Wang9f8e8db2011-11-04 11:37:01 -07002505 $(call intermediates-dir-for,PACKAGING,userdata)
Joe Onorato64d85d02009-04-09 19:31:12 -07002506BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
2507
Ying Wangbd93d422011-10-28 17:02:30 -07002508define build-userdataimage-target
2509 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
2510 @mkdir -p $(TARGET_OUT_DATA)
2511 @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002512 $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002513 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002514 $(BUILD_IMAGE) \
2515 $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
2516 $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
2517 $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
Ying Wangbd93d422011-10-28 17:02:30 -07002518endef
2519
Joe Onorato64d85d02009-04-09 19:31:12 -07002520# We just build this directly to the install location.
2521INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002522INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
2523 $(INTERNAL_USERIMAGES_DEPS) \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002524 $(INTERNAL_USERDATAIMAGE_FILES)
Andreas Gampe039b5c72017-03-24 16:06:31 -07002525$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002526 $(build-userdataimage-target)
2527
2528.PHONY: userdataimage-nodeps
Colin Cross144b0282010-05-10 13:04:47 -07002529userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08002530 $(build-userdataimage-target)
2531
Dan Willemsen67495202019-01-16 12:42:05 -08002532endif # BUILDING_USERDATA_IMAGE
Ying Wange215ed52012-10-15 14:36:22 -07002533
Andreas Gampe039b5c72017-03-24 16:06:31 -07002534# ASAN libraries in the system image - build rule.
2535ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
2536 $(TARGET_OUT_SHARED_LIBRARIES) \
2537 $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
2538 $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
2539 $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
Andreas Gampe2c498a32017-03-30 16:54:23 -07002540# Extra options: Enforce the system user for the files to avoid having to change ownership.
2541ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
Andreas Gampe039b5c72017-03-24 16:06:31 -07002542# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
2543# enough space.
2544$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
Andreas Gampe2c498a32017-03-30 16:54:23 -07002545 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 -07002546
The Android Open Source Project88b60792009-03-03 19:28:42 -08002547# -----------------------------------------------------------------
David Zeuthen25328622016-04-08 15:08:03 -04002548# partition table image
2549ifdef BOARD_BPT_INPUT_FILES
2550
2551BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002552BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
David Zeuthen25328622016-04-08 15:08:03 -04002553
2554INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
2555 --output_gpt $(BUILT_BPTIMAGE_TARGET) \
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002556 --output_json $(BUILT_BPTJSON_TARGET) \
David Zeuthen25328622016-04-08 15:08:03 -04002557 $(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
2558
2559ifdef BOARD_BPT_DISK_SIZE
2560INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
2561endif
2562
2563define build-bptimage-target
2564 $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
2565 $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
2566endef
2567
2568INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
Casey Dahlin04d15dd2016-08-19 10:59:57 -07002569$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
2570 $(hide) touch -c $(BUILT_BPTJSON_TARGET)
2571
David Zeuthen25328622016-04-08 15:08:03 -04002572$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
2573 $(build-bptimage-target)
2574
2575.PHONY: bptimage-nodeps
2576bptimage-nodeps:
2577 $(build-bptimage-target)
2578
2579endif # BOARD_BPT_INPUT_FILES
2580
2581# -----------------------------------------------------------------
Ying Wang9f8e8db2011-11-04 11:37:01 -07002582# cache partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002583ifdef BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002584INTERNAL_CACHEIMAGE_FILES := \
2585 $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
2586
2587cacheimage_intermediates := \
2588 $(call intermediates-dir-for,PACKAGING,cache)
2589BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
2590
2591define build-cacheimage-target
2592 $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
2593 @mkdir -p $(TARGET_OUT_CACHE)
2594 @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002595 $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002596 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002597 $(BUILD_IMAGE) \
2598 $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
2599 $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
2600 $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
Ying Wang9f8e8db2011-11-04 11:37:01 -07002601endef
2602
2603# We just build this directly to the install location.
2604INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002605$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
Ying Wang9f8e8db2011-11-04 11:37:01 -07002606 $(build-cacheimage-target)
2607
2608.PHONY: cacheimage-nodeps
2609cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2610 $(build-cacheimage-target)
2611
Dan Willemsen67495202019-01-16 12:42:05 -08002612else # BUILDING_CACHE_IMAGE
Patrick Tjinf3b0dc22016-05-13 15:26:09 -07002613# we need to ignore the broken cache link when doing the rsync
2614IGNORE_CACHE_LINK := --exclude=cache
Dan Willemsen67495202019-01-16 12:42:05 -08002615endif # BUILDING_CACHE_IMAGE
Ying Wang9f8e8db2011-11-04 11:37:01 -07002616
David Zeuthen0eb10972016-09-28 17:55:27 -04002617# -----------------------------------------------------------------
Alex Light4e358ab2016-06-16 14:47:10 -07002618# system_other partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002619ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002620ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
Alex Light4e358ab2016-06-16 14:47:10 -07002621# Marker file to identify that odex files are installed
2622INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
2623ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
2624$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
2625 $(hide) touch $@
2626endif
2627
Alex Light4e358ab2016-06-16 14:47:10 -07002628INTERNAL_SYSTEMOTHERIMAGE_FILES := \
2629 $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
2630 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002631 $(ALL_PDK_FUSION_FILES)) \
2632 $(PDK_FUSION_SYMLINK_STAMP)
Alex Light4e358ab2016-06-16 14:47:10 -07002633
Colin Cross6db5b0e2018-11-16 21:26:33 -08002634# system_other dex files are installed as a side-effect of installing system image files
2635INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
2636
Alex Light4e358ab2016-06-16 14:47:10 -07002637INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
Colin Cross23dded02018-06-13 14:04:22 -07002638INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
2639$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002640$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Alex Light4e358ab2016-06-16 14:47:10 -07002641 @echo Installed file list: $@
2642 @mkdir -p $(dir $@)
2643 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002644 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002645 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Alex Light4e358ab2016-06-16 14:47:10 -07002646
Bowgo Tsai867ab662019-01-29 13:30:18 +08002647# Determines partition size for system_other.img.
2648ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
2649ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
2650INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
2651endif
2652endif
2653
2654ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
2655INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
2656endif
2657
Alex Light4e358ab2016-06-16 14:47:10 -07002658systemotherimage_intermediates := \
2659 $(call intermediates-dir-for,PACKAGING,system_other)
2660BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
2661
2662# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
2663define build-systemotherimage-target
2664 $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
2665 @mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
2666 @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002667 $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002668 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002669 $(BUILD_IMAGE) \
2670 $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
2671 $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
2672 $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
Alex Light4e358ab2016-06-16 14:47:10 -07002673endef
2674
2675# We just build this directly to the install location.
2676INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002677ifneq (true,$(SANITIZE_LITE))
2678# Only create system_other when not building the second stage of a SANITIZE_LITE build.
Alex Light4e358ab2016-06-16 14:47:10 -07002679$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER)
2680 $(build-systemotherimage-target)
Andreas Gampe4ed21d12017-06-16 10:24:54 -07002681endif
Alex Light4e358ab2016-06-16 14:47:10 -07002682
2683.PHONY: systemotherimage-nodeps
2684systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
2685 $(build-systemotherimage-target)
2686
Dan Willemsen67495202019-01-16 12:42:05 -08002687endif # BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07002688
2689
2690# -----------------------------------------------------------------
Ying Wanga0febe52013-03-20 11:02:05 -07002691# vendor partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002692ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07002693INTERNAL_VENDORIMAGE_FILES := \
Ying Wangcff38622014-07-16 17:46:35 -07002694 $(filter $(TARGET_OUT_VENDOR)/%,\
2695 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002696 $(ALL_PDK_FUSION_FILES)) \
2697 $(PDK_FUSION_SYMLINK_STAMP)
Ying Wangcff38622014-07-16 17:46:35 -07002698
2699# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES).
2700$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
Ying Wanga0febe52013-03-20 11:02:05 -07002701
Ying Wang8da19e32015-09-15 14:22:12 -07002702INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
Colin Cross23dded02018-06-13 14:04:22 -07002703INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
2704$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002705$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Ying Wang8da19e32015-09-15 14:22:12 -07002706 @echo Installed file list: $@
2707 @mkdir -p $(dir $@)
2708 @rm -f $@
Makoto Onuki9fe97e22017-03-16 09:41:19 -07002709 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002710 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Ying Wang8da19e32015-09-15 14:22:12 -07002711
Bill Peckham1f9b8f02019-07-03 15:58:48 -07002712# Create symlink /vendor/odm to /odm if necessary.
2713ifdef BOARD_USES_ODMIMAGE
2714define create-vendor-odm-symlink
2715$(hide) if [ -d $(TARGET_OUT_VENDOR)/odm ] && [ ! -h $(TARGET_OUT_VENDOR)/odm ]; then \
2716 echo 'Non-symlink $(TARGET_OUT_VENDOR)/odm detected!' 1>&2; \
2717 echo 'You cannot install files to $(TARGET_OUT_VENDOR)/odm while building a separate odm.img!' 1>&2; \
2718 exit 1; \
2719fi
2720$(hide) ln -sf /odm $(TARGET_OUT_VENDOR)/odm
2721endef
2722else
2723define create-vendor-odm-symlink
2724endef
2725endif
2726
Ying Wanga0febe52013-03-20 11:02:05 -07002727vendorimage_intermediates := \
2728 $(call intermediates-dir-for,PACKAGING,vendor)
2729BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
Ying Wanga0febe52013-03-20 11:02:05 -07002730define build-vendorimage-target
2731 $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
2732 @mkdir -p $(TARGET_OUT_VENDOR)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002733 $(call create-vendor-odm-symlink)
Ying Wanga0febe52013-03-20 11:02:05 -07002734 @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002735 $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002736 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002737 $(BUILD_IMAGE) \
2738 $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
2739 $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
Yifan Hong9a3cad92020-04-27 19:06:59 -07002740 $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
Ying Wanga0febe52013-03-20 11:02:05 -07002741endef
2742
2743# We just build this directly to the install location.
2744INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002745$(INSTALLED_VENDORIMAGE_TARGET): \
2746 $(INTERNAL_USERIMAGES_DEPS) \
2747 $(INTERNAL_VENDORIMAGE_FILES) \
Yifan Hong9a3cad92020-04-27 19:06:59 -07002748 $(INSTALLED_FILES_FILE_VENDOR) \
2749 $(RECOVERY_FROM_BOOT_PATCH)
Ying Wanga0febe52013-03-20 11:02:05 -07002750 $(build-vendorimage-target)
2751
Steven Morelanda2e734d2017-03-07 12:10:09 -08002752.PHONY: vendorimage-nodeps vnod
Colin Cross4f60e362019-06-05 11:53:43 -07002753vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS)
Ying Wanga0febe52013-03-20 11:02:05 -07002754 $(build-vendorimage-target)
2755
Colin Cross91a52272017-06-20 16:57:52 -07002756sync: $(INTERNAL_VENDORIMAGE_FILES)
2757
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07002758else ifdef BOARD_PREBUILT_VENDORIMAGE
2759INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
2760$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
2761endif
Ying Wanga0febe52013-03-20 11:02:05 -07002762
Ying Wang9f8e8db2011-11-04 11:37:01 -07002763# -----------------------------------------------------------------
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002764# product partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002765ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002766INTERNAL_PRODUCTIMAGE_FILES := \
2767 $(filter $(TARGET_OUT_PRODUCT)/%,\
2768 $(ALL_DEFAULT_INSTALLED_MODULES)\
Dan Willemsen0663f682018-03-06 14:07:21 -08002769 $(ALL_PDK_FUSION_FILES)) \
2770 $(PDK_FUSION_SYMLINK_STAMP)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002771
2772# platform.zip depends on $(INTERNAL_PRODUCTIMAGE_FILES).
2773$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_PRODUCTIMAGE_FILES)
2774
2775INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
Colin Cross23dded02018-06-13 14:04:22 -07002776INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
2777$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002778$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002779 @echo Installed file list: $@
2780 @mkdir -p $(dir $@)
2781 @rm -f $@
2782 $(hide) $(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002783 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002784
2785productimage_intermediates := \
2786 $(call intermediates-dir-for,PACKAGING,product)
2787BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2788define build-productimage-target
2789 $(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
2790 @mkdir -p $(TARGET_OUT_PRODUCT)
2791 @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
Yifan Hong760d3c02018-05-30 11:16:46 -07002792 $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002793 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002794 $(BUILD_IMAGE) \
2795 $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
2796 $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
2797 $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002798endef
2799
2800# We just build this directly to the install location.
2801INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002802$(INSTALLED_PRODUCTIMAGE_TARGET): \
2803 $(INTERNAL_USERIMAGES_DEPS) \
2804 $(INTERNAL_PRODUCTIMAGE_FILES) \
2805 $(INSTALLED_FILES_FILE_PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09002806 $(build-productimage-target)
2807
2808.PHONY: productimage-nodeps pnod
2809productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS)
2810 $(build-productimage-target)
2811
2812sync: $(INTERNAL_PRODUCTIMAGE_FILES)
2813
2814else ifdef BOARD_PREBUILT_PRODUCTIMAGE
2815INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
2816$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
2817endif
2818
2819# -----------------------------------------------------------------
Justin Yun6151e3f2019-06-25 15:58:13 +09002820# system_ext partition image
2821ifdef BUILDING_SYSTEM_EXT_IMAGE
2822INTERNAL_SYSTEM_EXTIMAGE_FILES := \
2823 $(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
Dario Freni5f681e12018-05-29 13:09:01 +01002824 $(ALL_DEFAULT_INSTALLED_MODULES)\
2825 $(ALL_PDK_FUSION_FILES)) \
2826 $(PDK_FUSION_SYMLINK_STAMP)
2827
Justin Yun6151e3f2019-06-25 15:58:13 +09002828# platform.zip depends on $(INTERNAL_SYSTEM_EXTIMAGE_FILES).
2829$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002830
Justin Yun6151e3f2019-06-25 15:58:13 +09002831INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
2832INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
2833$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
2834$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Dario Freni5f681e12018-05-29 13:09:01 +01002835 @echo Installed file list: $@
2836 @mkdir -p $(dir $@)
2837 @rm -f $@
Justin Yun6151e3f2019-06-25 15:58:13 +09002838 $(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002839 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Dario Freni5f681e12018-05-29 13:09:01 +01002840
Justin Yun6151e3f2019-06-25 15:58:13 +09002841system_extimage_intermediates := \
2842 $(call intermediates-dir-for,PACKAGING,system_ext)
2843BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2844define build-system_extimage-target
2845 $(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
2846 @mkdir -p $(TARGET_OUT_SYSTEM_EXT)
2847 @mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
2848 $(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 -07002849 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002850 $(BUILD_IMAGE) \
2851 $(TARGET_OUT_SYSTEM_EXT) \
2852 $(system_extimage_intermediates)/system_ext_image_info.txt \
2853 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
2854 $(TARGET_OUT)
2855 $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
Dario Freni5f681e12018-05-29 13:09:01 +01002856endef
2857
2858# We just build this directly to the install location.
Justin Yun6151e3f2019-06-25 15:58:13 +09002859INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002860$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
2861 $(INTERNAL_USERIMAGES_DEPS) \
2862 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
2863 $(INSTALLED_FILES_FILE_SYSTEM_EXT)
Justin Yun6151e3f2019-06-25 15:58:13 +09002864 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002865
Justin Yun6151e3f2019-06-25 15:58:13 +09002866.PHONY: systemextimage-nodeps senod
2867systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS)
2868 $(build-system_extimage-target)
Dario Freni5f681e12018-05-29 13:09:01 +01002869
Justin Yun6151e3f2019-06-25 15:58:13 +09002870sync: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
Dario Freni5f681e12018-05-29 13:09:01 +01002871
Justin Yun6151e3f2019-06-25 15:58:13 +09002872else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
2873INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
2874$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
Dario Freni5f681e12018-05-29 13:09:01 +01002875endif
2876
2877# -----------------------------------------------------------------
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002878# odm partition image
Dan Willemsen67495202019-01-16 12:42:05 -08002879ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002880INTERNAL_ODMIMAGE_FILES := \
2881 $(filter $(TARGET_OUT_ODM)/%,\
2882 $(ALL_DEFAULT_INSTALLED_MODULES)\
2883 $(ALL_PDK_FUSION_FILES)) \
2884 $(PDK_FUSION_SYMLINK_STAMP)
2885# platform.zip depends on $(INTERNAL_ODMIMAGE_FILES).
2886$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_ODMIMAGE_FILES)
2887
2888INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
2889INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
2890$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002891$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002892 @echo Installed file list: $@
2893 @mkdir -p $(dir $@)
2894 @rm -f $@
2895 $(hide) $(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
Dan Willemsenc84e4cb2019-06-10 16:39:45 -07002896 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002897
2898odmimage_intermediates := \
2899 $(call intermediates-dir-for,PACKAGING,odm)
2900BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2901define build-odmimage-target
2902 $(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
2903 @mkdir -p $(TARGET_OUT_ODM)
2904 @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
2905 $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true)
Tao Baocf821fc2019-06-24 12:39:10 -07002906 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao2bbb07c2019-05-07 13:12:21 -07002907 $(BUILD_IMAGE) \
2908 $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
2909 $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
2910 $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002911endef
2912
2913# We just build this directly to the install location.
2914INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
Tao Bao2bbb07c2019-05-07 13:12:21 -07002915$(INSTALLED_ODMIMAGE_TARGET): \
2916 $(INTERNAL_USERIMAGES_DEPS) \
2917 $(INTERNAL_ODMIMAGE_FILES) \
2918 $(INSTALLED_FILES_FILE_ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002919 $(build-odmimage-target)
2920
2921.PHONY: odmimage-nodeps onod
Colin Cross4f60e362019-06-05 11:53:43 -07002922odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08002923 $(build-odmimage-target)
2924
2925sync: $(INTERNAL_ODMIMAGE_FILES)
2926
2927else ifdef BOARD_PREBUILT_ODMIMAGE
2928INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
2929$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
2930endif
2931
2932# -----------------------------------------------------------------
Yifan Hongcfb917a2020-05-07 14:58:20 -07002933# vendor_dlkm partition image
2934ifdef BUILDING_VENDOR_DLKM_IMAGE
2935INTERNAL_VENDOR_DLKMIMAGE_FILES := \
2936 $(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
2937 $(ALL_DEFAULT_INSTALLED_MODULES)\
2938 $(ALL_PDK_FUSION_FILES)) \
2939 $(PDK_FUSION_SYMLINK_STAMP)
2940# platform.zip depends on $(INTERNAL_VENDOR_DLKMIMAGE_FILES).
2941$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2942
2943INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
2944INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
2945$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
2946$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
2947 @echo Installed file list: $@
2948 @mkdir -p $(dir $@)
2949 @rm -f $@
2950 $(hide) $(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
2951 $(hide) $(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
2952
2953vendor_dlkmimage_intermediates := \
2954 $(call intermediates-dir-for,PACKAGING,vendor_dlkm)
2955BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2956define build-vendor_dlkmimage-target
2957 $(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
2958 @mkdir -p $(TARGET_OUT_VENDOR_DLKM)
2959 @mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
2960 $(call generate-userimage-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, skip_fsck=true)
2961 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
2962 $(BUILD_IMAGE) \
2963 $(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
2964 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
2965 $(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
2966endef
2967
2968# We just build this directly to the install location.
2969INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
2970$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
2971 $(INTERNAL_USERIMAGES_DEPS) \
2972 $(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
2973 $(INSTALLED_FILES_FILE_VENDOR_DLKM)
2974 $(build-vendor_dlkmimage-target)
2975
2976.PHONY: vendor_dlkmimage-nodeps vdnod
2977vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS)
2978 $(build-vendor_dlkmimage-target)
2979
2980sync: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
2981
2982else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
2983INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
2984$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
2985endif
2986
2987# -----------------------------------------------------------------
Yueyao Zhu211c9012017-04-27 00:34:50 -07002988# dtbo image
2989ifdef BOARD_PREBUILT_DTBOIMAGE
2990INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
2991
2992ifeq ($(BOARD_AVB_ENABLE),true)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08002993$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
Yueyao Zhu211c9012017-04-27 00:34:50 -07002994 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
2995 $(AVBTOOL) add_hash_footer \
Anton Hansson6d814982018-11-26 18:12:05 +00002996 --image $@ \
2997 --partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
2998 --partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
2999 $(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
Yueyao Zhu211c9012017-04-27 00:34:50 -07003000else
3001$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
3002 cp $(BOARD_PREBUILT_DTBOIMAGE) $@
3003endif
3004
Tao Bao0da43472018-08-22 22:53:41 -07003005endif # BOARD_PREBUILT_DTBOIMAGE
3006
3007# Returns a list of image targets corresponding to the given list of partitions. For example, it
3008# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
3009# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
Justin Yun6151e3f2019-06-25 15:58:13 +09003010# (1): list of partitions like "system", "vendor" or "system product system_ext".
Tao Bao0da43472018-08-22 22:53:41 -07003011define images-for-partitions
3012$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))
3013endef
Yueyao Zhu211c9012017-04-27 00:34:50 -07003014
3015# -----------------------------------------------------------------
Hongguang Chenf23364d2020-04-27 18:36:36 -07003016# custom images
3017INSTALLED_CUSTOMIMAGES_TARGET :=
3018
3019ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3020INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
3021
3022# Sign custom image.
3023# $(1): the prebuilt custom image.
3024# $(2): the mount point of the prebuilt custom image.
3025# $(3): the signed custom image target.
3026define sign_custom_image
3027$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
3028 @echo Target custom image: $(3)
3029 mkdir -p $(dir $(3))
3030 cp $(1) $(3)
3031ifeq ($(BOARD_AVB_ENABLE),true)
3032 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
3033 $(AVBTOOL) add_hashtree_footer \
3034 --image $(3) \
3035 --key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
3036 --algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
3037 --partition_size $(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE) \
3038 --partition_name $(2) \
3039 $(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
3040 $(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
3041endif
3042INSTALLED_CUSTOMIMAGES_TARGET += $(3)
3043endef
3044
3045$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3046 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
3047 $(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
3048endif
3049
3050# -----------------------------------------------------------------
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003051# vbmeta image
3052ifeq ($(BOARD_AVB_ENABLE),true)
3053
3054BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003055AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003056
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003057ifdef BOARD_AVB_KEY_PATH
3058$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
3059else
3060# If key path isn't specified, use the 4096-bit test key.
3061BOARD_AVB_ALGORITHM := SHA256_RSA4096
3062BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
3063endif
3064
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003065# AVB signing for system_other.img.
3066ifdef BUILDING_SYSTEM_OTHER_IMAGE
3067ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
3068$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
3069else
3070# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
3071BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
3072BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
3073endif
3074
Bowgo Tsaie4544b12019-02-27 10:15:51 +08003075$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
3076 @echo Extracting system_other avb key: $@
3077 @rm -f $@
3078 @mkdir -p $(dir $@)
3079 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
Bowgo Tsai45db7ce2019-01-30 14:53:57 +08003080
Bowgo Tsai1e04bf72019-01-23 22:19:19 +08003081ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
3082BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
3083endif
3084
3085BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
3086endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
3087
Tao Bao744c4c72018-08-20 21:09:07 -07003088INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
David Anderson7709ab22018-10-15 14:41:34 -07003089 $(BOARD_AVB_VBMETA_SYSTEM) \
Tao Bao744c4c72018-08-20 21:09:07 -07003090 $(BOARD_AVB_VBMETA_VENDOR)
3091
3092# Not allowing the same partition to appear in multiple groups.
3093ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
David Anderson7709ab22018-10-15 14:41:34 -07003094 $(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
Tao Bao744c4c72018-08-20 21:09:07 -07003095endif
3096
cfig1aeef722019-09-20 22:45:06 +08003097# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
3098# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
3099# details.
Yifan Hong65afc072020-04-17 10:08:10 -07003100ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
cfig1aeef722019-09-20 22:45:06 +08003101ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3102$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
Yifan Hong65afc072020-04-17 10:08:10 -07003103 $(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
cfig1aeef722019-09-20 22:45:06 +08003104 See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
3105endif
3106endif
3107
Bowgo Tsai9b548012019-05-14 16:57:03 +08003108# Appends os version and security patch level as a AVB property descriptor
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003109
3110BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003111 --prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003112 --prop com.android.build.system.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003113 --prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
3114
3115BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003116 --prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003117 --prop com.android.build.product.os_version:$(PLATFORM_VERSION) \
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003118 --prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
3119
Justin Yun6151e3f2019-06-25 15:58:13 +09003120BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003121 --prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003122 --prop com.android.build.system_ext.os_version:$(PLATFORM_VERSION) \
3123 --prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003124
Bowgo Tsai9b548012019-05-14 16:57:03 +08003125BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003126 --prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003127 --prop com.android.build.boot.os_version:$(PLATFORM_VERSION)
3128
Tao Bao19b02fe2019-10-09 00:04:28 -07003129BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
3130 --prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3131
3132BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
3133 --prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3134
Bowgo Tsai9b548012019-05-14 16:57:03 +08003135BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003136 --prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003137 --prop com.android.build.vendor.os_version:$(PLATFORM_VERSION)
3138
3139BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
Tao Bao19b02fe2019-10-09 00:04:28 -07003140 --prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
Bowgo Tsai9b548012019-05-14 16:57:03 +08003141 --prop com.android.build.odm.os_version:$(PLATFORM_VERSION)
3142
Yifan Hongcfb917a2020-05-07 14:58:20 -07003143BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3144 --prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
3145 --prop com.android.build.vendor_dlkm.os_version:$(PLATFORM_VERSION_LAST_STABLE)
3146
Tao Bao19b02fe2019-10-09 00:04:28 -07003147BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
3148 --prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
3149
Bowgo Tsai9b548012019-05-14 16:57:03 +08003150# The following vendor- and odm-specific images needs explicit SPL set per board.
Bowgo Tsaicca76dd2019-01-30 21:52:32 +08003151ifdef BOOT_SECURITY_PATCH
3152BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
3153 --prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
3154endif
3155
3156ifdef VENDOR_SECURITY_PATCH
3157BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
3158 --prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
3159endif
3160
3161ifdef ODM_SECURITY_PATCH
3162BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
3163 --prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
3164endif
3165
Yifan Hongcfb917a2020-05-07 14:58:20 -07003166ifdef VENDOR_DLKM_SECURITY_PATCH
3167BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
3168 --prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
3169endif
3170
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003171BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
Steve Mucklee1b10862019-07-10 10:49:37 -07003172VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003173DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
3174SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
3175VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
David Zeuthen8fecb282017-12-01 16:24:01 -05003176RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003177PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
Justin Yun6151e3f2019-06-25 15:58:13 +09003178SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003179ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
Yifan Hongcfb917a2020-05-07 14:58:20 -07003180VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003181
Tao Bao0da43472018-08-22 22:53:41 -07003182# Helper function that checks and sets required build variables for an AVB chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003183# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
Tao Bao0da43472018-08-22 22:53:41 -07003184define _check-and-set-avb-chain-args
3185$(eval part := $(1))
3186$(eval PART=$(call to-upper,$(part)))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003187
3188$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
3189$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
3190$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
3191$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3192$(if $($(_key_path)),,$(error $(_key_path) is not defined))
3193$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
3194$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
3195$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3196
3197# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
3198$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
3199$(eval $(_signing_args) := \
3200 --algorithm $($(_signing_algorithm)) --key $($(_key_path)))
3201
cfig1aeef722019-09-20 22:45:06 +08003202# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
3203# partition descriptor for recovery partition into vbmeta.img.
Yifan Hong65afc072020-04-17 10:08:10 -07003204$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
cfig1aeef722019-09-20 22:45:06 +08003205 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3206 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003207
Tao Bao744c4c72018-08-20 21:09:07 -07003208# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
David Anderson7709ab22018-10-15 14:41:34 -07003209# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
Tao Bao744c4c72018-08-20 21:09:07 -07003210$(if $(filter $(part),$(part:vbmeta_%=%)),\
3211 $(eval _footer_args := $(PART)_FOOTER_ARGS) \
3212 $(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003213endef
3214
Tao Bao0da43472018-08-22 22:53:41 -07003215# Checks and sets the required build variables for an AVB partition. The partition will be
3216# configured as a chained partition, if BOARD_AVB_<partition>_KEY_PATH is defined. Otherwise the
Tao Bao744c4c72018-08-20 21:09:07 -07003217# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
3218# VBMeta image.
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003219# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
3220# but vbmeta would capture the image descriptor of only the first boot
3221# image specified in BUILT_BOOTIMAGE_TARGET.
Tao Bao0da43472018-08-22 22:53:41 -07003222# $(1): Partition name, e.g. boot or system.
3223define check-and-set-avb-args
Tao Bao744c4c72018-08-20 21:09:07 -07003224$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
Tao Bao0da43472018-08-22 22:53:41 -07003225$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
Tao Bao744c4c72018-08-20 21:09:07 -07003226 $(if $(_in_chained_vbmeta),\
3227 $(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
Tao Bao0da43472018-08-22 22:53:41 -07003228 $(call _check-and-set-avb-chain-args,$(1)),\
Tao Bao744c4c72018-08-20 21:09:07 -07003229 $(if $(_in_chained_vbmeta),,\
Roopesh Nataraja3e15f6e2020-06-08 19:54:13 -07003230 $(if $(filter boot,$(1)),\
3231 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3232 --include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
3233 $(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3234 --include_descriptors_from_image $(call images-for-partitions,$(1))))))
Tao Bao0da43472018-08-22 22:53:41 -07003235endef
3236
Hongguang Chenf23364d2020-04-27 18:36:36 -07003237# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
3238# $(1): the custom partition to enable AVB chain.
3239define check-and-set-custom-avb-chain-args
3240$(eval part := $(1))
3241$(eval PART=$(call to-upper,$(part)))
3242$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
3243$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
3244
3245INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
3246 --chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
3247endef
3248
Tao Baob1a2e352018-08-14 16:17:12 -07003249ifdef INSTALLED_BOOTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003250$(eval $(call check-and-set-avb-args,boot))
Tao Baob1a2e352018-08-14 16:17:12 -07003251endif
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003252
Steve Mucklee1b10862019-07-10 10:49:37 -07003253ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
3254$(eval $(call check-and-set-avb-args,vendor_boot))
3255endif
3256
Tao Bao0da43472018-08-22 22:53:41 -07003257$(eval $(call check-and-set-avb-args,system))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003258
3259ifdef INSTALLED_VENDORIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003260$(eval $(call check-and-set-avb-args,vendor))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003261endif
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003262
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003263ifdef INSTALLED_PRODUCTIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003264$(eval $(call check-and-set-avb-args,product))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003265endif
3266
Justin Yun6151e3f2019-06-25 15:58:13 +09003267ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
3268$(eval $(call check-and-set-avb-args,system_ext))
Tao Baocee6d042018-08-22 23:39:03 -07003269endif
3270
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003271ifdef INSTALLED_ODMIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003272$(eval $(call check-and-set-avb-args,odm))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003273endif
3274
Yifan Hongcfb917a2020-05-07 14:58:20 -07003275ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
3276$(eval $(call check-and-set-avb-args,vendor_dlkm))
3277endif
3278
Yueyao Zhu211c9012017-04-27 00:34:50 -07003279ifdef INSTALLED_DTBOIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003280$(eval $(call check-and-set-avb-args,dtbo))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003281endif
Yueyao Zhu211c9012017-04-27 00:34:50 -07003282
David Zeuthen8fecb282017-12-01 16:24:01 -05003283ifdef INSTALLED_RECOVERYIMAGE_TARGET
Tao Bao0da43472018-08-22 22:53:41 -07003284$(eval $(call check-and-set-avb-args,recovery))
David Zeuthen8fecb282017-12-01 16:24:01 -05003285endif
Bowgo Tsai53cf9992017-06-13 11:27:06 +08003286
David Anderson7709ab22018-10-15 14:41:34 -07003287# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
3288ifdef BOARD_AVB_VBMETA_SYSTEM
3289$(eval $(call check-and-set-avb-args,vbmeta_system))
Tao Bao744c4c72018-08-20 21:09:07 -07003290endif
3291
3292ifdef BOARD_AVB_VBMETA_VENDOR
3293$(eval $(call check-and-set-avb-args,vbmeta_vendor))
3294endif
3295
Hongguang Chenf23364d2020-04-27 18:36:36 -07003296ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
3297$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3298 $(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
3299endif
3300
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003301# Add kernel cmdline descriptor for kernel to mount system.img as root with
3302# dm-verity. This works when system.img is either chained or not-chained:
3303# - chained: The --setup_as_rootfs_from_kernel option will add dm-verity kernel
3304# cmdline descriptor to system.img
3305# - not-chained: The --include_descriptors_from_image option for make_vbmeta_image
3306# will include the kernel cmdline descriptor from system.img into vbmeta.img
Bowgo Tsai9b377602017-04-14 18:50:11 +08003307ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
David Anderson8916a2a2018-09-18 15:46:59 -07003308ifeq ($(filter system, $(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003309BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += --setup_as_rootfs_from_kernel
Bowgo Tsai9b377602017-04-14 18:50:11 +08003310endif
David Anderson8916a2a2018-09-18 15:46:59 -07003311endif
Bowgo Tsai9b377602017-04-14 18:50:11 +08003312
Tao Bao0da43472018-08-22 22:53:41 -07003313BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
David Anderson7709ab22018-10-15 14:41:34 -07003314BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
Tao Bao744c4c72018-08-20 21:09:07 -07003315BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
3316
3317ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
Tao Bao240dcb82018-10-22 13:02:53 -07003318# We only need the flag in top-level vbmeta.img.
Tao Bao744c4c72018-08-20 21:09:07 -07003319BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
Tao Bao744c4c72018-08-20 21:09:07 -07003320endif
Tao Bao0da43472018-08-22 22:53:41 -07003321
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003322ifdef BOARD_AVB_ROLLBACK_INDEX
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003323BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003324endif
3325
David Anderson7709ab22018-10-15 14:41:34 -07003326ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
3327BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
3328 --rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
Tao Bao744c4c72018-08-20 21:09:07 -07003329endif
3330
3331ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
3332BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
3333 --rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
John Reck0588b432018-05-03 13:20:01 -07003334endif
3335
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003336# $(1): the directory to extract public keys to
3337define extract-avb-chain-public-keys
3338 $(if $(BOARD_AVB_BOOT_KEY_PATH),\
3339 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
3340 --output $(1)/boot.avbpubkey)
Steve Mucklee1b10862019-07-10 10:49:37 -07003341 $(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
3342 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
3343 --output $(1)/vendor_boot.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003344 $(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
3345 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
3346 --output $(1)/system.avbpubkey)
3347 $(if $(BOARD_AVB_VENDOR_KEY_PATH),\
3348 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
3349 --output $(1)/vendor.avbpubkey)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09003350 $(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
3351 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
3352 --output $(1)/product.avbpubkey)
Justin Yun6151e3f2019-06-25 15:58:13 +09003353 $(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
3354 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
3355 --output $(1)/system_ext.avbpubkey)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08003356 $(if $(BOARD_AVB_ODM_KEY_PATH),\
3357 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
3358 --output $(1)/odm.avbpubkey)
Yifan Hongcfb917a2020-05-07 14:58:20 -07003359 $(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
3360 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
3361 --output $(1)/vendor_dlkm.avbpubkey)
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003362 $(if $(BOARD_AVB_DTBO_KEY_PATH),\
3363 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
3364 --output $(1)/dtbo.avbpubkey)
David Zeuthen8fecb282017-12-01 16:24:01 -05003365 $(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
3366 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
3367 --output $(1)/recovery.avbpubkey)
David Anderson7709ab22018-10-15 14:41:34 -07003368 $(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
3369 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3370 --output $(1)/vbmeta_system.avbpubkey)
Tao Bao744c4c72018-08-20 21:09:07 -07003371 $(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
3372 $(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3373 --output $(1)/vbmeta_vendor.avbpubkey)
Hongguang Chenf23364d2020-04-27 18:36:36 -07003374 $(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
3375 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
3376 $(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
3377 --output $(1)/$(partition).avbpubkey;))
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003378endef
3379
Tao Bao744c4c72018-08-20 21:09:07 -07003380# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
3381# specified in BOARD_AVB_VBMETA_<NAME>. The built VBMeta image will be included into the top-level
David Anderson7709ab22018-10-15 14:41:34 -07003382# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
Justin Yun6151e3f2019-06-25 15:58:13 +09003383# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
3384# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
Tao Bao744c4c72018-08-20 21:09:07 -07003385# `vbmeta.img` as a chained partition.
David Anderson7709ab22018-10-15 14:41:34 -07003386# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
Tao Bao744c4c72018-08-20 21:09:07 -07003387# $(2): Output filename.
3388define build-chained-vbmeta-image
3389 $(call pretty,"Target chained vbmeta image: $@")
3390 $(hide) $(AVBTOOL) make_vbmeta_image \
3391 $(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
3392 $(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
3393 $(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
3394 --include_descriptors_from_image $(call images-for-partitions,$(image))) \
3395 --output $@
3396endef
3397
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003398ifdef BUILDING_SYSTEM_IMAGE
David Anderson7709ab22018-10-15 14:41:34 -07003399ifdef BOARD_AVB_VBMETA_SYSTEM
3400INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
3401$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003402 $(AVBTOOL) \
3403 $(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
3404 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
David Anderson7709ab22018-10-15 14:41:34 -07003405 $(call build-chained-vbmeta-image,vbmeta_system)
Tao Bao744c4c72018-08-20 21:09:07 -07003406endif
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07003407endif # BUILDING_SYSTEM_IMAGE
Tao Bao744c4c72018-08-20 21:09:07 -07003408
3409ifdef BOARD_AVB_VBMETA_VENDOR
3410INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
3411$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003412 $(AVBTOOL) \
3413 $(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
3414 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
Tao Bao744c4c72018-08-20 21:09:07 -07003415 $(call build-chained-vbmeta-image,vbmeta_vendor)
3416endif
3417
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003418define build-vbmetaimage-target
3419 $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003420 $(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
3421 $(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003422 $(hide) $(AVBTOOL) make_vbmeta_image \
3423 $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
Tao Bao0da43472018-08-22 22:53:41 -07003424 $(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003425 $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
3426 --output $@
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08003427 $(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003428endef
3429
Paul Trautrim4e143232019-08-13 16:30:57 +09003430ifdef BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003431INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
Tao Bao0da43472018-08-22 22:53:41 -07003432$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3433 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
3434
David Zeuthen8fecb282017-12-01 16:24:01 -05003435$(INSTALLED_VBMETAIMAGE_TARGET): \
Anton Hansson6d814982018-11-26 18:12:05 +00003436 $(AVBTOOL) \
3437 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07003438 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003439 $(INSTALLED_SYSTEMIMAGE_TARGET) \
3440 $(INSTALLED_VENDORIMAGE_TARGET) \
3441 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09003442 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003443 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07003444 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003445 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07003446 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00003447 $(INSTALLED_RECOVERYIMAGE_TARGET) \
3448 $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
3449 $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
3450 $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
3451 $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
3452 $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003453 $(build-vbmetaimage-target)
3454
3455.PHONY: vbmetaimage-nodeps
Bowgo Tsai6a4eaa52019-12-09 15:48:09 +08003456vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
3457 --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003458vbmetaimage-nodeps:
3459 $(build-vbmetaimage-target)
Paul Trautrim4e143232019-08-13 16:30:57 +09003460endif # BUILDING_VBMETA_IMAGE
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003461
Bowgo Tsai8ee4a3d2017-03-31 15:21:26 +08003462endif # BOARD_AVB_ENABLE
3463
3464# -----------------------------------------------------------------
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003465# Check VINTF of build
3466
Yifan Hongcfb917a2020-05-07 14:58:20 -07003467# Note: vendor_dlkm does not have VINTF files.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003468ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hongcfb917a2020-05-07 14:58:20 -07003469
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003470intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
3471check_vintf_all_deps :=
3472
Yifan Hongaf9b0702020-01-21 12:46:57 -08003473# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
3474# because they are only used for prebuilt images.
3475check_vintf_common_srcs_patterns := \
3476 $(TARGET_OUT)/etc/vintf/% \
3477 $(TARGET_OUT_VENDOR)/etc/vintf/% \
3478 $(TARGET_OUT_ODM)/etc/vintf/% \
3479 $(TARGET_OUT_PRODUCT)/etc/vintf/% \
3480 $(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
3481
3482check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns), \
3483 $(INTERNAL_SYSTEMIMAGE_FILES) \
3484 $(INTERNAL_VENDORIMAGE_FILES) \
3485 $(INTERNAL_ODMIMAGE_FILES) \
3486 $(INTERNAL_PRODUCTIMAGE_FILES) \
3487 $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
3488))
3489check_vintf_common_srcs_patterns :=
3490
3491check_vintf_has_system :=
3492check_vintf_has_vendor :=
3493
Yifan Hong28ffd732020-03-13 13:11:10 -07003494ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
3495$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
3496endif
3497ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
3498$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
3499endif
3500
Yifan Hong605ea042020-01-14 21:36:00 +00003501# -- Check system manifest / matrix including fragments (excluding other framework manifests / matrices, e.g. product);
Yifan Hongaf9b0702020-01-21 12:46:57 -08003502check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/%, $(check_vintf_common_srcs))
3503ifneq ($(check_vintf_system_deps),)
3504check_vintf_has_system := true
Yifan Hong605ea042020-01-14 21:36:00 +00003505check_vintf_system_log := $(intermediates)/check_vintf_system_log
3506check_vintf_all_deps += $(check_vintf_system_log)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003507$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps)
Yifan Hong605ea042020-01-14 21:36:00 +00003508 @( $< --check-one --dirmap /system:$(TARGET_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
3509check_vintf_system_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003510endif # check_vintf_system_deps
3511check_vintf_system_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003512
3513# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003514check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/%, $(check_vintf_common_srcs))
3515ifneq ($(check_vintf_vendor_deps),)
3516check_vintf_has_vendor := true
Yifan Hong605ea042020-01-14 21:36:00 +00003517check_vintf_vendor_log := $(intermediates)/check_vintf_vendor_log
3518check_vintf_all_deps += $(check_vintf_vendor_log)
Yifan Hong69430e62020-03-17 15:18:34 -07003519# Check vendor SKU=(empty) case when:
3520# - DEVICE_MANIFEST_FILE is not empty; OR
3521# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003522$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003523 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3524 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003525 $(DEVICE_MANIFEST_SKUS)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003526$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps)
Yifan Hong28ffd732020-03-13 13:11:10 -07003527 $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3528 ( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3529 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3530 > $@ 2>&1 ) || ( cat $@ && exit 1 ); )
Yifan Hong605ea042020-01-14 21:36:00 +00003531check_vintf_vendor_log :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003532endif # check_vintf_vendor_deps
3533check_vintf_vendor_deps :=
Yifan Hong605ea042020-01-14 21:36:00 +00003534
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003535# -- Check VINTF compatibility of build.
3536# Skip partial builds; only check full builds. Only check if:
3537# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
Yifan Hongaf9b0702020-01-21 12:46:57 -08003538# - system / vendor VINTF metadata exists
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003539# - Building product / system_ext / odm images if board has product / system_ext / odm images
3540ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
Yifan Hongaf9b0702020-01-21 12:46:57 -08003541ifeq ($(check_vintf_has_system),true)
3542ifeq ($(check_vintf_has_vendor),true)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003543ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
3544ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
3545ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
3546
3547check_vintf_compatible_log := $(intermediates)/check_vintf_compatible_log
3548check_vintf_all_deps += $(check_vintf_compatible_log)
3549
3550check_vintf_compatible_args :=
Yifan Hongaf9b0702020-01-21 12:46:57 -08003551check_vintf_compatible_deps := $(check_vintf_common_srcs)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003552
3553# -- Kernel version and configurations.
3554ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
3555
Yifan Hong605ea042020-01-14 21:36:00 +00003556BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
3557BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
3558
3559my_board_extracted_kernel :=
3560
3561# BOARD_KERNEL_CONFIG_FILE and BOARD_KERNEL_VERSION can be used to override the values extracted
3562# from INSTALLED_KERNEL_TARGET.
3563ifdef BOARD_KERNEL_CONFIG_FILE
3564ifdef BOARD_KERNEL_VERSION
3565$(BUILT_KERNEL_CONFIGS_FILE): $(BOARD_KERNEL_CONFIG_FILE)
3566 cp $< $@
3567$(BUILT_KERNEL_VERSION_FILE):
3568 echo $(BOARD_KERNEL_VERSION) > $@
3569
3570my_board_extracted_kernel := true
3571endif # BOARD_KERNEL_VERSION
3572endif # BOARD_KERNEL_CONFIG_FILE
3573
3574ifneq ($(my_board_extracted_kernel),true)
3575ifndef INSTALLED_KERNEL_TARGET
3576$(warning No INSTALLED_KERNEL_TARGET is defined when PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3577 is true. Information about the updated kernel cannot be built into OTA update package. \
3578 You can fix this by: (1) setting TARGET_NO_KERNEL to false and installing the built kernel \
3579 to $(PRODUCT_OUT)/kernel, so that kernel information will be extracted from the built kernel; \
3580 or (2) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
3581 BOARD_KERNEL_VERSION manually; or (3) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS \
3582 manually.)
3583else
3584
3585# Tools for decompression that is not in PATH.
3586# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
3587# Algorithms that are in the script but not in this list will be found in PATH.
3588my_decompress_tools := \
3589 lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
3590
3591$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
3592$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
3593$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
Steve Mucklebbdfbda2020-06-26 16:39:34 -07003594$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
3595 $< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
Yifan Hong605ea042020-01-14 21:36:00 +00003596 --output-configs $@ \
3597 --output-version $(BUILT_KERNEL_VERSION_FILE)
3598
3599my_decompress_tools :=
3600
3601endif # my_board_extracted_kernel
3602my_board_extracted_kernel :=
3603
3604endif # INSTALLED_KERNEL_TARGET
3605
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003606check_vintf_compatible_args += --kernel $$(cat $(BUILT_KERNEL_VERSION_FILE)):$(BUILT_KERNEL_CONFIGS_FILE)
3607check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
3608
3609endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
3610
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003611check_vintf_compatible_args += \
3612 --dirmap /system:$(TARGET_OUT) \
3613 --dirmap /vendor:$(TARGET_OUT_VENDOR) \
3614 --dirmap /odm:$(TARGET_OUT_ODM) \
3615 --dirmap /product:$(TARGET_OUT_PRODUCT) \
3616 --dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
3617
3618ifdef PRODUCT_SHIPPING_API_LEVEL
3619check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
3620endif # PRODUCT_SHIPPING_API_LEVEL
3621
3622$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
3623$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
Yifan Hong69430e62020-03-17 15:18:34 -07003624# Check ODM SKU=(empty) case when:
3625# - ODM_MANIFEST_FILES is not empty; OR
3626# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003627$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003628 $(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
3629 $(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003630 $(ODM_MANIFEST_SKUS)
Yifan Hong69430e62020-03-17 15:18:34 -07003631# Check vendor SKU=(empty) case when:
3632# - DEVICE_MANIFEST_FILE is not empty; OR
3633# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
Yifan Hong28ffd732020-03-13 13:11:10 -07003634$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
Yifan Hong69430e62020-03-17 15:18:34 -07003635 $(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
3636 $(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003637 $(DEVICE_MANIFEST_SKUS)
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003638$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
3639 @echo -n -e 'Deps: \n ' > $@
3640 @sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
3641 @echo -n -e 'Args: \n ' >> $@
3642 @cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
Yifan Hong28ffd732020-03-13 13:11:10 -07003643 $(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
3644 echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003645 ( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
Yifan Hong28ffd732020-03-13 13:11:10 -07003646 --property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
3647 --property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
3648 >> $@ 2>&1 ) || (cat $@ && exit 1); ))
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003649
3650check_vintf_compatible_log :=
3651check_vintf_compatible_args :=
3652check_vintf_compatible_deps :=
3653
3654endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
3655endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
3656endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
Yifan Hongaf9b0702020-01-21 12:46:57 -08003657endif # check_vintf_has_vendor
3658endif # check_vintf_has_system
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003659endif # PRODUCT_ENFORCE_VINTF_MANIFEST
3660
3661# Add all logs of VINTF checks to dist builds
3662droid_targets: $(check_vintf_all_deps)
3663$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
3664
3665# Helper alias to check all VINTF of current build.
3666.PHONY: check-vintf-all
3667check-vintf-all: $(check_vintf_all_deps)
3668 $(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
3669
Yifan Hongaf9b0702020-01-21 12:46:57 -08003670check_vintf_has_vendor :=
3671check_vintf_has_system :=
3672check_vintf_common_srcs :=
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003673check_vintf_all_deps :=
3674intermediates :=
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003675endif # !TARGET_BUILD_UNBUNDLED
Yifan Hongbcd46bc2020-01-14 21:35:45 +00003676
3677# -----------------------------------------------------------------
Yifan Hong055e6cf2018-11-29 13:51:48 -08003678# Check image sizes <= size of super partition
3679
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003680ifeq (,$(TARGET_BUILD_UNBUNDLED))
Yifan Hong055e6cf2018-11-29 13:51:48 -08003681
3682ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
Yifan Hong37c0c7c2018-07-24 17:45:08 -07003683
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003684# $(1): misc_info.txt
Yifan Hong30910932019-10-25 20:36:55 -07003685# #(2): optional log file
Yifan Hongb43012f2018-10-01 17:30:01 -07003686define check-all-partition-sizes-target
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003687 mkdir -p $(dir $(1))
3688 rm -f $(1)
3689 $(call dump-super-image-info, $(1))
3690 $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
3691 echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
Yifan Hong30910932019-10-25 20:36:55 -07003692 $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
Yifan Hongb43012f2018-10-01 17:30:01 -07003693endef
3694
Yifan Hong30910932019-10-25 20:36:55 -07003695check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes_log
3696droid_targets: $(check_all_partition_sizes_log)
3697$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
Colin Cross606c9f42019-05-17 15:51:39 -07003698
Yifan Hong30910932019-10-25 20:36:55 -07003699$(check_all_partition_sizes_log): \
3700 $(CHECK_PARTITION_SIZES) \
3701 $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
3702 $(call check-all-partition-sizes-target, \
3703 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
3704 $@)
3705
3706.PHONY: check-all-partition-sizes
3707check-all-partition-sizes: $(check_all_partition_sizes_log)
3708
3709.PHONY: check-all-partition-sizes-nodeps
Colin Cross606c9f42019-05-17 15:51:39 -07003710check-all-partition-sizes-nodeps:
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00003711 $(call check-all-partition-sizes-target, \
3712 $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
Yifan Hongb43012f2018-10-01 17:30:01 -07003713
Yifan Hong2dae5722018-07-31 12:47:27 -07003714endif # PRODUCT_BUILD_SUPER_PARTITION
Yifan Hong17dd45d2018-07-20 16:45:57 -07003715
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01003716endif # !TARGET_BUILD_UNBUNDLED
Yifan Hong17dd45d2018-07-20 16:45:57 -07003717
3718# -----------------------------------------------------------------
Greg Hartman2ebfef42014-11-04 21:17:06 -08003719# bring in the installer image generation defines if necessary
3720ifeq ($(TARGET_USE_DISKINSTALLER),true)
3721include bootable/diskinstaller/config.mk
3722endif
3723
3724# -----------------------------------------------------------------
Colin Crossc312f312012-04-19 13:54:39 -07003725# host tools needed to build dist and OTA packages
The Android Open Source Project88b60792009-03-03 19:28:42 -08003726
Ying Wangbd2d0242015-09-22 11:17:52 -07003727ifeq ($(BUILD_OS),darwin)
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003728 build_ota_package := false
3729 build_otatools_package := false
3730else
Tao Bao9be20c72019-04-08 21:11:59 -07003731 # Set build_ota_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003732 build_ota_package := true
3733 ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
3734 build_ota_package := false
3735 endif
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08003736 ifneq (,$(filter address, $(SANITIZE_TARGET)))
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003737 build_ota_package := false
3738 endif
3739 ifeq ($(TARGET_PRODUCT),sdk)
3740 build_ota_package := false
3741 endif
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003742 ifeq ($(TARGET_BUILD_PDK),true)
3743 build_ota_package := false
3744 endif
Tao Bao9be20c72019-04-08 21:11:59 -07003745 ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3746 ifneq ($(filter generic%,$(TARGET_DEVICE)),)
3747 build_ota_package := false
3748 endif
3749 ifeq ($(TARGET_NO_KERNEL),true)
3750 build_ota_package := false
3751 endif
3752 ifeq ($(recovery_fstab),)
3753 build_ota_package := false
3754 endif
3755 endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003756
Tao Bao9be20c72019-04-08 21:11:59 -07003757 # Set build_otatools_package, and allow opt-out below.
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003758 build_otatools_package := true
3759 ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
3760 build_otatools_package := false
3761 endif
Colin Cross481cc5a2016-02-04 15:09:23 -08003762endif
Ying Wangbd2d0242015-09-22 11:17:52 -07003763
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003764ifeq ($(build_otatools_package),true)
Tao Bao96daeeb2019-05-01 21:17:13 -07003765
3766INTERNAL_OTATOOLS_MODULES := \
changho.shin0f125362019-07-08 10:59:00 +09003767 aapt2 \
Tao Baoc1966a82019-06-25 11:42:12 -07003768 add_img_to_target_files \
Tianjie Xueaed60c2020-03-12 00:33:28 -07003769 aftltool \
Baligh Uddinab25b2d2020-05-29 19:01:32 +00003770 apksigner \
Tao Bao96daeeb2019-05-01 21:17:13 -07003771 append2simg \
3772 avbtool \
3773 blk_alloc_to_base_fs \
3774 boot_signer \
3775 brillo_update_payload \
3776 brotli \
3777 bsdiff \
Tao Bao2bbb07c2019-05-07 13:12:21 -07003778 build_image \
3779 build_super_image \
Tao Bao96daeeb2019-05-01 21:17:13 -07003780 build_verity_metadata \
3781 build_verity_tree \
3782 care_map_generator \
Tao Baoc1966a82019-06-25 11:42:12 -07003783 check_ota_package_signature \
3784 check_target_files_signatures \
Yifan Honge3ba82c2019-08-21 13:29:30 -07003785 check_target_files_vintf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003786 checkvintf \
3787 delta_generator \
3788 e2fsck \
3789 e2fsdroid \
3790 fc_sort \
3791 fec \
3792 fs_config \
3793 generate_verity_key \
3794 img2simg \
Tao Baoc1966a82019-06-25 11:42:12 -07003795 img_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003796 imgdiff \
3797 libconscrypt_openjdk_jni \
3798 lpmake \
Isaac Cheneec4a7c2019-06-25 11:50:58 +08003799 lpunpack \
Tianjie3031c292020-06-24 11:20:36 -07003800 lz4 \
Tao Bao96daeeb2019-05-01 21:17:13 -07003801 make_f2fs \
Tao Baoc1966a82019-06-25 11:42:12 -07003802 merge_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003803 minigzip \
Isaac Chen9e09d472019-07-05 17:30:41 +08003804 mk_combined_img \
Tao Bao96daeeb2019-05-01 21:17:13 -07003805 mkbootfs \
3806 mkbootimg \
3807 mke2fs \
Baligh Uddin6a8234b2020-01-29 17:42:59 -08003808 mke2fs.conf \
Tao Bao96daeeb2019-05-01 21:17:13 -07003809 mkf2fsuserimg.sh \
3810 mksquashfs \
3811 mksquashfsimage.sh \
3812 mkuserimg_mke2fs \
Tao Bao8821d642019-08-05 12:05:45 -07003813 ota_from_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003814 sefcontext_compile \
Isaac Chen9e09d472019-07-05 17:30:41 +08003815 sgdisk \
Tao Bao96daeeb2019-05-01 21:17:13 -07003816 shflags \
Tao Baoc1966a82019-06-25 11:42:12 -07003817 sign_apex \
3818 sign_target_files_apks \
Tao Bao96daeeb2019-05-01 21:17:13 -07003819 signapk \
3820 simg2img \
3821 sload_f2fs \
3822 tune2fs \
Daniel Mentz30652b32020-01-04 15:18:09 -08003823 unpack_bootimg \
Tianjie Xu4e5591f2019-06-11 14:35:59 -07003824 update_host_simulator \
Tao Baoc1966a82019-06-25 11:42:12 -07003825 validate_target_files \
Tao Bao96daeeb2019-05-01 21:17:13 -07003826 verity_signer \
3827 verity_verifier \
3828 zipalign \
Tao Bao5e04c382017-02-22 16:38:19 -08003829
Tianjie Xueb8a0a02020-01-23 13:59:13 -08003830# Additional tools to unpack and repack the apex file.
3831INTERNAL_OTATOOLS_MODULES += \
3832 apexer \
3833 deapexer \
3834 debugfs_static \
3835 merge_zips \
3836 resize2fs \
3837 soong_zip \
3838
Anton Hansson8dab0a62019-03-28 15:45:40 +00003839ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003840INTERNAL_OTATOOLS_MODULES += \
3841 futility \
3842 vboot_signer
Tao Bao5e04c382017-02-22 16:38:19 -08003843endif
Tao Baof8e6fbe2016-01-04 09:57:32 -08003844
Tao Bao96daeeb2019-05-01 21:17:13 -07003845INTERNAL_OTATOOLS_FILES := \
3846 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08003847
Ying Wang06898662010-06-17 17:52:18 -07003848.PHONY: otatools
Tao Bao96daeeb2019-05-01 21:17:13 -07003849otatools: $(INTERNAL_OTATOOLS_FILES)
Ying Wang06898662010-06-17 17:52:18 -07003850
Tao Bao96daeeb2019-05-01 21:17:13 -07003851# For each module, recursively resolve its host shared library dependencies. Then we have a full
3852# list of modules whose installed files need to be packed.
3853INTERNAL_OTATOOLS_MODULES_WITH_DEPS := \
3854 $(sort $(INTERNAL_OTATOOLS_MODULES) \
3855 $(foreach m,$(INTERNAL_OTATOOLS_MODULES),$(call get-all-shared-libs-deps,$(m))))
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003856
Tao Bao96daeeb2019-05-01 21:17:13 -07003857INTERNAL_OTATOOLS_PACKAGE_FILES := \
3858 $(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES_WITH_DEPS)))
3859
3860INTERNAL_OTATOOLS_PACKAGE_FILES += \
3861 $(sort $(shell find build/make/target/product/security -type f -name "*.x509.pem" -o \
3862 -name "*.pk8" -o -name verity_key))
Tao Bao93ab8442018-10-12 11:03:04 -07003863
3864ifneq (,$(wildcard device))
Tao Bao96daeeb2019-05-01 21:17:13 -07003865INTERNAL_OTATOOLS_PACKAGE_FILES += \
Dan Willemsen60c66442018-05-01 19:07:27 -07003866 $(sort $(shell find device $(wildcard vendor) -type f -name "*.pk8" -o -name "verifiedboot*" -o \
Baligh Uddindf238b42019-07-29 21:12:37 -07003867 -name "*.pem" -o -name "oem*.prop" -o -name "*.avbpubkey"))
Tao Bao93ab8442018-10-12 11:03:04 -07003868endif
3869ifneq (,$(wildcard external/avb))
Tao Bao96daeeb2019-05-01 21:17:13 -07003870INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao93ab8442018-10-12 11:03:04 -07003871 $(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
3872 -name "atx_metadata.bin"))
3873endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00003874ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
Tao Bao96daeeb2019-05-01 21:17:13 -07003875INTERNAL_OTATOOLS_PACKAGE_FILES += \
Tao Bao5232f092018-02-10 04:03:32 +00003876 $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
Tao Baoe8ef8f702017-05-17 11:41:50 -07003877endif
3878
Tao Bao96daeeb2019-05-01 21:17:13 -07003879INTERNAL_OTATOOLS_RELEASETOOLS := \
3880 $(sort $(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
3881 \( -type f -o -type l \) -print))
3882
3883BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
3884$(BUILT_OTATOOLS_PACKAGE): PRIVATE_ZIP_ROOT := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
3885$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_PACKAGE_FILES := $(INTERNAL_OTATOOLS_PACKAGE_FILES)
3886$(BUILT_OTATOOLS_PACKAGE): PRIVATE_OTATOOLS_RELEASETOOLS := $(INTERNAL_OTATOOLS_RELEASETOOLS)
3887$(BUILT_OTATOOLS_PACKAGE): $(INTERNAL_OTATOOLS_PACKAGE_FILES) $(INTERNAL_OTATOOLS_RELEASETOOLS)
Tao Bao57f8ed62019-08-14 23:08:18 -07003888$(BUILT_OTATOOLS_PACKAGE): $(SOONG_ZIP) $(ZIP2ZIP)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003889 @echo "Package OTA tools: $@"
Tao Bao96daeeb2019-05-01 21:17:13 -07003890 rm -rf $@ $(PRIVATE_ZIP_ROOT)
3891 mkdir -p $(dir $@)
3892 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_PACKAGE_FILES),$(HOST_OUT)/,$(PRIVATE_ZIP_ROOT))
3893 $(call copy-files-with-structure,$(PRIVATE_OTATOOLS_RELEASETOOLS),build/make/tools/,$(PRIVATE_ZIP_ROOT))
Tianjie Xua25d76f2020-01-28 19:17:35 -08003894 cp $(SOONG_ZIP) $(ZIP2ZIP) $(MERGE_ZIPS) $(PRIVATE_ZIP_ROOT)/bin/
Tao Bao96daeeb2019-05-01 21:17:13 -07003895 $(SOONG_ZIP) -o $@ -C $(PRIVATE_ZIP_ROOT) -D $(PRIVATE_ZIP_ROOT)
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003896
3897.PHONY: otatools-package
3898otatools-package: $(BUILT_OTATOOLS_PACKAGE)
3899
Bowgo Tsaid6ff8972018-10-09 15:46:25 +08003900endif # build_otatools_package
Doug Zongkerf22b0f42014-08-22 08:04:58 -07003901
The Android Open Source Project88b60792009-03-03 19:28:42 -08003902# -----------------------------------------------------------------
Daniel Normane1e48082019-06-27 13:55:23 -07003903# misc_info.txt
3904
3905INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
3906
3907ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
3908# default to common dir for device vendor
3909tool_extensions := $(TARGET_DEVICE_DIR)/../common
3910else
3911tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
3912endif
3913.KATI_READONLY := tool_extensions
3914
Steve Muckle903a1ca2020-05-07 17:32:10 -07003915# $1: boot image file name
3916define misc_boot_size
3917$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
3918endef
3919
Daniel Normane1e48082019-06-27 13:55:23 -07003920$(INSTALLED_MISC_INFO_TARGET):
3921 rm -f $@
3922 $(call pretty,"Target misc_info.txt: $@")
3923 $(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
3924 $(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
3925ifdef BOARD_FLASH_BLOCK_SIZE
3926 $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
3927endif
Steve Muckle903a1ca2020-05-07 17:32:10 -07003928ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
3929 $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
3930 echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
Daniel Normane1e48082019-06-27 13:55:23 -07003931endif
3932ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
3933 $(hide) echo "no_boot=true" >> $@
Steve Muckle9793cf62020-04-08 18:27:00 -07003934else
3935 echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003936endif
J. Avila98cd4cc2020-06-10 20:09:10 +00003937ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
3938 echo "lz4_ramdisks=true" >> $@
3939endif
Steve Mucklee1b10862019-07-10 10:49:37 -07003940ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
3941 echo "vendor_boot=true" >> $@
3942 echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
3943endif
Daniel Normane1e48082019-06-27 13:55:23 -07003944ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
3945 $(hide) echo "no_recovery=true" >> $@
3946endif
3947ifdef BOARD_INCLUDE_RECOVERY_DTBO
3948 $(hide) echo "include_recovery_dtbo=true" >> $@
3949endif
3950ifdef BOARD_INCLUDE_RECOVERY_ACPIO
3951 $(hide) echo "include_recovery_acpio=true" >> $@
3952endif
3953ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
3954 $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
3955endif
3956ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
3957 @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
3958 $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3959else
3960 $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
3961endif
3962 $(hide) echo "tool_extensions=$(tool_extensions)" >> $@
3963 $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
3964ifdef PRODUCT_EXTRA_RECOVERY_KEYS
3965 $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
3966endif
3967 $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
Steve Mucklef84668e2020-03-16 19:13:46 -07003968 $(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
Daniel Normane1e48082019-06-27 13:55:23 -07003969 $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
3970 $(hide) echo "multistage_support=1" >> $@
3971 $(hide) echo "blockimgdiff_versions=3,4" >> $@
3972ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
3973 $(hide) echo "build_generic_ota_package=true" >> $@
3974endif
3975ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
3976 # OTA scripts are only interested in fingerprint related properties
3977 $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
3978endif
3979ifneq (,$(filter address, $(SANITIZE_TARGET)))
3980 # We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
3981 $(hide) echo "userdata_img_with_data=true" >> $@
3982endif
3983ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
3984 $(hide) echo "full_recovery_image=true" >> $@
3985endif
Bill Peckhame868aec2019-09-17 17:06:47 -07003986ifdef BOARD_USES_VENDORIMAGE
3987 $(hide) echo "board_uses_vendorimage=true" >> $@
3988endif
Daniel Normane1e48082019-06-27 13:55:23 -07003989ifeq ($(BOARD_AVB_ENABLE),true)
3990 $(hide) echo "avb_enable=true" >> $@
3991 $(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
3992 $(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
3993 $(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
3994 $(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
3995ifdef BOARD_AVB_BOOT_KEY_PATH
3996 $(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
3997 $(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
3998 $(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
3999endif # BOARD_AVB_BOOT_KEY_PATH
Steve Mucklee1b10862019-07-10 10:49:37 -07004000 echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
4001ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
4002 echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
4003 echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
4004 echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
4005endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
Daniel Normane1e48082019-06-27 13:55:23 -07004006 $(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
4007ifdef BOARD_AVB_RECOVERY_KEY_PATH
4008 $(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
4009 $(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
4010 $(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
4011endif # BOARD_AVB_RECOVERY_KEY_PATH
Hongguang Chenf23364d2020-04-27 18:36:36 -07004012ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
4013 $(hide) echo "avb_custom_images_partition_list=$(BOARD_CUSTOMIMAGES_PARTITION_LIST)" >> $@
4014 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4015 echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
4016 echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
4017 echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
4018 echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
4019 echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
4020 echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
4021endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Daniel Normane1e48082019-06-27 13:55:23 -07004022ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
4023 $(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
4024 $(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4025 $(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
4026 $(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
4027 $(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
4028endif # BOARD_AVB_VBMETA_SYSTEM
4029ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
4030 $(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
4031 $(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
4032 $(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
4033 $(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
4034 $(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
4035endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
4036endif # BOARD_AVB_ENABLE
4037ifdef BOARD_BPT_INPUT_FILES
4038 $(hide) echo "board_bpt_enable=true" >> $@
4039 $(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $@
4040 $(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $@
4041endif
4042ifdef BOARD_BPT_DISK_SIZE
4043 $(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $@
4044endif
4045 $(call generate-userimage-prop-dictionary, $@)
4046ifeq ($(AB_OTA_UPDATER),true)
4047 @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
4048 $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
4049 $(hide) echo "ab_update=true" >> $@
4050endif
Yifan Hong65afc072020-04-17 10:08:10 -07004051ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
4052 $(hide) echo "allow_non_ab=true" >> $@
4053endif
Daniel Normane1e48082019-06-27 13:55:23 -07004054ifdef BOARD_PREBUILT_DTBOIMAGE
4055 $(hide) echo "has_dtbo=true" >> $@
4056ifeq ($(BOARD_AVB_ENABLE),true)
4057 $(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
4058 $(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
4059ifdef BOARD_AVB_DTBO_KEY_PATH
4060 $(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
4061 $(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
4062 $(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
4063endif # BOARD_AVB_DTBO_KEY_PATH
4064endif # BOARD_AVB_ENABLE
4065endif # BOARD_PREBUILT_DTBOIMAGE
4066 $(call dump-dynamic-partitions-info,$@)
Yifan Honge3ba82c2019-08-21 13:29:30 -07004067 @# VINTF checks
4068ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
4069 $(hide) echo "vintf_enforce=true" >> $@
4070endif
4071ifdef ODM_MANIFEST_SKUS
4072 $(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
4073endif
Yifan Hong28ffd732020-03-13 13:11:10 -07004074ifdef ODM_MANIFEST_FILES
4075 $(hide) echo "vintf_include_empty_odm_sku=true" >> $@
4076endif
4077ifdef DEVICE_MANIFEST_SKUS
4078 $(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
4079endif
4080ifdef DEVICE_MANIFEST_FILE
4081 $(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
4082endif
Daniel Normane1e48082019-06-27 13:55:23 -07004083
4084.PHONY: misc_info
4085misc_info: $(INSTALLED_MISC_INFO_TARGET)
4086
4087droidcore: $(INSTALLED_MISC_INFO_TARGET)
4088
4089# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004090# A zip of the directories that map to the target filesystem.
4091# This zip can be used to create an OTA package or filesystem image
4092# as a post-build step.
4093#
4094name := $(TARGET_PRODUCT)
4095ifeq ($(TARGET_BUILD_TYPE),debug)
4096 name := $(name)_debug
4097endif
4098name := $(name)-target_files-$(FILE_NAME_TAG)
4099
4100intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
4101BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
4102$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates)
4103$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004104 zip_root := $(intermediates)/$(name)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004105
4106# $(1): Directory to copy
4107# $(2): Location to copy it to
4108# The "ls -A" is to prevent "acp s/* d" from failing if s is empty.
4109define package_files-copy-root
4110 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
4111 mkdir -p $(2) && \
4112 $(ACP) -rd $(strip $(1))/* $(2); \
4113 fi
4114endef
4115
Tao Baoa04fca32015-11-30 12:22:24 -08004116built_ota_tools :=
Ying Wange6e544e2015-06-22 18:35:35 -07004117
4118# We can't build static executables when SANITIZE_TARGET=address
Evgenii Stepanov5d06f242018-11-14 14:12:10 -08004119ifeq (,$(filter address, $(SANITIZE_TARGET)))
Ying Wange6e544e2015-06-22 18:35:35 -07004120built_ota_tools += \
Elliott Hughes9b824d52020-04-17 15:46:55 -07004121 $(call intermediates-dir-for,EXECUTABLES,updater)/updater
Ying Wange6e544e2015-06-22 18:35:35 -07004122endif
4123
The Android Open Source Project88b60792009-03-03 19:28:42 -08004124$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
4125
Dan Willemsen653bea92017-03-21 15:47:37 -07004126tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
Dan Willemsen653bea92017-03-21 15:47:37 -07004127$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
Doug Zongkerc18736b2009-09-30 09:20:32 -07004128
Sen Jiang4438fd92016-03-07 16:51:01 -08004129ifeq ($(AB_OTA_UPDATER),true)
Sen Jiang43935632017-12-19 15:24:43 -08004130updater_dep := system/update_engine/update_engine.conf
Yifan Hong65afc072020-04-17 10:08:10 -07004131endif
4132
4133# Build OTA tools if non-A/B is allowed
4134ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004135updater_dep := $(built_ota_tools)
Steve Fung48e49f52015-10-01 23:53:31 -07004136endif
Yifan Hong65afc072020-04-17 10:08:10 -07004137
Shinichiro Hamajiee2d2112016-05-10 16:40:38 +09004138$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
Steve Fung48e49f52015-10-01 23:53:31 -07004139
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004140# If we are using recovery as boot, output recovery files to BOOT/.
4141ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
4142$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
4143else
4144$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
4145endif
4146
Dan Willemsen653bea92017-03-21 15:47:37 -07004147ifeq ($(AB_OTA_UPDATER),true)
Dan Willemsen653bea92017-03-21 15:47:37 -07004148 ifdef OSRELEASED_DIRECTORY
4149 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
4150 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
4151 $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
4152 endif
Tao Baoa835f382019-07-18 15:55:30 -07004153
4154 # Not checking in board_config.mk, since AB_OTA_PARTITIONS may be updated in Android.mk (e.g. to
4155 # additionally include radio or bootloader partitions).
4156 ifeq ($(AB_OTA_PARTITIONS),)
4157 $(error AB_OTA_PARTITIONS must be defined when using AB_OTA_UPDATER)
4158 endif
4159endif
4160
4161ifneq ($(AB_OTA_PARTITIONS),)
4162 ifneq ($(AB_OTA_UPDATER),true)
4163 $(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
4164 endif
Dan Willemsen653bea92017-03-21 15:47:37 -07004165endif
4166
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004167# Run fs_config while creating the target files package
4168# $1: root directory
4169# $2: add prefix
4170define fs_config
Luis Hector Chavez440da2d2018-02-07 09:49:52 -08004171(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 -08004172endef
4173
Yifan Hong60bfcc42019-11-01 11:39:45 -07004174# Filter out vendor from the list for AOSP targets.
4175# $(1): list
4176define filter-out-missing-vendor
4177$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
4178endef
4179
4180# Information related to dynamic partitions and virtual A/B. This information
4181# is needed for building the super image (see dump-super-image-info) and
4182# building OTA packages.
Yifan Hong2b891ac2018-11-29 12:06:31 -08004183# $(1): file
4184define dump-dynamic-partitions-info
4185 $(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
4186 echo "use_dynamic_partitions=true" >> $(1))
4187 $(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
4188 echo "dynamic_partition_retrofit=true" >> $(1))
Yifan Hong055e6cf2018-11-29 13:51:48 -08004189 echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
4190 $(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
4191 echo "build_super_partition=true" >> $(1)))
Tao Bao519d1822018-12-27 12:47:23 -08004192 $(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
4193 echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004194 echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
4195 $(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4196 echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
4197 $(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
4198 echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
4199 $(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004200 echo "dynamic_partition_list=$(call filter-out-missing-vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST))" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004201 $(if $(BOARD_SUPER_PARTITION_GROUPS),
4202 echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
4203 $(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
4204 echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
4205 $(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
Luca Stefanic158e422020-05-12 20:36:31 +02004206 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 -07004207 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
4208 echo "build_non_sparse_super_partition=true" >> $(1))
Alistair Delva91238cc2019-10-16 10:53:41 -07004209 $(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
4210 echo "build_non_sparse_super_partition=true" >> $(1))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004211 $(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
4212 echo "super_image_in_update_package=true" >> $(1))
Yifan Hong3a7c2ef2019-11-01 18:23:19 +00004213 $(if $(BOARD_SUPER_PARTITION_SIZE), \
4214 echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
4215 $(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
4216 echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
4217 $(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
4218 echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
4219 $(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
4220 echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
Yifan Hongcb8e2752019-11-01 17:03:57 -07004221 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
4222 echo "virtual_ab=true" >> $(1))
4223 $(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
4224 echo "virtual_ab_retrofit=true" >> $(1))
Yifan Hong2b891ac2018-11-29 12:06:31 -08004225endef
4226
Bill Peckhamd52fd9b2019-04-16 10:06:13 -07004227# By conditionally including the dependency of the target files package on the
4228# full system image deps, we speed up builds that do not build the system
4229# image.
4230ifdef BUILDING_SYSTEM_IMAGE
4231$(BUILT_TARGET_FILES_PACKAGE): $(FULL_SYSTEMIMAGE_DEPS)
4232endif
4233
Isaac Chen9e09d472019-07-05 17:30:41 +08004234ifeq ($(BUILD_QEMU_IMAGES),true)
4235MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
4236$(BUILT_TARGET_FILES_PACKAGE): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
4237endif
4238
The Android Open Source Project88b60792009-03-03 19:28:42 -08004239# Depending on the various images guarantees that the underlying
4240# directories are up-to-date.
4241$(BUILT_TARGET_FILES_PACKAGE): \
Anton Hansson6d814982018-11-26 18:12:05 +00004242 $(INSTALLED_RAMDISK_TARGET) \
4243 $(INSTALLED_BOOTIMAGE_TARGET) \
Steve Mucklee1b10862019-07-10 10:49:37 -07004244 $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004245 $(INSTALLED_RADIOIMAGE_TARGET) \
4246 $(INSTALLED_RECOVERYIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004247 $(INSTALLED_USERDATAIMAGE_TARGET) \
4248 $(INSTALLED_CACHEIMAGE_TARGET) \
4249 $(INSTALLED_VENDORIMAGE_TARGET) \
4250 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004251 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004252 $(INSTALLED_VBMETAIMAGE_TARGET) \
4253 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004254 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004255 $(INSTALLED_DTBOIMAGE_TARGET) \
Hongguang Chenf23364d2020-04-27 18:36:36 -07004256 $(INSTALLED_CUSTOMIMAGES_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004257 $(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
4258 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
4259 $(INSTALLED_KERNEL_TARGET) \
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004260 $(INSTALLED_DTBIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004261 $(INSTALLED_2NDBOOTLOADER_TARGET) \
4262 $(BOARD_PREBUILT_DTBOIMAGE) \
Hridya Valsarajua9418992019-02-04 10:35:25 -08004263 $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004264 $(BOARD_RECOVERY_ACPIO) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004265 $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4266 $(PRODUCT_VENDOR_BASE_FS_PATH) \
4267 $(PRODUCT_PRODUCT_BASE_FS_PATH) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004268 $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
Anton Hansson8dab0a62019-03-28 15:45:40 +00004269 $(PRODUCT_ODM_BASE_FS_PATH) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004270 $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
Anton Hansson6d814982018-11-26 18:12:05 +00004271 $(LPMAKE) \
4272 $(SELINUX_FC) \
Daniel Normane1e48082019-06-27 13:55:23 -07004273 $(INSTALLED_MISC_INFO_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004274 $(APKCERTS_FILE) \
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004275 $(SOONG_APEX_KEYS_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004276 $(SOONG_ZIP) \
4277 $(HOST_OUT_EXECUTABLES)/fs_config \
Tao Baoc1966a82019-06-25 11:42:12 -07004278 $(ADD_IMG_TO_TARGET_FILES) \
Tao Baoe11a4602019-08-06 23:21:23 -07004279 $(MAKE_RECOVERY_PATCH) \
Yifan Honge3ba82c2019-08-21 13:29:30 -07004280 $(BUILT_KERNEL_CONFIGS_FILE) \
4281 $(BUILT_KERNEL_VERSION_FILE) \
Anton Hansson6d814982018-11-26 18:12:05 +00004282 | $(ACP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004283 @echo "Package target files: $@"
Dan Willemsenf75d7fa2017-03-23 13:09:21 -07004284 $(call create-system-vendor-symlink)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004285 $(call create-system-product-symlink)
Justin Yun6151e3f2019-06-25 15:58:13 +09004286 $(call create-system-system_ext-symlink)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004287 $(call create-vendor-odm-symlink)
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004288 $(hide) rm -rf $@ $@.list $(zip_root)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004289 $(hide) mkdir -p $(dir $@) $(zip_root)
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004290ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08004291 @# Components of the recovery image
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004292 $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004293 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004294 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004295ifdef INSTALLED_KERNEL_TARGET
Steve Muckleb3dda772020-03-11 16:03:07 -07004296 cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
The Android Open Source Project88b60792009-03-03 19:28:42 -08004297endif
Steve Mucklef84668e2020-03-16 19:13:46 -07004298ifeq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(AB_OTA_UPDATER)))
Steve Mucklee1b10862019-07-10 10:49:37 -07004299 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
Steve Mucklef84668e2020-03-16 19:13:46 -07004300else # not (BUILDING_VENDOR_BOOT_IMAGE and AB_OTA_UPDATER)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004301ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004302 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004303endif
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004304ifdef BOARD_INCLUDE_RECOVERY_DTBO
Hridya Valsarajua9418992019-02-04 10:35:25 -08004305ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
Steve Mucklee1b10862019-07-10 10:49:37 -07004306 cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajua9418992019-02-04 10:35:25 -08004307else
Steve Mucklee1b10862019-07-10 10:49:37 -07004308 cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
Hridya Valsarajue74a38b2018-03-21 12:15:11 -07004309endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004310endif # BOARD_INCLUDE_RECOVERY_DTBO
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004311ifdef BOARD_INCLUDE_RECOVERY_ACPIO
Steve Mucklee1b10862019-07-10 10:49:37 -07004312 cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
Chen, ZhiminX752439b2018-09-23 22:10:47 +08004313endif
Hridya Valsaraju59eaef02019-05-20 11:10:24 -07004314ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004315 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004316endif
Dan Willemsenc1f17ff2016-10-05 16:57:27 -07004317ifdef INTERNAL_KERNEL_CMDLINE
Steve Mucklee1b10862019-07-10 10:49:37 -07004318 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
The Android Open Source Project88b60792009-03-03 19:28:42 -08004319endif
Doug Zongker38a649f2009-06-17 09:07:09 -07004320ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004321 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004322endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004323ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004324 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004325endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004326endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET not defined
Daniel Rosenbergd80bef22015-11-10 19:21:34 -08004327endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
The Android Open Source Project88b60792009-03-03 19:28:42 -08004328 @# Components of the boot image
4329 $(hide) mkdir -p $(zip_root)/BOOT
Tao Bao62bd4792015-07-21 18:01:20 -07004330 $(hide) mkdir -p $(zip_root)/ROOT
4331 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004332 $(TARGET_ROOT_OUT),$(zip_root)/ROOT)
Tom Cherry3871f0f2018-11-06 14:23:44 -08004333 @# If we are using recovery as boot, this is already done when processing recovery.
4334ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherryd14b8952018-08-09 14:26:00 -07004335ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004336 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004337 $(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
Tao Bao62bd4792015-07-21 18:01:20 -07004338endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004339ifdef INSTALLED_KERNEL_TARGET
Dan Willemsen653bea92017-03-21 15:47:37 -07004340 $(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
The Android Open Source Project88b60792009-03-03 19:28:42 -08004341endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004342ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET
The Android Open Source Project88b60792009-03-03 19:28:42 -08004343ifdef INSTALLED_2NDBOOTLOADER_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004344 cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
The Android Open Source Project88b60792009-03-03 19:28:42 -08004345endif
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004346ifdef INSTALLED_DTBIMAGE_TARGET
Steve Mucklee1b10862019-07-10 10:49:37 -07004347 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
Hridya Valsaraju9683b2f2019-01-22 18:08:59 -08004348endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004349 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
Doug Zongker38a649f2009-06-17 09:07:09 -07004350ifdef BOARD_KERNEL_BASE
Steve Mucklee1b10862019-07-10 10:49:37 -07004351 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
Doug Zongker38a649f2009-06-17 09:07:09 -07004352endif
Ying Wang4de6b5b2010-08-25 14:29:34 -07004353ifdef BOARD_KERNEL_PAGESIZE
Steve Mucklee1b10862019-07-10 10:49:37 -07004354 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
Ying Wang4de6b5b2010-08-25 14:29:34 -07004355endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004356else # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4357 echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
4358endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET defined
4359endif # BOARD_USES_RECOVERY_AS_BOOT not true
Doug Zongkere01100c2009-06-19 17:12:18 -07004360 $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
4361 mkdir -p $(zip_root)/RADIO; \
Dan Willemsen653bea92017-03-21 15:47:37 -07004362 cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
Steve Mucklee1b10862019-07-10 10:49:37 -07004363ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
4364 mkdir -p $(zip_root)/VENDOR_BOOT
4365 $(call package_files-copy-root, \
4366 $(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
4367ifdef INSTALLED_DTBIMAGE_TARGET
4368 cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
4369endif
4370ifdef BOARD_KERNEL_BASE
4371 echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
4372endif
4373ifdef BOARD_KERNEL_PAGESIZE
4374 echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
4375endif
4376 echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
4377endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
Dan Willemsen67495202019-01-16 12:42:05 -08004378ifdef BUILDING_SYSTEM_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004379 @# Contents of the system image
4380 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004381 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
Dan Willemsen67495202019-01-16 12:42:05 -08004382endif
4383ifdef BUILDING_USERDATA_IMAGE
The Android Open Source Project88b60792009-03-03 19:28:42 -08004384 @# Contents of the data image
4385 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004386 $(TARGET_OUT_DATA),$(zip_root)/DATA)
Dan Willemsen67495202019-01-16 12:42:05 -08004387endif
4388ifdef BUILDING_VENDOR_IMAGE
Ying Wanga0febe52013-03-20 11:02:05 -07004389 @# Contents of the vendor image
4390 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004391 $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
Ying Wanga0febe52013-03-20 11:02:05 -07004392endif
Dan Willemsen67495202019-01-16 12:42:05 -08004393ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004394 @# Contents of the product image
4395 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004396 $(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004397endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004398ifdef BUILDING_SYSTEM_EXT_IMAGE
4399 @# Contents of the system_ext image
Dario Freni5f681e12018-05-29 13:09:01 +01004400 $(hide) $(call package_files-copy-root, \
Justin Yun6151e3f2019-06-25 15:58:13 +09004401 $(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
Dario Freni5f681e12018-05-29 13:09:01 +01004402endif
Dan Willemsen67495202019-01-16 12:42:05 -08004403ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004404 @# Contents of the odm image
4405 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004406 $(TARGET_OUT_ODM),$(zip_root)/ODM)
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004407endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004408ifdef BUILDING_VENDOR_DLKM_IMAGE
4409 @# Contents of the vendor_dlkm image
4410 $(hide) $(call package_files-copy-root, \
4411 $(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
4412endif
Dan Willemsen67495202019-01-16 12:42:05 -08004413ifdef BUILDING_SYSTEM_OTHER_IMAGE
Alex Light4e358ab2016-06-16 14:47:10 -07004414 @# Contents of the system_other image
4415 $(hide) $(call package_files-copy-root, \
Anton Hansson6d814982018-11-26 18:12:05 +00004416 $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
Alex Light4e358ab2016-06-16 14:47:10 -07004417endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08004418 @# Extra contents of the OTA package
Steve Fung48e49f52015-10-01 23:53:31 -07004419 $(hide) mkdir -p $(zip_root)/OTA
Dan Willemsen653bea92017-03-21 15:47:37 -07004420 $(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
Yifan Hong65afc072020-04-17 10:08:10 -07004421ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Ying Wang03b6e8b2015-12-07 10:45:19 -08004422ifneq ($(built_ota_tools),)
Steve Fung48e49f52015-10-01 23:53:31 -07004423 $(hide) mkdir -p $(zip_root)/OTA/bin
Dan Willemsen653bea92017-03-21 15:47:37 -07004424 $(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
Steve Fung48e49f52015-10-01 23:53:31 -07004425endif
Ying Wang03b6e8b2015-12-07 10:45:19 -08004426endif
Doug Zongker8678df42009-06-15 14:30:14 -07004427 @# Files that do not end up in any images, but are necessary to
The Android Open Source Project88b60792009-03-03 19:28:42 -08004428 @# build them.
4429 $(hide) mkdir -p $(zip_root)/META
Dan Willemsen653bea92017-03-21 15:47:37 -07004430 $(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
Jiyong Parkbcc8d8a2019-02-18 15:21:19 +09004431 $(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004432ifneq ($(tool_extension),)
4433 $(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
4434endif
Ying Wang0eabd4f2015-03-24 19:07:40 -07004435 $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
Dan Willemsen653bea92017-03-21 15:47:37 -07004436 $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
Daniel Normane1e48082019-06-27 13:55:23 -07004437 $(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
Anton Hansson8dab0a62019-03-28 15:45:40 +00004438ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
4439 $(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
4440 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004441endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004442ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
4443 $(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
4444 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
Tao Baof54216f2016-03-29 15:12:37 -07004445endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004446ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
4447 $(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
4448 $(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004449endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004450ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
4451 $(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
4452 $(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
Dario Freni5f681e12018-05-29 13:09:01 +01004453endif
Anton Hansson8dab0a62019-03-28 15:45:40 +00004454ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
4455 $(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
4456 $(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004457endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004458ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
4459 $(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
4460 $(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
4461endif
Yifan Hong65afc072020-04-17 10:08:10 -07004462ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
Tao Baocbc6dc22015-08-18 18:03:56 -07004463ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
Tao Baocf821fc2019-06-24 12:39:10 -07004464 $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
Tao Baoe11a4602019-08-06 23:21:23 -07004465 $(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
Tao Baocbc6dc22015-08-18 18:03:56 -07004466endif
Bill Peckhamc0f413f2019-11-07 11:27:02 -08004467endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004468ifeq ($(AB_OTA_UPDATER),true)
4469 @# When using the A/B updater, include the updater config files in the zip.
Dan Willemsen653bea92017-03-21 15:47:37 -07004470 $(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
Alex Deymo49be2b12015-10-22 18:15:27 -07004471 $(hide) for part in $(AB_OTA_PARTITIONS); do \
Alex Deymo8925d332015-10-01 17:38:09 -07004472 echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
4473 done
Sen Jiang8f22e2a2015-11-12 13:53:25 -08004474 $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \
4475 echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
4476 done
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004477ifdef OSRELEASED_DIRECTORY
Dan Willemsen653bea92017-03-21 15:47:37 -07004478 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
4479 $(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
4480 $(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
Bertrand SIMONNET4af72592015-10-08 15:32:40 -07004481endif
Alex Deymo70067ac2015-09-29 19:05:37 -07004482endif
Steve Fungdfbab492015-09-24 18:12:33 -07004483ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
Alex Deymo70067ac2015-09-29 19:05:37 -07004484 @# If breakpad symbols have been generated, add them to the zip.
Dan Willemsen288bedf2019-05-28 15:36:47 -07004485 $(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
Steve Fungdfbab492015-09-24 18:12:33 -07004486endif
Dan Willemsen6c3e79b2016-06-17 14:07:37 -07004487ifdef BOARD_PREBUILT_VENDORIMAGE
4488 $(hide) mkdir -p $(zip_root)/IMAGES
4489 $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
4490endif
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004491ifdef BOARD_PREBUILT_PRODUCTIMAGE
4492 $(hide) mkdir -p $(zip_root)/IMAGES
4493 $(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
4494endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004495ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
Dario Freni5f681e12018-05-29 13:09:01 +01004496 $(hide) mkdir -p $(zip_root)/IMAGES
Justin Yun6151e3f2019-06-25 15:58:13 +09004497 $(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
Dario Freni5f681e12018-05-29 13:09:01 +01004498endif
Michael Schwartz0dc6f212017-07-18 10:05:13 -07004499ifdef BOARD_PREBUILT_BOOTIMAGE
4500 $(hide) mkdir -p $(zip_root)/IMAGES
4501 $(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
4502endif
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004503ifdef BOARD_PREBUILT_ODMIMAGE
4504 $(hide) mkdir -p $(zip_root)/IMAGES
4505 $(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
4506endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004507ifdef BOARD_PREBUILT_VENDOR_DLKIMMAGE
4508 $(hide) mkdir -p $(zip_root)/IMAGES
4509 $(hide) cp $(INSTALLED_VENDOR_DLKIMMAGE_TARGET) $(zip_root)/IMAGES/
4510endif
Yueyao Zhu889ee5e2017-05-12 17:50:46 -07004511ifdef BOARD_PREBUILT_DTBOIMAGE
Tao Baoc633ed02017-05-30 21:46:33 -07004512 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4513 $(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
Bowgo Tsai3e599ea2017-05-26 18:30:04 +08004514endif # BOARD_PREBUILT_DTBOIMAGE
Hongguang Chenf23364d2020-04-27 18:36:36 -07004515ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
4516 $(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
4517 $(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
4518 $(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
4519endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
Tao Bao95a95c32017-06-16 15:30:23 -07004520 @# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
4521 @# IMAGES/, which then will be added into <product>-img.zip. Such images must be listed in
4522 @# INSTALLED_RADIOIMAGE_TARGET.
4523 $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
4524 echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004525 @# Run fs_config on all the system, vendor, boot ramdisk,
4526 @# and recovery ramdisk files in the zip, and save the output
Dan Willemsen67495202019-01-16 12:42:05 -08004527ifdef BUILDING_SYSTEM_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004528 $(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
Dan Willemsen67495202019-01-16 12:42:05 -08004529endif
4530ifdef BUILDING_VENDOR_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004531 $(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
4532endif
Dan Willemsen67495202019-01-16 12:42:05 -08004533ifdef BUILDING_PRODUCT_IMAGE
Jaekyun Seokb7735d82017-11-27 17:04:47 +09004534 $(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
4535endif
Justin Yun6151e3f2019-06-25 15:58:13 +09004536ifdef BUILDING_SYSTEM_EXT_IMAGE
4537 $(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 +01004538endif
Dan Willemsen67495202019-01-16 12:42:05 -08004539ifdef BUILDING_ODM_IMAGE
Bowgo Tsaid624fa62017-11-14 23:42:30 +08004540 $(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
4541endif
Yifan Hongcfb917a2020-05-07 14:58:20 -07004542ifdef BUILDING_VENDOR_DLKM_IMAGE
4543 $(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
4544endif
Tom Cherryd14b8952018-08-09 14:26:00 -07004545 @# ROOT always contains the files for the root under normal boot.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004546 $(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004547ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
Tom Cherry2929cad2018-09-20 11:04:37 -07004548 @# BOOT/RAMDISK exists and contains the ramdisk for recovery if using BOARD_USES_RECOVERY_AS_BOOT.
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004549 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
Tao Baoda01b212018-02-28 21:20:08 -08004550endif
Steve Mucklee1b10862019-07-10 10:49:37 -07004551ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
4552 $(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
4553endif
Tom Cherry2929cad2018-09-20 11:04:37 -07004554ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
4555 @# 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 -08004556 $(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
4557endif
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004558ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
4559 $(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
4560endif
Dan Willemsen67495202019-01-16 12:42:05 -08004561ifdef BUILDING_SYSTEM_OTHER_IMAGE
Dan Willemsen2a5a34f2017-03-05 19:56:52 -08004562 $(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
4563endif
Michael Schwartz4d9cb562017-04-04 13:01:18 -07004564 @# Metadata for compatibility verification.
Yifan Honge3ba82c2019-08-21 13:29:30 -07004565ifdef BUILT_KERNEL_CONFIGS_FILE
4566 $(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
4567endif
4568ifdef BUILT_KERNEL_VERSION_FILE
4569 $(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
4570endif
Yifan Hongcb8e2752019-11-01 17:03:57 -07004571 rm -rf $(zip_root)/META/dynamic_partitions_info.txt
4572ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4573 $(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
4574endif
Tao Baocbd6d492019-10-07 22:46:02 -07004575 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
4576 $(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
Isaac Chen9e09d472019-07-05 17:30:41 +08004577ifeq ($(BUILD_QEMU_IMAGES),true)
4578 $(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
4579 $(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
4580endif
Alex Deymo92cfd6f2016-01-26 18:47:44 -08004581 @# Zip everything up, preserving symlinks and placing META/ files first to
4582 @# help early validation of the .zip file while uploading it.
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004583 $(hide) find $(zip_root)/META | sort >$@.list
Nan Zhangcabecd92017-03-20 18:22:43 -07004584 $(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@.list
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004585 $(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l $@.list
Doug Zongker283e2a12010-03-15 17:52:32 -07004586
Ying Wanga0febe52013-03-20 11:02:05 -07004587.PHONY: target-files-package
The Android Open Source Project88b60792009-03-03 19:28:42 -08004588target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
4589
Ying Wang4709d7c2014-04-14 17:25:43 -07004590ifneq ($(filter $(MAKECMDGOALS),target-files-package),)
4591$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
4592endif
Doug Zongker367910f2009-06-15 18:56:51 -07004593
Dan Albert4d323332016-10-14 13:23:06 -07004594# -----------------------------------------------------------------
4595# NDK Sysroot Package
4596NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
Dan Willemsen14e10262018-06-17 21:54:21 -07004597$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
Dan Albert4d323332016-10-14 13:23:06 -07004598 @echo Package NDK sysroot...
4599 $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
4600
4601$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
4602
Ying Wang09c4b682015-08-11 11:24:19 -07004603ifeq ($(build_ota_package),true)
Ying Wang09a00a62010-10-20 14:01:09 -07004604# -----------------------------------------------------------------
4605# OTA update package
4606
Yifan Hong50e79542018-11-08 17:44:12 -08004607# $(1): output file
4608# $(2): additional args
4609define build-ota-package-target
Tao Baoc9315472019-06-25 12:17:08 -07004610PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
Tao Bao8821d642019-08-05 12:05:45 -07004611 $(OTA_FROM_TARGET_FILES) \
4612 --verbose \
4613 --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
4614 --path $(HOST_OUT) \
4615 $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
4616 $(2) \
4617 $(BUILT_TARGET_FILES_PACKAGE) $(1)
Yifan Hong50e79542018-11-08 17:44:12 -08004618endef
4619
Doug Zongker8678df42009-06-15 14:30:14 -07004620name := $(TARGET_PRODUCT)
4621ifeq ($(TARGET_BUILD_TYPE),debug)
4622 name := $(name)_debug
4623endif
4624name := $(name)-ota-$(FILE_NAME_TAG)
4625
4626INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
xunchang3b548b02019-02-19 14:52:33 -08004627INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
4628
Doug Zongker8678df42009-06-15 14:30:14 -07004629$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
xunchang3b548b02019-02-19 14:52:33 -08004630$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
Tao Bao8821d642019-08-05 12:05:45 -07004631$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
Doug Zongker8678df42009-06-15 14:30:14 -07004632 @echo "Package OTA: $@"
xunchang3b548b02019-02-19 14:52:33 -08004633 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
Doug Zongker8678df42009-06-15 14:30:14 -07004634
4635.PHONY: otapackage
4636otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
4637
Tao Bao519d1822018-12-27 12:47:23 -08004638ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
Yifan Hong50e79542018-11-08 17:44:12 -08004639name := $(TARGET_PRODUCT)
4640ifeq ($(TARGET_BUILD_TYPE),debug)
4641 name := $(name)_debug
4642endif
4643name := $(name)-ota-retrofit-$(FILE_NAME_TAG)
4644
4645INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
Yifan Hong50e79542018-11-08 17:44:12 -08004646$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
Tao Bao8821d642019-08-05 12:05:45 -07004647$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
4648 $(BUILT_TARGET_FILES_PACKAGE) \
4649 $(OTA_FROM_TARGET_FILES)
Yifan Hong50e79542018-11-08 17:44:12 -08004650 @echo "Package OTA (retrofit dynamic partitions): $@"
4651 $(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
4652
4653.PHONY: otardppackage
4654
4655otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
4656
Tao Bao519d1822018-12-27 12:47:23 -08004657endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
Yifan Hong50e79542018-11-08 17:44:12 -08004658
Ying Wang09c4b682015-08-11 11:24:19 -07004659endif # build_ota_package
Ying Wangf8824af2014-06-03 14:07:27 -07004660
Ying Wang09a00a62010-10-20 14:01:09 -07004661# -----------------------------------------------------------------
Dario Frenid1011272018-07-23 20:20:15 +01004662# A zip of the appcompat directory containing logs
4663APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
4664# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004665ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004666$(APPCOMPAT_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004667 $(INSTALLED_RAMDISK_TARGET) \
4668 $(INSTALLED_BOOTIMAGE_TARGET) \
4669 $(INSTALLED_USERDATAIMAGE_TARGET) \
4670 $(INSTALLED_VENDORIMAGE_TARGET) \
4671 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004672 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
Dario Frenid1011272018-07-23 20:20:15 +01004673endif
4674$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
4675$(APPCOMPAT_ZIP): $(SOONG_ZIP)
4676 @echo "appcompat logs: $@"
4677 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4678 $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
4679 $(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
4680 $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
4681
Dario Frenid1011272018-07-23 20:20:15 +01004682# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004683# A zip of the symbols directory. Keep the full paths to make it
4684# more obvious where these files came from.
4685#
4686name := $(TARGET_PRODUCT)
4687ifeq ($(TARGET_BUILD_TYPE),debug)
4688 name := $(name)_debug
4689endif
4690name := $(name)-symbols-$(FILE_NAME_TAG)
4691
4692SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
Colin Cross6cdc5d22017-10-20 11:37:33 -07004693# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004694ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004695$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004696 $(INSTALLED_RAMDISK_TARGET) \
4697 $(INSTALLED_BOOTIMAGE_TARGET) \
4698 $(INSTALLED_USERDATAIMAGE_TARGET) \
4699 $(INSTALLED_VENDORIMAGE_TARGET) \
4700 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004701 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004702 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004703 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004704 $(updater_dep)
Ying Wangda3b9722014-10-24 11:36:59 -07004705endif
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004706$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
4707$(SYMBOLS_ZIP): $(SOONG_ZIP)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004708 @echo "Package symbols: $@"
Dan Willemsen5e29cad2016-08-06 20:15:06 -07004709 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4710 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
Jiyong Park88e09802019-03-21 15:19:16 +09004711 $(hide) find -L $(TARGET_OUT_UNSTRIPPED) -type f | sort >$(PRIVATE_LIST_FILE)
Colin Cross8d342442019-05-07 11:47:13 -07004712 $(hide) $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004713# -----------------------------------------------------------------
4714# A zip of the coverage directory.
4715#
Oliver Nguyene91ab232019-04-30 15:14:44 -07004716name := gcov-report-files-all
Ryan Campbell81c9d292016-09-12 13:56:50 -07004717ifeq ($(TARGET_BUILD_TYPE),debug)
4718name := $(name)_debug
4719endif
Ryan Campbell81c9d292016-09-12 13:56:50 -07004720COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004721ifeq (,$(TARGET_BUILD_UNBUNDLED))
Tao Baoe9d61b02018-08-20 21:09:07 -07004722$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
Anton Hansson6d814982018-11-26 18:12:05 +00004723 $(INSTALLED_RAMDISK_TARGET) \
4724 $(INSTALLED_BOOTIMAGE_TARGET) \
4725 $(INSTALLED_USERDATAIMAGE_TARGET) \
4726 $(INSTALLED_VENDORIMAGE_TARGET) \
4727 $(INSTALLED_PRODUCTIMAGE_TARGET) \
Justin Yun6151e3f2019-06-25 15:58:13 +09004728 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004729 $(INSTALLED_ODMIMAGE_TARGET) \
4730 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
Ryan Campbell81c9d292016-09-12 13:56:50 -07004731endif
4732$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
4733$(COVERAGE_ZIP): $(SOONG_ZIP)
4734 @echo "Package coverage: $@"
4735 $(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
4736 $(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
4737 $(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
4738 $(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004739
Oliver Nguyenb02f7db2019-12-11 14:55:52 -08004740#------------------------------------------------------------------
4741# Export the LLVM profile data tool and dependencies for Clang coverage processing
4742#
4743ifeq (true,$(CLANG_COVERAGE))
4744 LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
4745 LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
4746 PROFDATA_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
4747 $(PROFDATA_ZIP): $(SOONG_ZIP)
4748 $(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX)
4749
4750 $(call dist-for-goals,droidcore,$(PROFDATA_ZIP))
4751endif
4752
The Android Open Source Project88b60792009-03-03 19:28:42 -08004753# -----------------------------------------------------------------
4754# A zip of the Android Apps. Not keeping full path so that we don't
4755# include product names when distributing
4756#
4757name := $(TARGET_PRODUCT)
4758ifeq ($(TARGET_BUILD_TYPE),debug)
4759 name := $(name)_debug
4760endif
4761name := $(name)-apps-$(FILE_NAME_TAG)
4762
4763APPS_ZIP := $(PRODUCT_OUT)/$(name).zip
Tao Baoe9d61b02018-08-20 21:09:07 -07004764$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08004765 @echo "Package apps: $@"
4766 $(hide) rm -rf $@
4767 $(hide) mkdir -p $(dir $@)
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004768 $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
4769 if [ -z "$$apps_to_zip" ]; then \
Anton Hansson6d814982018-11-26 18:12:05 +00004770 echo "No apps to zip up. Generating empty apps archive." ; \
4771 a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004772 else \
Anton Hansson6d814982018-11-26 18:12:05 +00004773 zip -qjX $@ $$apps_to_zip; \
Gaurav Shah67c2ed32015-08-23 09:40:05 -07004774 fi
Guang Zhu0198d6e2010-04-23 11:54:37 -07004775
Ying Wangbc415dd2012-08-15 12:22:44 -07004776ifeq (true,$(EMMA_INSTRUMENT))
Colin Crossa6bc3a82017-09-27 14:28:41 -07004777#------------------------------------------------------------------
4778# An archive of classes for use in generating code-coverage reports
4779# These are the uninstrumented versions of any classes that were
4780# to be instrumented.
Colin Cross6cdc5d22017-10-20 11:37:33 -07004781# Any dependencies are set up later in build/make/core/main.mk.
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004782
Colin Crossa6bc3a82017-09-27 14:28:41 -07004783JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004784$(JACOCO_REPORT_CLASSES_ALL) :
4785 @echo "Collecting uninstrumented classes"
Colin Crossd81f4b32020-02-12 14:14:27 -08004786 find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "jacoco-report-classes.jar" 2>/dev/null | sort > $@.list
4787 $(SOONG_ZIP) -o $@ -L 0 -C $(OUT_DIR) -P out -l $@.list
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004788
Ying Wangbc415dd2012-08-15 12:22:44 -07004789endif # EMMA_INSTRUMENT=true
4790
Jeff Gastonaaae43c2017-04-11 16:36:46 -07004791
Ying Wangae9115a2013-08-22 20:52:47 -07004792#------------------------------------------------------------------
4793# A zip of Proguard obfuscation dictionary files.
Ying Wangae9115a2013-08-22 20:52:47 -07004794#
Ying Wangc62c92c2013-08-28 18:38:25 -07004795PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip
Colin Cross114e8df2019-09-05 17:19:35 -07004796# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
Martin Stjernholm7a430fd2020-06-04 15:16:39 +01004797ifeq (,$(TARGET_BUILD_UNBUNDLED))
Colin Cross114e8df2019-09-05 17:19:35 -07004798$(PROGUARD_DICT_ZIP): \
4799 $(INSTALLED_SYSTEMIMAGE_TARGET) \
4800 $(INSTALLED_RAMDISK_TARGET) \
4801 $(INSTALLED_BOOTIMAGE_TARGET) \
4802 $(INSTALLED_USERDATAIMAGE_TARGET) \
4803 $(INSTALLED_VENDORIMAGE_TARGET) \
4804 $(INSTALLED_PRODUCTIMAGE_TARGET) \
4805 $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
4806 $(INSTALLED_ODMIMAGE_TARGET) \
Yifan Hongcfb917a2020-05-07 14:58:20 -07004807 $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
Colin Cross114e8df2019-09-05 17:19:35 -07004808 $(updater_dep)
4809endif
4810$(PROGUARD_DICT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,proguard)/filelist
4811$(PROGUARD_DICT_ZIP): $(SOONG_ZIP)
Ying Wangae9115a2013-08-22 20:52:47 -07004812 @echo "Packaging Proguard obfuscation dictionary files."
Colin Cross114e8df2019-09-05 17:19:35 -07004813 mkdir -p $(dir $@) $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS $(dir $(PRIVATE_LIST_FILE))
4814 find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary | \
4815 sed -e 's/\(.*\)\/proguard_dictionary/\0\n\1\/classes.jar/' > $(PRIVATE_LIST_FILE)
4816 $(SOONG_ZIP) --ignore_missing_files -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
Ying Wangae9115a2013-08-22 20:52:47 -07004817
Tao Bao48a2feb2019-06-28 11:00:05 -07004818
4819ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
4820
4821# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
4822# $(1): output file
4823define dump-super-image-info
4824 $(call dump-dynamic-partitions-info,$(1))
4825 $(if $(filter true,$(AB_OTA_UPDATER)), \
4826 echo "ab_update=true" >> $(1))
4827endef
4828
4829endif # PRODUCT_USE_DYNAMIC_PARTITIONS
4830
The Android Open Source Project88b60792009-03-03 19:28:42 -08004831# -----------------------------------------------------------------
Yifan Hongacd862a2019-04-16 15:44:30 -07004832# super partition image (dist)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004833
4834ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4835
4836# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
4837ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4838
4839ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004840
4841# For real devices and for dist builds, build super image from target files to an intermediate directory.
4842INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
4843$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
4844$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_PACKAGE) $(BUILD_SUPER_IMAGE)
4845 $(call pretty,"Target super fs image from target files: $@")
Tao Bao403a2f92018-12-13 10:45:46 -08004846 PATH=$(dir $(LPMAKE)):$$PATH \
4847 $(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
Yifan Hong69e0d612019-03-11 15:55:33 -07004848
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004849# Skip packing it in dist package because it is in update package.
4850ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
Yifan Hongacd862a2019-04-16 15:44:30 -07004851$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004852endif
Yifan Hongacd862a2019-04-16 15:44:30 -07004853
4854.PHONY: superimage_dist
4855superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
Yifan Hong69e0d612019-03-11 15:55:33 -07004856
4857endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
Yifan Hongacd862a2019-04-16 15:44:30 -07004858endif # BOARD_SUPER_PARTITION_SIZE != ""
4859endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004860
Yifan Hongacd862a2019-04-16 15:44:30 -07004861# -----------------------------------------------------------------
4862# super partition image for development
4863
4864ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
4865ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
4866ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
4867
4868# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
4869# $(1): built image path
4870# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
4871define build-superimage-target
4872 mkdir -p $(dir $(2))
4873 rm -rf $(2)
4874 $(call dump-super-image-info,$(2))
4875 $(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
4876 echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
changho.shina8f9f112019-10-15 13:26:19 +09004877 $(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
4878 echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
Yifan Hongacd862a2019-04-16 15:44:30 -07004879 mkdir -p $(dir $(1))
4880 PATH=$(dir $(LPMAKE)):$$PATH \
4881 $(BUILD_SUPER_IMAGE) -v $(2) $(1)
4882endef
4883
4884INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
4885INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
4886 $(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
4887
changho.shina8f9f112019-10-15 13:26:19 +09004888ifdef BUILDING_SYSTEM_OTHER_IMAGE
4889ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
4890INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
4891endif
4892endif
4893
Yifan Hongacd862a2019-04-16 15:44:30 -07004894# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
4895# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
4896# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
4897# virtual devices.
4898ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
4899$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4900 $(call pretty,"Target super fs image for debug: $@")
4901 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
Isaac Chen52cc60c2019-08-14 18:52:13 +08004902 $(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004903
4904droidcore: $(INSTALLED_SUPERIMAGE_TARGET)
4905
4906# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
4907.PHONY: superimage
4908superimage: $(INSTALLED_SUPERIMAGE_TARGET)
Isaac Chen52cc60c2019-08-14 18:52:13 +08004909
4910$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
Yifan Hongacd862a2019-04-16 15:44:30 -07004911endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
4912
4913# Build $(PRODUCT_OUT)/super.img without dependencies.
4914.PHONY: superimage-nodeps supernod
4915superimage-nodeps supernod: intermediates :=
4916superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
4917 $(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
4918 $(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
4919 $(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
4920
4921endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
4922endif # BOARD_SUPER_PARTITION_SIZE != ""
4923endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
4924
4925# -----------------------------------------------------------------
4926# super empty image
4927
Tao Bao48a2feb2019-06-28 11:00:05 -07004928ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
Yifan Hongacd862a2019-04-16 15:44:30 -07004929ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
Yifan Hong2b891ac2018-11-29 12:06:31 -08004930
Yifan Hong8b79d162018-11-29 12:32:00 -08004931INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
4932$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
4933$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
4934 $(call pretty,"Target empty super fs image: $@")
4935 mkdir -p $(intermediates)
4936 rm -rf $(intermediates)/misc_info.txt
Yifan Hong69e0d612019-03-11 15:55:33 -07004937 $(call dump-super-image-info,$(intermediates)/misc_info.txt)
Tao Bao403a2f92018-12-13 10:45:46 -08004938 PATH=$(dir $(LPMAKE)):$$PATH \
4939 $(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
Yifan Hong8b79d162018-11-29 12:32:00 -08004940
4941$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
4942
Yifan Hong2b891ac2018-11-29 12:06:31 -08004943endif # BOARD_SUPER_PARTITION_SIZE != ""
Tao Bao48a2feb2019-06-28 11:00:05 -07004944endif # PRODUCT_USE_DYNAMIC_PARTITIONS == "true"
Yifan Hong2b891ac2018-11-29 12:06:31 -08004945
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004946
4947# -----------------------------------------------------------------
4948# The update package
4949
4950name := $(TARGET_PRODUCT)
4951ifeq ($(TARGET_BUILD_TYPE),debug)
4952 name := $(name)_debug
4953endif
4954name := $(name)-img-$(FILE_NAME_TAG)
4955
4956INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
4957
Tao Bao57f8ed62019-08-14 23:08:18 -07004958$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
4959 $(call pretty,"Package: $@")
4960 PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
4961 $(IMG_FROM_TARGET_FILES) \
4962 --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
4963 $(BUILT_TARGET_FILES_PACKAGE) $@
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004964
4965.PHONY: updatepackage
4966updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
Dan Willemsen9ae64952019-08-05 14:45:11 -07004967$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
Yifan Hong0e97dbb2019-04-17 14:28:52 -07004968
4969
Yifan Hong2b891ac2018-11-29 12:06:31 -08004970# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08004971# dalvik something
4972.PHONY: dalvikfiles
4973dalvikfiles: $(INTERNAL_DALVIK_MODULES)
4974
Bo Huf0d50bb2017-08-01 19:02:09 +00004975ifeq ($(BUILD_QEMU_IMAGES),true)
Bo Huf0d50bb2017-08-01 19:02:09 +00004976MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
Isaac Chen9e09d472019-07-05 17:30:41 +08004977MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
Bo Huf0d50bb2017-08-01 19:02:09 +00004978SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
Roman Kiryanove64998f2019-02-14 16:45:33 -08004979
4980ifdef INSTALLED_SYSTEMIMAGE_TARGET
4981INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
bohu9492ee32019-03-07 10:03:41 -08004982INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
4983$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
4984 @echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
4985 @echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
Isaac Chen9e09d472019-07-05 17:30:41 +08004986$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
bohu9492ee32019-03-07 10:03:41 -08004987 $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
4988 @echo Create system-qemu.img now
4989 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
Isaac Chen9e09d472019-07-05 17:30:41 +08004990 $(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
Bo Huf0d50bb2017-08-01 19:02:09 +00004991
4992systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
4993droidcore: $(INSTALLED_QEMU_SYSTEMIMAGE)
Roman Kiryanove64998f2019-02-14 16:45:33 -08004994endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00004995ifdef INSTALLED_VENDORIMAGE_TARGET
Bo Huf0d50bb2017-08-01 19:02:09 +00004996INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00004997$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Bo Huf0d50bb2017-08-01 19:02:09 +00004998 @echo Create vendor-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08004999 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
Bo Huf0d50bb2017-08-01 19:02:09 +00005000
5001vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
5002droidcore: $(INSTALLED_QEMU_VENDORIMAGE)
5003endif
bohu8fd437c2020-03-30 20:16:13 -07005004
5005ifdef INSTALLED_RAMDISK_TARGET
5006ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
5007ifdef INTERNAL_VENDOR_RAMDISK_TARGET
5008INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
5009$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
5010 @echo Create ramdisk-qemu.img
5011 (cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
5012
5013droidcore: $(INSTALLED_QEMU_RAMDISKIMAGE)
5014endif
5015endif
5016endif
5017
Anton Hansson32c76fe2018-12-13 14:34:18 +00005018ifdef INSTALLED_PRODUCTIMAGE_TARGET
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005019INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
Isaac Chenb9b51b12018-08-03 18:34:55 +00005020$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005021 @echo Create product-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005022 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
Jaekyun Seokb7735d82017-11-27 17:04:47 +09005023
5024productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
5025droidcore: $(INSTALLED_QEMU_PRODUCTIMAGE)
5026endif
Justin Yun6151e3f2019-06-25 15:58:13 +09005027ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
5028INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
5029$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
5030 @echo Create system_ext-qemu.img
5031 (export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
Dario Freni5f681e12018-05-29 13:09:01 +01005032
Justin Yun6151e3f2019-06-25 15:58:13 +09005033systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
5034droidcore: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
Dario Freni5f681e12018-05-29 13:09:01 +01005035endif
Anton Hansson32c76fe2018-12-13 14:34:18 +00005036ifdef INSTALLED_ODMIMAGE_TARGET
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005037INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
5038$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5039 @echo Create odm-qemu.img
Roman Kiryanov4985cc82019-02-15 10:22:45 -08005040 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
Bowgo Tsaid624fa62017-11-14 23:42:30 +08005041
5042odmimage: $(INSTALLED_QEMU_ODMIMAGE)
5043droidcore: $(INSTALLED_QEMU_ODMIMAGE)
5044endif
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005045
Yifan Hongcfb917a2020-05-07 14:58:20 -07005046ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
5047INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
5048$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
5049 @echo Create vendor_dlkm-qemu.img
5050 (export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
5051
5052vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5053droidcore: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
5054endif
5055
5056
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005057QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
bohu9492ee32019-03-07 10:03:41 -08005058$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
5059 $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005060 @echo Creating $@
bohu9492ee32019-03-07 10:03:41 -08005061 (export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
5062 $(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005063
5064systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
5065droidcore: $(QEMU_VERIFIED_BOOT_PARAMS)
bohu9492ee32019-03-07 10:03:41 -08005066
Bo Huf0d50bb2017-08-01 19:02:09 +00005067endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005068# -----------------------------------------------------------------
The Android Open Source Project88b60792009-03-03 19:28:42 -08005069# The emulator package
Ying Wang7d8c5352012-07-26 10:15:21 -07005070ifeq ($(BUILD_EMULATOR),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005071INTERNAL_EMULATOR_PACKAGE_FILES += \
5072 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
Jean-Baptiste Queru5ea72ef2012-01-06 16:44:06 -08005073 prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005074 $(INSTALLED_RAMDISK_TARGET) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005075 $(INSTALLED_SYSTEMIMAGE_TARGET) \
5076 $(INSTALLED_USERDATAIMAGE_TARGET)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005077
5078name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG)
5079
5080INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
5081
Ying Wang5d887702015-11-04 10:06:25 -08005082$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005083 @echo "Package: $@"
Dan Willemsen48a621c2015-10-29 16:33:05 -07005084 $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005085
Ying Wang7d8c5352012-07-26 10:15:21 -07005086endif
The Android Open Source Project88b60792009-03-03 19:28:42 -08005087# -----------------------------------------------------------------
Keun young Park7fc7aad2012-02-27 15:49:23 -08005088# Old PDK stuffs, retired
The Android Open Source Project88b60792009-03-03 19:28:42 -08005089# The pdk package (Platform Development Kit)
5090
Keun young Park7fc7aad2012-02-27 15:49:23 -08005091#ifneq (,$(filter pdk,$(MAKECMDGOALS)))
5092# include development/pdk/Pdk.mk
5093#endif
5094
The Android Open Source Project88b60792009-03-03 19:28:42 -08005095
5096# -----------------------------------------------------------------
5097# The SDK
5098
The Android Open Source Project88b60792009-03-03 19:28:42 -08005099# The SDK includes host-specific components, so it belongs under HOST_OUT.
Ying Wangd7af1762014-06-02 16:16:53 -07005100sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005101
5102# Build a name that looks like:
5103#
5104# linux-x86 --> android-sdk_12345_linux-x86
5105# darwin-x86 --> android-sdk_12345_mac-x86
5106# windows-x86 --> android-sdk_12345_windows
5107#
5108sdk_name := android-sdk_$(FILE_NAME_TAG)
5109ifeq ($(HOST_OS),darwin)
Joe Onorato03fbe402009-04-13 08:31:16 -07005110 INTERNAL_SDK_HOST_OS_NAME := mac
The Android Open Source Project88b60792009-03-03 19:28:42 -08005111else
Joe Onorato03fbe402009-04-13 08:31:16 -07005112 INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005113endif
5114ifneq ($(HOST_OS),windows)
Ying Wang2713fce2014-06-09 12:31:12 -07005115 INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005116endif
Joe Onorato03fbe402009-04-13 08:31:16 -07005117sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005118
5119sdk_dep_file := $(sdk_dir)/sdk_deps.mk
5120
5121ATREE_FILES :=
5122-include $(sdk_dep_file)
5123
5124# if we don't have a real list, then use "everything"
5125ifeq ($(strip $(ATREE_FILES)),)
5126ATREE_FILES := \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005127 $(ALL_DEFAULT_INSTALLED_MODULES) \
5128 $(INSTALLED_RAMDISK_TARGET) \
5129 $(ALL_DOCS) \
5130 $(ALL_SDK_FILES)
5131endif
5132
5133atree_dir := development/build
5134
David 'Digit' Turner74b0c362011-03-23 11:20:14 +01005135
The Android Open Source Project88b60792009-03-03 19:28:42 -08005136sdk_atree_files := \
5137 $(atree_dir)/sdk.exclude.atree \
Ying Wang2713fce2014-06-09 12:31:12 -07005138 $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree
The Android Open Source Project88b60792009-03-03 19:28:42 -08005139
David 'Digit' Turner77ec16a2011-06-23 12:49:02 +02005140# development/build/sdk-android-<abi>.atree is used to differentiate
5141# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
5142# files like the kernel image. We use TARGET_CPU_ABI because we don't
5143# have a better way to distinguish between CPU models.
5144ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
5145 sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
5146endif
5147
Anton Hansson8dab0a62019-03-28 15:45:40 +00005148ifneq ($(PRODUCT_SDK_ATREE_FILES),)
5149sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
Griff Hazen433febb2014-02-28 08:45:59 -08005150else
5151sdk_atree_files += $(atree_dir)/sdk.atree
5152endif
5153
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005154include $(BUILD_SYSTEM)/sdk_font.mk
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005155
The Android Open Source Project88b60792009-03-03 19:28:42 -08005156deps := \
5157 $(target_notice_file_txt) \
5158 $(tools_notice_file_txt) \
5159 $(OUT_DOCS)/offline-sdk-timestamp \
Jerome Gaillarda0171af2019-10-10 19:35:08 +01005160 $(SDK_METADATA_FILES) \
Ying Wang139e3322010-03-31 17:29:04 -07005161 $(SYMBOLS_ZIP) \
Ryan Campbell81c9d292016-09-12 13:56:50 -07005162 $(COVERAGE_ZIP) \
Dario Frenid1011272018-07-23 20:20:15 +01005163 $(APPCOMPAT_ZIP) \
Tao Baoe9d61b02018-08-20 21:09:07 -07005164 $(INSTALLED_SYSTEMIMAGE_TARGET) \
Bo Huf0d50bb2017-08-01 19:02:09 +00005165 $(INSTALLED_QEMU_SYSTEMIMAGE) \
bohu8fd437c2020-03-30 20:16:13 -07005166 $(INSTALLED_QEMU_RAMDISKIMAGE) \
bohu18d18682017-08-14 14:52:20 -07005167 $(INSTALLED_QEMU_VENDORIMAGE) \
Matt Wachowski9e4d5152018-08-07 16:29:22 -07005168 $(QEMU_VERIFIED_BOOT_PARAMS) \
Doug Zongkerdddd9572009-06-15 21:25:32 -07005169 $(INSTALLED_USERDATAIMAGE_TARGET) \
5170 $(INSTALLED_RAMDISK_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005171 $(INSTALLED_SDK_BUILD_PROP_TARGET) \
Ying Wang139e3322010-03-31 17:29:04 -07005172 $(INSTALLED_BUILD_PROP_TARGET) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005173 $(ATREE_FILES) \
Ying Wang0c0a4ce2014-02-18 14:29:59 -08005174 $(sdk_atree_files) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005175 $(HOST_OUT_EXECUTABLES)/atree \
Deepanshu Gupta4e5e5822014-08-01 10:14:15 -07005176 $(HOST_OUT_EXECUTABLES)/line_endings \
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07005177 $(SDK_FONT_DEPS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005178
5179INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
5180$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
5181$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
5182$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
5183$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
5184
5185# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
5186#
5187#SDK_GNU_ERROR := true
5188
Ying Wang5d887702015-11-04 10:06:25 -08005189$(INTERNAL_SDK_TARGET): $(deps)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005190 @echo "Package SDK: $@"
5191 $(hide) rm -rf $(PRIVATE_DIR) $@
5192 $(hide) for f in $(target_gnu_MODULES); do \
5193 if [ -f $$f ]; then \
5194 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
5195 including GNU target $$f >&2; \
5196 FAIL=$(SDK_GNU_ERROR); \
5197 fi; \
5198 done; \
5199 if [ $$FAIL ]; then exit 1; fi
Deepanshu Gupta88a307e2014-08-12 10:23:58 -07005200 $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt
The Android Open Source Project88b60792009-03-03 19:28:42 -08005201 $(hide) ( \
Anton Hansson6d814982018-11-26 18:12:05 +00005202 ATREE_STRIP="$(HOST_STRIP) -x" \
5203 $(HOST_OUT_EXECUTABLES)/atree \
5204 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
5205 -m $(PRIVATE_DEP_FILE) \
5206 -I . \
5207 -I $(PRODUCT_OUT) \
5208 -I $(HOST_OUT) \
5209 -I $(TARGET_COMMON_OUT_ROOT) \
5210 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
5211 -v "OUT_DIR=$(OUT_DIR)" \
5212 -v "HOST_OUT=$(HOST_OUT)" \
5213 -v "TARGET_ARCH=$(TARGET_ARCH)" \
5214 -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
5215 -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
5216 -v "FONT_OUT=$(SDK_FONT_TEMP)" \
5217 -o $(PRIVATE_DIR) && \
5218 cp -f $(target_notice_file_txt) \
5219 $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \
5220 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
5221 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
5222 development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
5223 chmod -R ug+rwX $(PRIVATE_DIR) && \
5224 cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005225 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
5226
Raphael3d224a02010-04-16 17:50:09 -07005227
5228# Is a Windows SDK requested? If so, we need some definitions from here
5229# in order to find the Linux SDK used to create the Windows one.
Raphaelc4d47312011-02-15 16:09:36 -08005230MAIN_SDK_NAME := $(sdk_name)
5231MAIN_SDK_DIR := $(sdk_dir)
5232MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
Ying Wangff1fe682015-01-27 12:47:10 -08005233ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
Raphael3d224a02010-04-16 17:50:09 -07005234include $(TOPDIR)development/build/tools/windows_sdk.mk
5235endif
5236
The Android Open Source Project88b60792009-03-03 19:28:42 -08005237# -----------------------------------------------------------------
5238# Findbugs
5239INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
5240INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
5241$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
5242 @echo UnionBugs: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005243 $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08005244 > $@
5245$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
5246 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +09005247 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
Ying Wangad7fd292013-08-08 16:34:29 -07005248 $(INTERNAL_FINDBUGS_XML_TARGET) > $@
The Android Open Source Project88b60792009-03-03 19:28:42 -08005249
5250# -----------------------------------------------------------------
5251# Findbugs
5252
5253# -----------------------------------------------------------------
5254# These are some additional build tasks that need to be run.
Ying Wangad7fd292013-08-08 16:34:29 -07005255ifneq ($(dont_bother),true)
The Android Open Source Project88b60792009-03-03 19:28:42 -08005256include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
Claes Elgemarke22ad672010-11-12 15:46:00 +01005257-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
Andrew Boief34a9ba2012-04-16 10:03:16 -07005258-include $(sort $(wildcard device/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005259-include $(sort $(wildcard product/*/build/tasks/*.mk))
Ying Wang66c78e42014-09-05 17:47:34 -07005260# Also the project-specific tasks
5261-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
5262-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
Lee Campbell04ba3122015-08-20 15:39:56 -07005263-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
Guang Zhu8322be72016-06-20 22:03:24 -07005264# Also add test specifc tasks
5265include $(sort $(wildcard platform_testing/build/tasks/*.mk))
Keun Soo Yim199a7102016-08-31 09:20:51 -07005266include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
Ying Wangad7fd292013-08-08 16:34:29 -07005267endif
Raphaelc4d47312011-02-15 16:09:36 -08005268
Ying Wang67132ba2015-10-28 16:42:39 -07005269include $(BUILD_SYSTEM)/product-graph.mk
5270
Raphaelc4d47312011-02-15 16:09:36 -08005271# -----------------------------------------------------------------
5272# Create SDK repository packages. Must be done after tasks/* since
5273# we need the addon rules defined.
5274ifneq ($(sdk_repo_goal),)
5275include $(TOPDIR)development/build/tools/sdk_repo.mk
5276endif
Mitch Phillipsceefc442019-09-26 16:37:59 -07005277
5278# -----------------------------------------------------------------
Mitch Phillips3adbcb32019-10-17 19:24:46 -07005279# Soong generates the list of all shared libraries that are depended on by fuzz
5280# targets. It saves this list as a source:destination pair to
5281# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
5282# build of the unstripped shared library, and the destination is the
5283# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
5284# where fuzz target shared libraries are to be "reinstalled". The
5285# copy-many-files below generates the rules to copy the unstripped shared
5286# libraries to the device or host "reinstallation" directory. These rules are
5287# depended on by each module in soong_cc_prebuilt.mk, where the module will have
5288# a dependency on each shared library that it needs to be "reinstalled".
5289FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
5290
5291# -----------------------------------------------------------------
Mitch Phillipsceefc442019-09-26 16:37:59 -07005292# The rule to build all fuzz targets, and package them.
5293# Note: The packages are created in Soong, and in a perfect world,
5294# we'd be able to create the phony rule there. But, if we want to
5295# have dist goals for the fuzz target, we need to have the PHONY
5296# target defined in make. MakeVarsContext.DistForGoal doesn't take
5297# into account that a PHONY rule create by Soong won't be available
5298# during make, and such will fail with `writing to readonly
Kris Alder8c8c2b92019-11-26 12:03:39 -08005299# directory`, because kati will see 'haiku' as being a file, not a
Mitch Phillipsceefc442019-09-26 16:37:59 -07005300# phony target.
Kris Alder8c8c2b92019-11-26 12:03:39 -08005301.PHONY: haiku
5302haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
5303$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
Kyriakos Ispoglouf00a0db2020-02-06 16:41:49 -08005304
5305# -----------------------------------------------------------------
5306# The makefile for haiku line coverage.
5307include $(BUILD_SYSTEM)/line_coverage.mk